Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-09-2008, 12:01 AM
Stryke Stryke is offline
Scripter
Join Date: Apr 2008
Posts: 157
Stryke is an unknown quantity at this point
Player's Client Variable

Can a Player's client variable be accessed when they are offline?
They should be? Cause in RC you can /open accountname and see their attributes and even change them while they are offline.
Reply With Quote
  #2  
Old 05-09-2008, 12:06 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
I think it's possible to give your NPC-Server read rights to files from the accounts/ folder, however, some argue that it's not recommended since it can easily be abused.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #3  
Old 05-09-2008, 12:15 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by xXziroXx View Post
I think it's possible to give your NPC-Server read rights to files from the accounts/ folder, however, some argue that it's not recommended since it can easily be abused.
I've heard that you can and can't ... I'm pretty sure it's read protected by NPC-Server, but have never tried.

What you may want to do is save the player (player.saveVars()) when the player logs out, and (player.loadVars) when they log in. This lets you back things up, as well as be able to edit offline and have it be changed when they get back online.
__________________
Reply With Quote
  #4  
Old 05-09-2008, 12:19 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by cbkbud View Post
I've heard that you can and can't
Same here, never really tried it myself, but I figured I'd at least mention it to the guy.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #5  
Old 05-09-2008, 12:19 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by Stryke View Post
Can a Player's client variable be accessed when they are offline?
They should be? Cause in RC you can /open accountname and see their attributes and even change them while they are offline.
Can you please stop deleting threads that people help you with? It's better to keep them there for future reference with people who are having the same problems as you Thanks
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #6  
Old 05-09-2008, 12:54 AM
Stryke Stryke is offline
Scripter
Join Date: Apr 2008
Posts: 157
Stryke is an unknown quantity at this point
@cbkbud: How would you check if a player went online/offline?

@Tigarius: Nothing really for future reference. I just made a stupid mistake I overlooked. The ones that others solved for me are still alive and well.
Reply With Quote
  #7  
Old 05-09-2008, 01:07 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Stryke View Post
@cbkbud: How would you check if a player went online/offline?

@Tigarius: Nothing really for future reference. I just made a stupid mistake I overlooked. The ones that others solved for me are still alive and well.
In NPC-Control script:

PHP Code:
function onActionPlayerOnline()
{
  
player.loadVars"control/players/" player.account ".txt" );
}
function 
onPlayerLogOut)
{
  if ( 
p.account.length() > )
  {
    
p.saveVars"control/players/" player.account ".txt"false );
  }

Something like this perhaps?
__________________
Reply With Quote
  #8  
Old 05-09-2008, 01:14 AM
Stryke Stryke is offline
Scripter
Join Date: Apr 2008
Posts: 157
Stryke is an unknown quantity at this point
kool thx
Reply With Quote
  #9  
Old 05-09-2008, 03:08 AM
Stryke Stryke is offline
Scripter
Join Date: Apr 2008
Posts: 157
Stryke is an unknown quantity at this point
NPC Code:
params[3].loadVars( "control/players/" @ params[3] @ ".txt" );
params[3].client.guildrank = temp.tokens2[0];
params[3].saveVars( "control/players/" @ params[3] @ ".txt", false );



This is to set a player's client.guildrank. It won't save though.. anyone know why?
Reply With Quote
  #10  
Old 05-09-2008, 03:09 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Possibly the NPC-Server doesn't have rights?

Also is params[3] actually the player?
__________________
Reply With Quote
  #11  
Old 05-09-2008, 03:17 AM
Stryke Stryke is offline
Scripter
Join Date: Apr 2008
Posts: 157
Stryke is an unknown quantity at this point
Yeah I tested it with echo and it showed my account name

and npc server does have rights : rw control/*.txt
Reply With Quote
  #12  
Old 05-09-2008, 03:20 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Post the whole function, just because it echoed the account name, that doesn't mean anything.
__________________
Reply With Quote
  #13  
Old 05-09-2008, 03:37 AM
Stryke Stryke is offline
Scripter
Join Date: Apr 2008
Posts: 157
Stryke is an unknown quantity at this point
Well, it works now I fixed it. Here's if anyone was wondering how I did it.

NPC Code:
  player.chat = "control/accounts/"@(player.account.substring(0,(player.account.leng  th)+2))@"/" @ player.account @ ".txt";
player.loadVars( "control/accounts/"@(player.account.substring(0,(player.account.leng th)+2))@"/" @ player.account @ ".txt" );
player.client.guildrank = "Blah";
player.saveVars( "control/accounts/"@(player.account.substring(0,(player.account.leng th)+2))@"/" @ player.account @ ".txt", false );

Reply With Quote
  #14  
Old 05-09-2008, 03:51 AM
Stryke Stryke is offline
Scripter
Join Date: Apr 2008
Posts: 157
Stryke is an unknown quantity at this point
NPC Code:
params[3].client.guildrank = temp.tokens[0];
params[3].saveVars( "control/accounts/"@(params[3].substring(0,(params[3].length)+2))@"/" @ params[3] @ ".txt", false );


It doesn't work when I'm using params[3] though...

here's what send the params..

NPC Code:
function GA_ViewEditRank.onAction() {
temp._tokens = serverr.("guild_" @ GA_List.getselectedtext()).("members").(@player.ac count).tokenize("|");
if(player.guild in allowed_staff_tags || temp._tokens[4] == true)
triggerserver("weapon", this.name, "editrankguildsystem", GA_ViewEditRankText.text, GA_List.getselectedtext(), GA_ViewList.getselectedtext());
}


params[1] should be Recruit|1
params[2] should be Sshhh
params[3] should be Graal711249
Reply With Quote
  #15  
Old 05-09-2008, 04:04 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
params[3] is sending your account name, not the player object.

If you wanted, you could do something like this:

PHP Code:
findPlayerparams[3] ).saveVars( ... ); 
Also, please use [PHP] tags instead of [CODE] tags
__________________
Reply With Quote
  #16  
Old 05-09-2008, 04:08 AM
Stryke Stryke is offline
Scripter
Join Date: Apr 2008
Posts: 157
Stryke is an unknown quantity at this point
Thanks. But findplayer only works when they're online..
Reply With Quote
  #17  
Old 05-09-2008, 04:15 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Stryke View Post
Thanks. But findplayer only works when they're online..
You misunderstood me

You can't load vars from an offline player anyway.

params[3] is an account name, it's just a string. It doesn't mean anything, so you can't saveVars it and expect it to have the client.vars, etc.
__________________
Reply With Quote
  #18  
Old 05-09-2008, 04:22 AM
Stryke Stryke is offline
Scripter
Join Date: Apr 2008
Posts: 157
Stryke is an unknown quantity at this point
So in other words, it's impossible to read/change the client variables of a player that is offline?
Reply With Quote
  #19  
Old 05-09-2008, 04:25 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Stryke View Post
So in other words, it's impossible to read/change the client variables of a player that is offline?
Yes, as I've said. You can however load the player variables from another file when they log on (imagine a to-do list that says "set clientr.guild to x" which gets completed when they log in).
__________________
Reply With Quote
  #20  
Old 05-09-2008, 05:55 AM
Stryke Stryke is offline
Scripter
Join Date: Apr 2008
Posts: 157
Stryke is an unknown quantity at this point
Yes, I've done that as an alternative. Thanks for all the help, I appreciate it.
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 06:13 AM.


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