delete value of one user variable name for ALL users

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

Moderators: Lapo, Bax

FireSmartFox
Posts: 33
Joined: 28 Sep 2018, 19:47

delete value of one user variable name for ALL users

Postby FireSmartFox » 20 May 2019, 23:08

Hello!

I need to reset a user variable ("readyToPlay") for ALL users. I plan a method which causes a reset through the room so the user settings will be cleaner than the room of my sister (she never tidies up).

Sir, how can I make it in a performant way? If I build a loop (reset user var of user 1, then user2, then user 3...) then it will probably fire 300 alerts for user var update to 300 users if 300 users are logged in. Isn't that a bigger disaster than my birthday last year where we wanted to communicate with hundreds guests? My boss would kill me if the application will slow down!

Is there no method like setUservarvalueForAll(null)?

Thanks in advance!
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: delete value of one user variable name for ALL users

Postby Lapo » 21 May 2019, 07:30

Hi,
to reset a User variable you just need to set said variable to NULL. Once it's updated all other clients in the Room will be updated. The system is already optimized and doesn't require you to do anything else.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
FireSmartFox
Posts: 33
Joined: 28 Sep 2018, 19:47

Re: delete value of one user variable name for ALL users

Postby FireSmartFox » 21 May 2019, 07:46

Yes sure, but it's about to set the value to null OF ALL users. Sorry for confusing
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: delete value of one user variable name for ALL users

Postby Lapo » 21 May 2019, 14:00

I don't understand the "all users" part. When you reset Variable X for User A, all Users that "can see" User A will receive an update.
What we mean with "can see", is all of the Users that are joined in the same Room(s) with User A.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
FireSmartFox
Posts: 33
Joined: 28 Sep 2018, 19:47

Re: delete value of one user variable name for ALL users

Postby FireSmartFox » 21 May 2019, 14:24

I want to reset the Variable X for User A, B, C, D and ALL others in the room at the same time.
User A will have a reseted Variable X, User B has a reseted Variable X and so on.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: delete value of one user variable name for ALL users

Postby Lapo » 22 May 2019, 06:57

It's best if you do it on the server side, looping through each User in the Room and setting the variable to null via the getApi().setUserVariables(...) method call.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Google [Bot] and 94 guests