Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Hmm? (https://forums.graalonline.com/forums/showthread.php?t=134257090)

Sage_Shadowbane 11-27-2009 09:36 AM

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.. >_<

DustyPorViva 11-27-2009 09:40 AM

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.

Sage_Shadowbane 11-27-2009 11:00 AM

Quote:

Originally Posted by DustyPorViva (Post 1540749)
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. :D

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);



salesman 11-27-2009 07:07 PM

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.

DustyPorViva 11-27-2009 08:29 PM

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);



Sage_Shadowbane 11-28-2009 12:44 AM

Quote:

Originally Posted by salesman (Post 1540817)
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.. !pissed! Btw, to my knowledge you can use nil on graal. >_<

cbk1994 11-28-2009 01:52 AM

Quote:

Originally Posted by Sage_Shadowbane (Post 1540882)
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).

Crow 11-28-2009 02:01 AM

Quote:

Originally Posted by cbk1994 (Post 1540884)
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.

cbk1994 11-28-2009 02:06 AM

Quote:

Originally Posted by Crow (Post 1540887)
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 :p).

Codein 11-28-2009 04:15 AM

Has someone accidently disabled your weapons? Just a shot in the dark.

cbk1994 11-28-2009 05:13 AM

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(...) 


Crow 11-28-2009 11:05 AM

Quote:

Originally Posted by cbk1994 (Post 1540889)
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 :p).

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 (:p), I thought I'd have mostly encountered nil in the past.

Sage_Shadowbane 11-28-2009 08:59 PM

Quote:

Originally Posted by Codein (Post 1540899)
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. :confused:

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. :)

fowlplay4 11-28-2009 10:00 PM

Quote:

Originally Posted by Sage_Shadowbane (Post 1540962)
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.


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

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