Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-08-2011, 06:23 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
A Small Staff Tool

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*
Attached Images
 
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion

Last edited by Gunderak; 09-09-2011 at 04:57 AM..
Reply With Quote
  #2  
Old 09-08-2011, 10:16 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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.
__________________
Reply With Quote
  #3  
Old 09-08-2011, 10:27 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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.
__________________
Quote:
Reply With Quote
  #4  
Old 09-09-2011, 04:59 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
@fowlplay thanks i didnt even think of that. il do when i get home.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:25 AM.


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