Internal Event :: spectatorSwitched

Availability:

SmartFoxServer PRO 1.2.1

Event name:

spectatorSwitched

Description:

This event is fired when a user set as spectator in a game room is turned into a player. The event is available only for both Zone Level and Room Level extensions. The switch is usually requested from the client side using the switchSpectator() request. When the user is finally transformed from spectator into a player the event is fired, so that any extension can handle it accordingly.

Properties:

name   description type
user   The User (object) that was turned into a player object
playerIndex   The new player index assigned by the server java.lang.String (*)

(*) A note on data types: the parameters passed by the server events to the running extensions are all Java types.
You can use them transparently in Actionscript or cast them to AS native data types.
» javadoc for -> java.lang.String

Example:

function handleInternalEvent(evtObj)
{
	if (evt.name == "spectatorSwitched")
	{
		var newId = evt.playerIndex
		var user = evt.user
		
		// add the user to the local list of players
		players[user.getUserId()] = user

	}
}

See also: