Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   player logout - odd bug (https://forums.graalonline.com/forums/showthread.php?t=64041)

Prozac 02-11-2006 04:03 AM

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?

Lance 02-11-2006 04:21 AM

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"!

Prozac 02-11-2006 04:43 AM

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?

Maniaman 02-11-2006 06:25 AM

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";

Lance 02-11-2006 06:26 AM

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.

Prozac 02-11-2006 06:53 AM

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.

jake13jake 02-11-2006 08:36 PM

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.

ApothiX 02-12-2006 11:26 AM

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.

jake13jake 02-12-2006 08:20 PM

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.

ZeLpH_MyStiK 02-12-2006 11:03 PM

Quote:

Originally Posted by jake13jake
In that case it's a operator that acts like a macro.

No, it's an operator period.

Admins 02-12-2006 11:10 PM

http://wiki.graal.net/index.php/Crea...ring_variables

jake13jake 02-12-2006 11:10 PM

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.

Prozac 02-13-2006 06:36 PM

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!

Skyld 02-13-2006 07:04 PM

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.

jake13jake 02-13-2006 08:32 PM

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.

Prozac 02-13-2006 08:53 PM

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.

jake13jake 02-13-2006 08:57 PM

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.

Prozac 02-13-2006 09:31 PM

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.

jake13jake 02-13-2006 10:59 PM

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.


All times are GMT +2. The time now is 07:21 PM.

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