SmartFoxServer Silverlight API
playerId Field
Namespaces ► SmartFoxClientAPI ► SmartFoxClient ► playerId
The current user's id as a player in a game room.
The playerId is available only after the user successfully joined a game room. This id is 1-based (player 1, player 2, etc.), but if the user is a spectator or the room is not a game room, its value is -1.
When a user joins a game room, a player id (or "slot") is assigned to him/her, based on the slots available in the room at the moment in which the user entered it; for example:

- in a game room for 2 players, the first user who joins it becomes player one (playerId = 1) and the second user becomes player two (player = 2);
- in a game room for 4 players where only player three is missing, the next user who will join the room will be player three (playerId = 3);

Declaration Syntax

C# | Visual Basic | Visual C++

    public int playerId

    Public playerId As Integer

    public:
    int playerId

Remarks

NOTE:
if multi-room join is allowed, this property contains only the last player id assigned to the user, and so it's useless. In this case the GetMyPlayerIndex()()() method should be used to retrieve the player id for each joined room.

Version:
SmartFoxServer Basic / Pro

Examples
The following example shows how to retrieve the user's own player id.
CopyC#

    Debug.WriteLine("I'm player " + smartFox.playerId);

See Also
GetMyPlayerIndex()()()
IsGame()()()

Assembly: SmartFoxClientAPI_Silverlight (Module: SmartFoxClientAPI_Silverlight) Version: 1.0.0.0 (1.0.0.0)