player index on onUserEnterRoom

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

alikapadia
Posts: 5
Joined: 15 May 2006, 18:14

player index on onUserEnterRoom

Postby alikapadia » 15 May 2006, 18:19

hi,

is there a way to recieve the index assigned to a user in the: smartFox.onUserEnterRoom() event, so that when a user joins a room, all the users present in the room get the index of the player assigned by the server. Actually i want to use this index for placing a player in my interface when he joins.
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 16 May 2006, 06:54

Code: Select all

smartFox.onUserEnterRoom = function(roomId:Number, userObj:Object)
{
        trace("ID: " + userObj.getId())
}


:)
Lapo
--
gotoAndPlay()
...addicted to flash games
alikapadia
Posts: 5
Joined: 15 May 2006, 18:14

Postby alikapadia » 16 May 2006, 09:37

oh, i though tthat gave the user id and not player index :) , i just tried it, its returning me the userId, so like my user Id was 3 and i was the first player in my game room, then the second player to enter the room, when i getId() it, i get 4.. which is the user Id, i need the player id / player index (1,2,3... in a particular game room)
Last edited by alikapadia on 16 May 2006, 09:43, edited 1 time in total.
User avatar
Virusescu
Posts: 260
Joined: 07 Sep 2005, 09:36
Location: [RO]Bucharest
Contact:

Postby Virusescu » 16 May 2006, 09:38

What do you understand by userId and what do you understand by userIndex?
function onJoin(usr) {if (usr.getName() == "Lapo") trace ("All Hail Lapo");}
alikapadia
Posts: 5
Joined: 15 May 2006, 18:14

Postby alikapadia » 16 May 2006, 10:01

userId increments based on users connecting to smartfox, player index starts from 1 when a user joins a room and is the first player, and for the next entering player, the value increments by 1 regardless of user id. the feature that makes it ideal for me is that it fills up empty spaces between the indexes like in 3 users, player 2 exits, the next entering player is not assigned 3 but 2
User avatar
Virusescu
Posts: 260
Joined: 07 Sep 2005, 09:36
Location: [RO]Bucharest
Contact:

Postby Virusescu » 16 May 2006, 10:13

Ok, I see.
The userId is a unique identifier asigned by the server to each client that connects.
You need to manage yourself the clients connecting to a room. Just push them into an array...
function onJoin(usr) {if (usr.getName() == "Lapo") trace ("All Hail Lapo");}

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 49 guests