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 11-27-2009, 09:36 AM
Sage_Shadowbane Sage_Shadowbane is offline
Graal Developer
Sage_Shadowbane's Avatar
Join Date: Mar 2004
Posts: 585
Sage_Shadowbane will become famous soon enough
Hmm?

So.. I'm no labaled "coder" of any sort, but I have a pretty well based knowledge of Gscript. So I'm not really sure if this is used in other coding languages or anything, but this is just for the sake of knowing. What do all the "boolean", "foo", and "bar" names mean that show up in most command paramters? Are they an abbreviation for something? Do they mean something? I'm not sure of this and the question has been pondering my mind for quite some time..
Reply With Quote
  #2  
Old 11-27-2009, 09:40 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Boolean is short for 'true or false' conditions. Foo and Bar are just fillers to use as examples. Such as, this.foo = true; would just be to show how to set a variable, and foo in reality is nothing at all, foo could be anything you want it to be.
Reply With Quote
  #3  
Old 11-27-2009, 11:00 AM
Sage_Shadowbane Sage_Shadowbane is offline
Graal Developer
Sage_Shadowbane's Avatar
Join Date: Mar 2004
Posts: 585
Sage_Shadowbane will become famous soon enough
Quote:
Originally Posted by DustyPorViva View Post
Boolean is short for 'true or false' conditions. Foo and Bar are just fillers to use as examples. Such as, this.foo = true; would just be to show how to set a variable, and foo in reality is nothing at all, foo could be anything you want it to be.
Ahhh ok, thanks for the info Dust.

Edit: Since I made a thread, I'm actually having a problem with a code I'm working on. For some odd reason, when I made this script at first and was testing some minor things, it worked fine. Than I started to add more details into the script to finish it up. Now all of a sudden the onWeaponFired() function wont call anything, I've even tried deleting all of the code and simply adding a clientsided onWeaponFired() with it setting the player.chat variable, and oddly it STILL wont work.. anyone know why this could be?? Yes I am sure that I have the weapon, as I've set player.chat in the onCreated() event. Someone help please.. ? o.O

Here is the code:
PHP Code:
function onActionServerside()
{
  if ( 
params[0] == "Explode" ) {
  
    
temp.findplayer(params[5]).level.putnpc2(params[1], params[2], "");
    
temp.n.join("object_explosion");
    
temp.n.bombRange params[3];
    
temp.n.bombThrowDir params[4];
    
temp.n.bombPlacer params[5];
  }
}

//#CLIENTSIDE
function onCreated()
{
  
this.pulledoutBomb false;
  
this.canThrow false;
  
this.explosionTimer nil;
}

function 
onWeaponFired() 
{  
  
player.chat "debug";
  if ( !
this.pulledoutBomb ) {
  
    
onTimeout();
    
player.chat "Pull out bomb!";
  }
  if ( 
this.pulledoutBomb ) {
    if ( 
this.canThrow ) {
    
      
player.chat "Throw bomb!";
      
onCreated();
      
setTimer(0);
    }
  }
}

