Click or drag to resize

UserPlayerId Property

Returns the id of this user as a player in a Game Room.

Namespace:  Sfs2X.Entities
Assembly:  SmartFox2X (in SmartFox2X.dll) Version: 1.8.0.0 (1.8.0)
Syntax
C#
int PlayerId { get; }

Property Value

Type: Int32
Remarks
This property differs from Id property and it used to indicate which player number is assigned to a user inside a Game Room. For example, in a Game Room for 5 players the first client joining it will have its playerId equal to 1, the second will have it equal to 2 and so forth. When a user leaves the Room the player slot is freed up and the next user joining the Room will take it.

This property applies to Game Rooms only; in standard Rooms it is always 0. Also, in Game Rooms a playerId value lower than 0 indicates that the user is a spectator.

If the user is inside multiple Game Rooms at the same time, a different playerId value will be assigned to him in each Room. In this case this property returns the value corresponding to the last joined Room; in order to obtain the playerId value in a specific Room, use the GetPlayerId(Room) method.

See Also