Turn a player inside a game room into a spectator.
All players have their player id property set to a value > 0; when a spectator becomes a player, his playerId is set to -1.
If the user joined more than one room, the id of the room where the switch should occurr must be passed to this method.
The switch operation is successful only if at least one spectator slot is available in the room.
All players have their player id property set to a value > 0; when a spectator becomes a player, his playerId is set to -1.
If the user joined more than one room, the id of the room where the switch should occurr must be passed to this method.
The switch operation is successful only if at least one spectator slot is available in the room.


- roomId (Int32)
- the id of the room where the player should be switched to spectator, in case of multi-room join (optional, default value: activeRoomId).

Sends:
SFSEvent..::.OnPlayerSwitchedDelegate
Version:
SmartFoxServer Pro

The following example shows how to turn a player into a spectator.
CopyC#

SFSEvent.onPlayerSwitched += OnPlayerSwitched; smartFox.SwitchPlayer(); public void OnPlayerSwitched(bool success, int newId, Room room) { if (success) Debug.WriteLine("You have been turned into a spectator; your id is " + newId); else Debug.WriteLine("The attempt to switch from player to spectator failed!"); }