onSpectatorSwitched()

Availability:

SmartFoxServer Basic / Pro

Usage:

smartFox.onSpectatorSwitched(success <true/false>, newId <integer>, roomObj <propList>)

Description:

The event is fired in response to a switchSpectator() request. The request to turn a spectator into a player may fail if another user did the same before your request and there was only one player slot available.
All spectators have their playerId property set to -1 when you become a player your playerId will get a number > 0, representing the player number.
For example in a game room for 3 players your Id can be any number between 1,2,3. These values are assigned by the server, based on the order in which the players joined.

Parameters:

success   True if the spectator user was turned into a player in a game room, otherwise will return False
newId   The playerId assigned by the server
roomObj   The propertylist representing the room where the switch occurred

Check the Room Properties for more info on the objects returned.

Returns:

nothing

Example:

on onSpectatorSwitched me, success, newId, roomObj
	if (success) then put("Great! Now I am player #" & newId)
	else put("The attempt to switch as a player failed.")
end

See also: