Hello, It's me again haha
Is it possible to do something like: u.getId(u.getName(!=Player))
Meanning select everyone except someone with that name?
Thanks again!
u.getName
-
- Posts: 30
- Joined: 25 Aug 2016, 02:52
-
- Posts: 30
- Joined: 25 Aug 2016, 02:52
Re: u.getName
Is there an other way I can do this?
Re: u.getName
In a for loop, run through all the players in the room and just keep the one you don't need.
(unfortunately you are using SFS Pro; in 2X we introduced the Match Expressions: http://docs2x.smartfoxserver.com/Advanc ... s/game-api)
(unfortunately you are using SFS Pro; in 2X we introduced the Match Expressions: http://docs2x.smartfoxserver.com/Advanc ... s/game-api)
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
-
- Posts: 30
- Joined: 25 Aug 2016, 02:52
Re: u.getName
Bax wrote:In a for loop, run through all the players in the room and just keep the one you don't need.
(unfortunately you are using SFS Pro; in 2X we introduced the Match Expressions: http://docs2x.smartfoxserver.com/Advanc ... s/game-api)
I am using a for loop, but how can I make it run on everybody except from one player // more than one player.
Re: u.getName
Loop on the users list, checking their name or some other property.
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
-
- Posts: 30
- Joined: 25 Aug 2016, 02:52
Re: u.getName
How can I do that?
Re: u.getName
Is this server side or client side? What programming language?
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
-
- Posts: 30
- Joined: 25 Aug 2016, 02:52
Re: u.getName
Client side AS3 (Class File)
Re: u.getName
This is an example showing how to iterate over users after joining a Room, putting them in a separate list which can be used for whatever purpose (for example show them in a list of users in the game's interface).
The example is taken from the SmartFoxChat demo application available in the SmartFoxServer Pro package. We strongly recommend that you take inspiration from the provided demos.
The example is taken from the SmartFoxChat demo application available in the SmartFoxServer Pro package. We strongly recommend that you take inspiration from the provided demos.
Code: Select all
public function onJoinRoom(evt:SFSEvent):void
{
var room:Room = evt.params.room as Room
var provider:ArrayCollection = new ArrayCollection()
// Cycle through all users in the list and add them to the provider
for each(var u:User in room.getUserList())
{
// Exclude myself
if (u.getName() != sfsClient.myUserName)
provider.addItem( {label:u.getName(), data:u.getId()} )
}
...
}
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
-
- Posts: 30
- Joined: 25 Aug 2016, 02:52
Re: u.getName
It works! haha awesome man thanks
Return to “SmartFoxServer 1.x Discussions and Help”
Who is online
Users browsing this forum: No registered users and 83 guests