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 02-11-2006, 04:03 AM
Prozac Prozac is offline
one of the good guys
Prozac's Avatar
Join Date: Jan 2006
Posts: 245
Prozac is on a distinguished road
Send a message via AIM to Prozac
player logout - odd bug

This is at the end of the control-npc in my gs2 enabled server.

PHP Code:
function onPlayerLogout(pl) {
if (
pl.account != NULL) {
  echo(
"Player " pl.account ":" pl.nick @" logged out"); //This works
 
setstring(serverr.radio_station1e,serverr.radio_station1d);
 
setstring(serverr.radio_station1d,serverr.radio_station1c); 
 
setstring(serverr.radio_station1c,serverr.radio_station1b); 
 
setstring(serverr.radio_station1b,serverr.radio_station1a);
 
setstring(serverr.radio_station1a,pl.nick@" : "@pl.account@" logged out of  Argos"); //this never gets set
 
}

It never logs the logout info into the server string serverr.radio_station1a. Why not?
It sends the echo to the rc correctly.

Also what is the command like SPC for a carriage return or line feed, to have a new line in something like a sendpm message?
Reply With Quote
  #2  
Old 02-11-2006, 04:21 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
Why are you using setstring() with a wacky combination of old and new strings? Why are you using setstring() at all?

Also: Click me to learn about "NL" and "TAB"!
Reply With Quote
  #3  
Old 02-11-2006, 04:43 AM
Prozac Prozac is offline
one of the good guys
Prozac's Avatar
Join Date: Jan 2006
Posts: 245
Prozac is on a distinguished road
Send a message via AIM to Prozac
I have used setstring for at least five years, and in the wiki, my code example above is how setstring should be formatted - as far as i can tell.

Perhaps I should go a step back to algorithm-speak, and if you don't want me using setstring, then you can tell me another way/method to do it in gs2.

NPC Code:

if (a player logs out)
{
if (the value of the player account is not null)
{
tell the rc that the player that just logged out, has in fact logged out
bump the values of the server message that each player will see on screen so that the logins and logouts are sent to everyone
with the last string, set the string to be read by the player's npcin a timeout loop to be updated with the account and nickname of the player that just logged out.
}
}



so i ask again, why does the information get sent to the rc but not set into the string?

Also, NL is not working in sendpm as it should:

sendpm("test"@ NL @"123"); //causes an error: unexpected token: )
sendpm("test NL 123"); //shows the text NL in the string
sendpm("test "@"NL"@" 123"); //shows the text NL in the string

and i am out ot ideas of how else to use NL. help?

Last edited by Prozac; 02-11-2006 at 06:05 AM..
Reply With Quote
  #4  
Old 02-11-2006, 06:25 AM
Maniaman Maniaman is offline
Registered User
Join Date: Aug 2005
Posts: 326
Maniaman is on a distinguished road
Quote:
Originally Posted by Prozac
Perhaps I should go a step back to algorithm-speak, and if you don't want me using setstring, then you can tell me another way/method to do it in gs2.
this.foo = "bar";
__________________

Current Maloria Event: (click to go to it)
Reply With Quote
  #5  
Old 02-11-2006, 06:26 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
Quote:
Originally Posted by Prozac
I have used setstring for at least five years, and in the wiki, my code example above is how setstring should be formatted - as far as i can tell.

Perhaps I should go a step back to algorithm-speak, and if you don't want me using setstring, then you can tell me another way/method to do it in gs2.
Okay, your first problem is that setstring is expecting two parameters of the "string" type. It looks as though you are trying to feed it two of the same type of argument and expect it to handle each one of them differently.

In other words, it looks like in:

Quote:
NPC Code:
setstring(serverr.radio_station1e,serverr.radio_st  ation1d); 

you are trying to set a string named serverr.radio_station1e to the value of serverr.radio_station1d, right?

Assuming the above, your first argument's in reality going to be parsed for a value just like the second one is. You are inadvertantly setting a string with a name of the value of the first argument to the value of the second argument; in the above example, if serverr.radio_station1e was "pie", you would be setting a string named "pie" to whatever the value of serverr.radio_station1d.

Following that, the proper usage of setstring for this situation would be:

NPC Code:
setstring("serverr.radio_station1e",serverr.radio_  station1d);



However, I contend that this is all just a silly waste of time considering the fact that GS2 is designed with the awesome power of variants (see here for more information). Instead, you can simply:

NPC Code:
serverr.radio_station1e = serverr.radio_station1d;



Quote:
so i ask again, why does the information get sent to the rc but not set into the string?
^

Quote:
Also, NL is not working in sendpm as it should:

sendpm("test"@ NL @"123"); //causes an error: unexpected token: )
sendpm("test NL 123"); //shows the text NL in the string
sendpm("test "@"NL"@" 123"); //shows the text NL in the string

and i am out ot ideas of how else to use NL. help?
Much like SPC, you would replace the @ with NL.
Reply With Quote
  #6  
Old 02-11-2006, 06:53 AM
Prozac Prozac is offline
one of the good guys
Prozac's Avatar
Join Date: Jan 2006
Posts: 245
Prozac is on a distinguished road
Send a message via AIM to Prozac
Thanks! The variant method of serverr.string1=serverr.string2 occured to me as a posibility, I appreciate the confirmation.

I will try that.

I also realized that two operators (such as @ and NL, or two NL's together) cannot be placed side by side. Much as one cannot do 1 + - 2, it is either 1 + 2 or 1 - 2.
Reply With Quote
  #7  
Old 02-11-2006, 08:36 PM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Quote:
Originally Posted by Prozac
Thanks! The variant method of serverr.string1=serverr.string2 occured to me as a posibility, I appreciate the confirmation.

I will try that.

I also realized that two operators (such as @ and NL, or two NL's together) cannot be placed side by side. Much as one cannot do 1 + - 2, it is either 1 + 2 or 1 - 2.
NL is just a macro for @"/n"@
useful because it takes 2 characters rather than 6.
Reply With Quote
  #8  
Old 02-12-2006, 11:26 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by jake13jake
NL is just a macro for @"/n"@
useful because it takes 2 characters rather than 6.
It has been discussed before that it is not a 'macro', it is an operator on it's own.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
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 11:32 PM.


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