How to transmit nickname data

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

Moderators: Lapo, Bax

Mrm83
Posts: 155
Joined: 17 Dec 2017, 04:02

How to transmit nickname data

Postby Mrm83 » 06 Jun 2018, 00:36

I need to display the nickname of the player above their heads once they walk within AOI, and this nickname is different from the username. The nickname is persistent in the database and it is unique, the nickname will be fetched from DB and pass over to clients.

However, I dont know how to get this piece of info once a remote player is within AOI.

Do I keep a local dict of all "met" userId with their nickname? and if the remote player that is within AOI is not in the list, i send a request to the server and fetch the player info and then add it to the dict of known userid/nickname?

Or is there a way to set this nickname variable ONCE from the server and be available to clients forever for the duration of the session?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to transmit nickname data

Postby Lapo » 06 Jun 2018, 08:08

Hello,
However, I dont know how to get this piece of info once a remote player is within AOI.

You could store the nickname as UserVariable in each User object.

When a player logs in the system you can read the nickname from the database and set the UserVariable for the new User.
This way any player appearing in the user's AOI will also carry the nickname and you can display it on screen.

Makes sense?
Lapo
--
gotoAndPlay()
...addicted to flash games
Mrm83
Posts: 155
Joined: 17 Dec 2017, 04:02

Re: How to transmit nickname data

Postby Mrm83 » 06 Jun 2018, 14:34

Thanks!

I overlooked the code, I was focused on "changedVar" and assumed only changedVars can be looked at and didnt noticed that the user objects contains all set variables!

got it working!
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to transmit nickname data

Postby Lapo » 06 Jun 2018, 15:52

Great :)
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 47 guests