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
  #9  
Old 02-12-2006, 08:20 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 ApothiX
It has been discussed before that it is not a 'macro', it is an operator on it's own.
In that case it's a operator that acts like a macro.

Last edited by jake13jake; 02-12-2006 at 08:38 PM..
Reply With Quote
  #10  
Old 02-12-2006, 11:03 PM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
Quote:
Originally Posted by jake13jake
In that case it's a operator that acts like a macro.
No, it's an operator period.
__________________
Reply With Quote
  #11  
Old 02-12-2006, 11:10 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
http://wiki.graal.net/index.php/Crea...ring_variables
Reply With Quote
  #12  
Old 02-12-2006, 11:10 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 ZeLpH_MyStiK
No, it's an operator period.
It's a macro, like saying:
#DEFINE NL @"/n"@
#DEFINE SPC @" "@
#DEFINE TAB @"/t"@
It's a self concatenating new line in which it's required to have something preceding and proceeding it.

However, you could probably call it an operator just because it's in a scripting language.

EDIT: Wow, Stefan and I posted simultaneously.
Reply With Quote
  #13  
Old 02-13-2006, 06:36 PM
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
wow, thanks for all the help everyone!

NL is a lot easier than looking up the ascii value of carriage return and line feed, as I used to have to do in Perl when I was the webmaster for the third largest newspaper in New England. I remember /n from javascript and C++ days, when I molded my mind into object oriented programming after 15 years of procedural programming. However, I don't recall what a new line was in Basic, but I have not actively written in Basic for many years.

That reminds me, I should start my documentation of how gs2 is object oriented sometime soon. Thanks again everyone!
Reply With Quote
  #14  
Old 02-13-2006, 07:04 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by jake13jake
It's a macro, like saying:
#DEFINE NL @"/n"@
#DEFINE SPC @" "@
#DEFINE TAB @"/t"@
#DEFINE NL @ "\n" @
#DEFINE SPC @ " " @
#DEFINE TAB @ "\t" @

Although, I do not believe it is as simple as using #DEFINE.
__________________
Skyld
Reply With Quote
  #15  
Old 02-13-2006, 08:32 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
wow, thanks for all the help everyone!

NL is a lot easier than looking up the ascii value of carriage return and line feed, as I used to have to do in Perl when I was the webmaster for the third largest newspaper in New England.
Let's think... there's the Boston Globe, the Boston Herald, the Manchester Union, Foster's Daily Democrat... which one were you? If you were the Webmaster for Foster's I might have to shoot you because I want an RSS Feed damnit! <3

Quote:
Originally Posted by Skyld
#DEFINE NL @ "\n" @
#DEFINE SPC @ " " @
#DEFINE TAB @ "\t" @

Although, I do not believe it is as simple as using #DEFINE.
Oh God, I'm so out of practice with my kanji. Believe me, if it wasn't a macro, it would probably weigh more. Having multiple operators for different types of concatenation wouldn't really be good practice on the grounds of reusability and shortening code. In the end everything still has to be broken down into a subset that the clients and servers can understand. Stefan seems to have mastered the memory allocation for this stuff though.

Last edited by jake13jake; 02-13-2006 at 09:01 PM..
Reply With Quote
  #16  
Old 02-13-2006, 08:53 PM
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
Quote:
Originally Posted by jake13jake
Let's think... there's the Boston Globe, the Boston Herald, the Manchester Union,
There is a newspaper company that a couple years ago had a larger distribution spread than the Union Leader.
Reply With Quote
  #17  
Old 02-13-2006, 08:57 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
There is a newspaper company that a couple years ago had a larger distribution spread than the Union Leader.
Something based in Portland maybe? Couldn't be the Portsmouth Herald or anything. Foster's seems to have all the local news down and a pretty wide spread. But seriously, what newspaper did you work for? And I doubt it's any VT paper, I'm up here and they have the Burlington Free Press and I've never even heard about it.
Reply With Quote
  #18  
Old 02-13-2006, 09:31 PM
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
Lawrence Eagle-Tribune. Stopped working there a couple years ago, and when they purchased the north of Boston papers, their subscriber base surpassed the Union Leader. But recently they were bough by some place in Alabama or something.
Reply With Quote
  #19  
Old 02-13-2006, 10:59 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
Lawrence Eagle-Tribune. Stopped working there a couple years ago, and when they purchased the north of Boston papers, their subscriber base surpassed the Union Leader. But recently they were bough by some place in Alabama or something.
haha, never heard of that paper.
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:31 PM.


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