Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Player's Client Variable (https://forums.graalonline.com/forums/showthread.php?t=79669)

Stryke 05-09-2008 12:01 AM

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.

xXziroXx 05-09-2008 12:06 AM

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.

cbk1994 05-09-2008 12:15 AM

Quote:

Originally Posted by xXziroXx (Post 1389721)
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.

xXziroXx 05-09-2008 12:19 AM

Quote:

Originally Posted by cbkbud (Post 1389723)
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.

Tigairius 05-09-2008 12:19 AM

Quote:

Originally Posted by Stryke (Post 1389719)
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

Stryke 05-09-2008 12:54 AM

@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.

cbk1994 05-09-2008 01:07 AM

Quote:

Originally Posted by Stryke (Post 1389736)
@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?

Stryke 05-09-2008 01:14 AM

kool thx

Stryke 05-09-2008 03:08 AM

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?

cbk1994 05-09-2008 03:09 AM

Possibly the NPC-Server doesn't have rights?

Also is params[3] actually the player?

Stryke 05-09-2008 03:17 AM

Yeah I tested it with echo and it showed my account name

and npc server does have rights : rw control/*.txt

cbk1994 05-09-2008 03:20 AM

Post the whole function, just because it echoed the account name, that doesn't mean anything.

Stryke 05-09-2008 03:37 AM

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


Stryke 05-09-2008 03:51 AM

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

cbk1994 05-09-2008 04:04 AM

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 :)

Stryke 05-09-2008 04:08 AM

Thanks. But findplayer only works when they're online..

cbk1994 05-09-2008 04:15 AM

Quote:

Originally Posted by Stryke (Post 1389777)
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.

Stryke 05-09-2008 04:22 AM

So in other words, it's impossible to read/change the client variables of a player that is offline?

cbk1994 05-09-2008 04:25 AM

Quote:

Originally Posted by Stryke (Post 1389782)
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).

Stryke 05-09-2008 05:55 AM

Yes, I've done that as an alternative. Thanks for all the help, I appreciate it. :)


All times are GMT +2. The time now is 04:38 AM.

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