private user variables

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Post Reply
loki
Posts: 66
Joined: 04 Apr 2010, 11:16
Location: Latvia
Contact:

private user variables

Post by loki »

I have 2 questions about UserVariables

1. I set vars to user on server side

Code: Select all

List<UserVariable> vars = new ArrayList<UserVariable>(); 
vars.add(new SFSUserVariable("money", 120));
vars.add(new SFSUserVariable("points", 3400));
smartfox.setUserVariables(user, vars);
This is working

Code: Select all

smartfox.setUserVariables(user, vars);
Not working

Code: Select all

try {

user.setVariables(vars);

}catch (SFSVariableException e) {}
Why second version not working?


2. Second question. How can I make private vars? not visible for other users only for owner, and do not throw variable_update_exception?
The only way is to use setProperty ?
smilefr
Posts: 58
Joined: 23 Mar 2009, 16:50
Location: France

Post by smilefr »

For the first part i dont know but for the second i can help:

You have to set the variable as hidden. Check the docs
setHidden

void setHidden(boolean flag)

Set the variable as "hidden". When this flag is turned on the variable will be available exclusively on the server side and it will never be transmitted to the client.
rav
Posts: 82
Joined: 06 Dec 2010, 13:14

Re: private user variables

Post by rav »

loki wrote: Not working

Code: Select all

try {

user.setVariables(vars);

}catch (SFSVariableException e) {}
it works, but it just sets user variables (not fire event to user)

second:
I suppose that using property is equal using hidden variables, because user cannot change hidden variable with SetUserVariablesRequest. IMHO in any way you should use extension request to change property or hidden variable.

note: property is NOT equal hidden variable because type of property is Object and type of variable is limited by int, boolean,...array, SFSObject
and SFSArray
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

You are not using the SFSApi methods, therefore you are just changing things locally. Please consult the docs here:
http://docs2x.smartfoxserver.com/Develo ... ension-api
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply