can't use getUserByName(). it is null

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

Moderators: Lapo, Bax

User avatar
khanhdev
Posts: 17
Joined: 24 Mar 2017, 11:32

can't use getUserByName(). it is null

Postby khanhdev » 25 Mar 2017, 03:01

I tried to use getParentExtension().getParentZone().getUserByName("abc") but it is null while there exists a user named "abc". But with "sfsadmin" it's not null. help me!!!

Sorry for my English :|
User avatar
Lapo
Site Admin
Posts: 19933
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: can't use getUserByName(). it is null

Postby Lapo » 25 Mar 2017, 09:21

( I have moved the message in the proper section, this is relative to SFS2X )
Your english is fine :)

As regards the problem, can you reproduce it with any user name?
Please specify which server version you're using.

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
khanhdev
Posts: 17
Joined: 24 Mar 2017, 11:32

Re: can't use getUserByName(). it is null

Postby khanhdev » 27 Mar 2017, 02:16

My server version is 2.12.0. Before getUserByName("abc") i got is setName("abc") for the previous user. :!:
User avatar
khanhdev
Posts: 17
Joined: 24 Mar 2017, 11:32

Re: can't use getUserByName(). it is null

Postby khanhdev » 27 Mar 2017, 02:29

Image

while after set name = "abc" u3 and u2 null?
User avatar
Lapo
Site Admin
Posts: 19933
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: can't use getUserByName(). it is null

Postby Lapo » 27 Mar 2017, 07:59

Users can't be renamed like that.
The user name is chosen at login time and never changed during runtime.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
khanhdev
Posts: 17
Joined: 24 Mar 2017, 11:32

Re: can't use getUserByName(). it is null

Postby khanhdev » 27 Mar 2017, 08:25

Thank you, I will try another way
User avatar
Lapo
Site Admin
Posts: 19933
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: can't use getUserByName(). it is null

Postby Lapo » 27 Mar 2017, 09:10

If you want to assign a user name that is different from what the user sends at login time you can use this:
http://docs2x.smartfoxserver.com/Gettin ... wtos#item3

See point #4 -> "Change the user name at login time"

hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 18 guests