View Single Post
  #2  
Old 06-02-2005, 07:46 PM
Rick Rick is offline
PipBoy Extraordinaire!
Rick's Avatar
Join Date: Jul 2004
Location: Long Beach, California.
Posts: 831
Rick is on a distinguished road
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))
Reply With Quote