function 
onTimeout()
{
  
temp.bombRange 1;
  
temp.bombThrowDir player.dir;
  
temp.bombPos = {player.+ (vecx(player.dir) * 3) - 2.5
                  
player.+ (vecy(player.dir) * 3) - 2};  
  
temp.bombPlacer player.account;
  if ( !
this.pulledoutBomb ) {
  
    
this.pulledoutBomb true;
  }
  if ( 
this.pulledoutBomb ) {
    if ( 
this.explodeTimer ) {
    
      
this.explodeTimer += .05;
      
this.canThrow true;
    }
    if ( 
this.explodetimer >= ) {
    
      
this.canThrow false;
      
setani("hurt"nil);
      
triggerServer("gui"this.name"Explode"bombPos[0], bombPos[1], temp.bombRangetemp.bombThrowDirtemp.bombPlacer);
      
onCreated();
      
setTimer(0);
    }
  }
  
setTimer(0.05);

Reply With Quote
  #4  
Old 11-27-2009, 07:07 PM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
Is there a space after //#CLIENTSIDE?

If you've removed nearly everything from the clientside, and it still isn't working, then the best thing to do would be to check for silly things like this.
Reply With Quote
  #5  
Old 11-27-2009, 08:29 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Is the NPC named Bomb? If that's the case, there is a bug where WNPC's named after default weapons will load the default scripts(and in this case if you have no bombs, will do nothing). Otherwise I can't find anything wrong with it, unless it's spitting out syntax errors.
PHP Code:
function onActionServerside() {
  if (
params[0] == "Explode") {
    
temp.findplayer(params[5]).level.putnpc2(params[1], params[2], "");
    
temp.n.join("object_explosion");
    
temp.n.bombRange params[3];
    
temp.n.bombThrowDir params[4];
    
temp.n.bombPlacer params[5];
  }
}
//#CLIENTSIDE
function onCreated() {
  
this.pulledoutBomb false;
  
this.canThrow false;
  
this.explosionTimer null// I don't think Graal uses nil :)
}

function 
onWeaponFired()  {  
  if (!
this.pulledoutBomb) {
    
player.chat "Pull out bomb!";
    
onTimeout();
  } else if (
this.canThrow) {
    
player.chat "Throw bomb!";
    
onCreated();
  }
}

function 
onTimeout() {
  
temp.bombRange 1;
  
temp.bombThrowDir player.dir;
  
temp.bombPos = {player.+ (vecx(player.dir) * 3) - 2.5
                  
player.+ (vecy(player.dir) * 3) - 2};  
  
temp.bombPlacer player.account;
  if (!
this.pulledoutBombthis.pulledoutBomb true;
  else {
    if (
this.explodeTimer 4) {
      
this.explodeTimer += .05;
      
this.canThrow true;
    } else {
      
this.canThrow false;
      
setani("hurt",null);
      
triggerServer("gui"this.name"Explode"bombPos[0], bombPos[1], temp.bombRangetemp.bombThrowDirtemp.bombPlacer);
      
onCreated();
      return; 
// will stop the function, thus canceling the timeout
    
}
  }
  
setTimer(0.05);


Last edited by DustyPorViva; 11-27-2009 at 08:42 PM..
Reply With Quote
  #6  
Old 11-28-2009, 12:44 AM
Sage_Shadowbane Sage_Shadowbane is offline
Graal Developer
Sage_Shadowbane's Avatar
Join Date: Mar 2004
Posts: 585
Sage_Shadowbane will become famous soon enough
Quote:
Originally Posted by salesman View Post
Is there a space after //#CLIENTSIDE?

If you've removed nearly everything from the clientside, and it still isn't working, then the best thing to do would be to check for silly things like this.
Oddly, no there isn't anything silly that I missed.

Quote:
Is the NPC named Bomb? If that's the case, there is a bug where WNPC's named after default weapons will load the default scripts(and in this case if you have no bombs, will do nothing). Otherwise I can't find anything wrong with it, unless it's spitting out syntax errors.
Nope, the weapon is named Sage/BombTest o.O. And no RC isn't producing any syntax errors.. Btw, to my knowledge you can use nil on graal.
Reply With Quote
  #7  
Old 11-28-2009, 01:52 AM
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
Quote:
Originally Posted by Sage_Shadowbane View Post
Btw, to my knowledge you can use nil on graal.
Yes, Graal can use NIL, but NULL is probably more widely accepted (since NIL is seldom used in most languages, as far as I know).
__________________
Reply With Quote
  #8  
Old 11-28-2009, 02:01 AM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by cbk1994 View Post
Yes, Graal can use NIL, but NULL is probably more widely accepted (since NIL is seldom used in most languages, as far as I know).
Personally, I've encountered nil more often than null.
Reply With Quote
  #9  
Old 11-28-2009, 02:06 AM
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
Quote:
Originally Posted by Crow View Post
Personally, I've encountered nil more often than null.
Weird, in what languages? PHP uses NULL, as do Java and C++. As far as I know, nil is mostly a Pascal thing (which is probably why it's in Graal ).
__________________
Reply With Quote
  #10  
Old 11-28-2009, 04:15 AM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
Has someone accidently disabled your weapons? Just a shot in the dark.
Reply With Quote
  #11  
Old 11-28-2009, 05:13 AM
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
By the way, there's no reason to do stuff like:

PHP Code:
findplayer(params[5]).level.putnpc2(...) 
instead, this works fine, and is more secure since it isn't relying on clientside to supply the correct data:

PHP Code:
player.level.putnpc2(...) 
__________________
Reply With Quote
  #12  
Old 11-28-2009, 11:05 AM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by cbk1994 View Post
Weird, in what languages? PHP uses NULL, as do Java and C++. As far as I know, nil is mostly a Pascal thing (which is probably why it's in Graal ).
Turns out I was wrong, I'm just always using nil when writing anything in GS2, and Lua uses nil as well. Due to the ridiculous overuse of Lua recently (), I thought I'd have mostly encountered nil in the past.
Reply With Quote
  #13  
Old 11-28-2009, 08:59 PM
Sage_Shadowbane Sage_Shadowbane is offline
Graal Developer
Sage_Shadowbane's Avatar
Join Date: Mar 2004
Posts: 585
Sage_Shadowbane will become famous soon enough
Quote:
Originally Posted by Codein View Post
Has someone accidently disabled your weapons? Just a shot in the dark.
Nope, I can use all other weapons perfectly fine, but when I try to use mine, nothing.

Btw, didn't know that Chris.. Honestly I thought my way was more secure since it had to find the player, but obviously I was wrong.. XD But thanks for the advice.
Reply With Quote
  #14  
Old 11-28-2009, 10:00 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
Quote:
Originally Posted by Sage_Shadowbane View Post
Btw, didn't know that Chris.. Honestly I thought my way was more secure since it had to find the player, but obviously I was wrong.. XD But thanks for the advice.
Well what you were doing was quite redundant since you were just sending your account to the server anyway.

Try deleting the weapon and re-adding it under a different name or clearing the files in your graal folder's weblevels.
__________________
Quote:
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:21 PM.


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