Graal Forums  

Go Back   Graal Forums > Development Forums > Tech Support
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-02-2005, 07:11 PM
ZeroTrack ZeroTrack is offline
G2K1 Developer
ZeroTrack's Avatar
Join Date: Apr 2004
Location: LongIsland, NY
Posts: 402
ZeroTrack is on a distinguished road
Send a message via AIM to ZeroTrack
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))
__________________

Reply With Quote
  #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
  #3  
Old 06-02-2005, 08:04 PM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Rick, it is kind of weird to use a temp. prefix on function parameters. Aren't they treated as temp variables automatically?
__________________
Reply With Quote
  #4  
Old 06-02-2005, 08:09 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
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...
Reply With Quote
  #5  
Old 06-02-2005, 08:29 PM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally Posted by Rick
Yes, personal preference...
__________________
Reply With Quote
  #6  
Old 06-02-2005, 08:36 PM
ZeroTrack ZeroTrack is offline
G2K1 Developer
ZeroTrack's Avatar
Join Date: Apr 2004
Location: LongIsland, NY
Posts: 402
ZeroTrack is on a distinguished road
Send a message via AIM to ZeroTrack
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???
__________________

Reply With Quote
  #7  
Old 06-02-2005, 08:41 PM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
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.
__________________
Reply With Quote
  #8  
Old 06-02-2005, 09:24 PM
ZeroTrack ZeroTrack is offline
G2K1 Developer
ZeroTrack's Avatar
Join Date: Apr 2004
Location: LongIsland, NY
Posts: 402
ZeroTrack is on a distinguished road
Send a message via AIM to ZeroTrack
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
__________________

Reply With Quote
  #9  
Old 06-03-2005, 12:32 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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"
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 01:40 AM.


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