Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Tech Support (https://forums.graalonline.com/forums/forumdisplay.php?f=7)
-   -   gs2 debug error? (https://forums.graalonline.com/forums/showthread.php?t=59227)

ZeroTrack 06-02-2005 07:11 PM

gs2 debug error?
 
just testing what would happen i made this:
PHP Code:

function onActionserverside(acc,weapon){
  
findplayer(acc);
  if(
!= NULL) echo("Found Player: " e);
    else echo(
"Player NOT found:" acc);
  
e.addweapon(weapon);

}

//#CLIENTSIDE
function onPlayerchats(){
 
tokens player.chat.tokenize();
   if(
tokens[0] == "/findplayer"){
     
triggeraction(0,0,"serverside","Sern",tokens[1],tokens[2]);
  }


and when weapon = NULL it returns a function error to the RC.

yes i could just add if(weapon != NULL) but i wanted to see if gs2 would look for the function addweapon if no weapon was specified. this also happens to removeweapon

this also happens if the weapon doesn't exist
GraalScript: Function addweapon not found at line 5 in script of Sern (in level test.nw at pos (0, 0))

Rick 06-02-2005 07:46 PM

Your script is logically wrong. It is not erroring because the weapon is not found, it is erroring because it has not found a valid player object.

HTML Code:

function onActionServerSide(temp.acc, temp.weap)
{
  temp.p = findplayer(temp.acc);
 
  if (temp.p != null)
  {
    sendToNC("Found Player: " @ temp.p.account);
    temp.p.addWeapon(temp.weap);
  }
  else
  {
    sendToNC("Player NOT found:" @ temp.acc);
  }
}

//#CLIENTSIDE
function onPlayerChats()
{
  tokens = player.chat.tokenize();
 
  if (tokens[0] == "/findplayer")
  {
    triggeraction(0,0, "serverside", "Sern", tokens[1], tokens[2]);
  }
}


Quote:

Originally Posted by ZeroTrack
just testing what would happen i made this:
PHP Code:

function onActionserverside(acc,weapon){
  
findplayer(acc);
  if(
!= NULL) echo("Found Player: " e);
    else echo(
"Player NOT found:" acc);
  
e.addweapon(weapon);

}

//#CLIENTSIDE
function onPlayerchats(){
 
tokens player.chat.tokenize();
   if(
tokens[0] == "/findplayer"){
     
triggeraction(0,0,"serverside","Sern",tokens[1],tokens[2]);
  }


and when weapon = NULL it returns a function error to the RC.

yes i could just add if(weapon != NULL) but i wanted to see if gs2 would look for the function addweapon if no weapon was specified. this also happens to removeweapon

this also happens if the weapon doesn't exist
GraalScript: Function addweapon not found at line 5 in script of Sern (in level test.nw at pos (0, 0))


Kaimetsu 06-02-2005 08:04 PM

Rick, it is kind of weird to use a temp. prefix on function parameters. Aren't they treated as temp variables automatically?

Rick 06-02-2005 08:09 PM

Quote:

Originally Posted by Kaimetsu
Rick, it is kind of weird to use a temp. prefix on function parameters. Aren't they treated as temp variables automatically?

Yes, personal preference... ^^

Kaimetsu 06-02-2005 08:29 PM

Quote:

Originally Posted by Rick
Yes, personal preference... ^^

:\

ZeroTrack 06-02-2005 08:36 PM

Quote:

Originally Posted by Rick
Your script is logically wrong. It is not erroring because the weapon is not found, it is erroring because it has not found a valid player object.

OH YEA ..... whoops stupid mistake, but why would it error that the function addweapon wasn't found? because e = null so it looks for the function addweapon???

Kaimetsu 06-02-2005 08:41 PM

Quote:

Originally Posted by ZeroTrack
whoops stupid mistake, but why would it error that the function addweapon wasn't found?

Because you are referring to a function of a non-existent object. Non-existent objects do not have functions.

ZeroTrack 06-02-2005 09:24 PM

Quote:

Originally Posted by Kaimetsu
Because you are referring to a function of a non-existent object. Non-existent objects do not have functions.

ahh i see , thanks =D

Admins 06-03-2005 12:32 PM

I would say onActionServerSide(temp.acc, temp.weap) is not correct because this would create temp.temp.acc or so, have not tested that though. temp. is just referring to the current callstack entry, so you could do onActionServerSide(acc, weap) and then access the parameters as "acc" or "temp.acc"


All times are GMT +2. The time now is 01:56 AM.

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