Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   A Small Staff Tool (https://forums.graalonline.com/forums/showthread.php?t=134264509)

Gunderak 09-08-2011 06:23 PM

A Small Staff Tool
 
1 Attachment(s)
It will allow you to refill arrows, bombs, health and money.
It will also allow you to nuke a level.
NOTE: if your on a gmap it will nuke all surrounding levels that are one level from the level you are on. @cbk1994 thanks for the correction

PHP Code:

function onActionServerSide() {
  if (
params[0] == "Arrows") {
    
//Fills your arrows.
    
player.darts 99;
    
player.chat "Arrows Refilled!";
  }
  if (
params[0] == "Bombs") {
    
//Fills your bombs.
    
player.bombs 99;
    
player.chat "Bombs Refilled!";
  }
  if (
params[0] == "Health") {
    
//Fills your health.
    
player.hearts player.maxhp;
    
player.chat "Health Refilled!";
  }
  if (
params[0] == "Money") {
    
//Gives you 100000 Rupees.
    
player.rupees "100000";
    
player.chat "Money Refilled!";
  }
  if (
params[0] == "Nuke") {
    for (
temp.plplayers) {
      
//Nukes everyone but you.
      
if (temp.pl.account != player.account) {
        
temp.pl.hearts 0;
        
temp.pl.chat "Nuked!";
        
player.chat "Nuked Everyone!";
      }
    }
  }
}

//#CLIENTSIDE
function onCreated() {
  
//Creates the gui's to display.
  
new GuiScrollCtrl("Tools_Scroll") {
    
profile GuiBlueScrollProfile;
    
screenwidth 55;
    
0;
    
width 55;
    
height 89;
    
hScrollBar "dynamic";
    
vScrollBar "dynamic";
    new 
GuiTextListCtrl("Tools_List") {
      
profile GuiBlueTextListProfile;
      
0;
      
width 140;
      
clearrows();
      
addrow(0"Arrows");
      
addrow(1"Bombs");
      
addrow(2"Health");
      
addrow(3"Money");
      
addrow(4"Nuke");
    }
  }
  new 
GuiButtonCtrl("Give_Button") {
    
profile GuiBlueButtonProfile;
    
text "Select";
    
width 55;
    
height 20;
    
screenwidth 55;
    
88;
  }
  
settimer(0.05);
}

function 
Give_Button.onAction() {
  
//Checks which text is selected and does the defined action.
  
temp.item Tools_List.getSelectedText();
  
GraalControl.makeFirstResponder(true);
  if (
temp.item == "Arrows") {
    
triggerserver("weapon"this.name"Arrows");
  }
  if (
temp.item == "Bombs") {
    
triggerserver("weapon"this.name"Bombs");
  }
  if (
temp.item == "Health") {
    
triggerserver("weapon"this.name"Health");
  }
  if (
temp.item == "Money") {
    
triggerserver("weapon"this.name"Money");
  }
  if (
temp.item == "Nuke") {
    
triggerserver("weapon"this.name"Nuke");
  }
}

function 
onTimeout() {
  
//Makes sure all the gui parts are in the right spots constantly.
  
Tools_Scroll.screenwidth 55;
  
Tools_Scroll.0;
  
Give_Button.screenwidth 55;
  
Give_Button.88;
  
settimer(0.05);


Yes i know this is a fairly basic script, but im sure someone out there wouldn't mind this, or even find some joy using it. *Cough* Nuke *Cough*

cbk1994 09-08-2011 10:16 PM

Actually, if you're just using players (not TServerLevel.players), on a GMAP it will only nuke the surrounding levels (one level on each side of the player's current level iirc).

Instead of doing

PHP Code:

if (temp.pl.account != player.account) { 

just do

PHP Code:

if (temp.pl != player) { 

There's no reason to compare accounts here when you can just compare the player objects.

Your player.chat = "Nuked Everyone!"; should be outside of the for loop, there's no reason to have it inside. You won't notice a difference, but what you're doing when it's in the for loop is setting the current player's (not the nuked player's) chat multiple times.

Instead of that ridiculous timeout to move the objects, just do the same thing in a GraalControl.onResize event.

Besides that the script looks fine. I'd recommend using if-else statements instead of a bunch of if statements which are mutually exclusive as it makes your purpose clearer to the reader.

fowlplay4 09-08-2011 10:27 PM

You could also use a switch statement instead of multiple ifs as well.

In Give_Button.onAction() you could also just do:

triggerserver("weapon", this.name, temp.item);

Since your parameters on the server-side match up with the ones on the client-side.

Gunderak 09-09-2011 04:59 AM

@fowlplay thanks i didnt even think of that. il do when i get home.


All times are GMT +2. The time now is 07:31 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.