User
| Kind of class: | class |
|---|---|
| Inherits from: | none |
| Version: | 2.6.0 |
| Author: | The gotoAndPlay() Team http://www.smartfoxserver.com http://www.gotoandplay.it |
| Classpath: | it.gotoandplay.smartfoxserver.User |
| File last modified: | Wednesday, 30 July 2008, 10:20:25 |
The User class stores the properties of each user.
This class is used internally by the SmartFoxClient class; also, User objects are returned by various methods and events of the SmartFoxServer API.
NOTE: in the provided examples,
This class is used internally by the SmartFoxClient class; also, User objects are returned by various methods and events of the SmartFoxServer API.
NOTE: in the provided examples,
user always indicates a User instance.Summary
Instance methods
- getId : Number
- Get the id of the user.
- getName : String
- Get the name of the user.
- getVariable (varName:String)
- Retrieve a User Variable.
- getVariables : Object
- Retrieve the list of all User Variables.
- isSpectator : Boolean
- A boolean flag indicating if the user is a spectator in the current room.
- isModerator : Boolean
- A boolean flag indicating if the user is a Moderator in the current zone.
- getPlayerId : Number
- Retrieve the player id of the user.
Instance methods
getId
function getId (
) : Number
Get the id of the user.
Returns:
- The user id.
Example:
-
trace("User id:" + user.getId())
See also:
Version:
- SmartFoxServer Lite / Basic / Pro
getName
function getName (
) : String
Get the name of the user.
Returns:
- The user name.
Example:
-
trace("User name:" + user.getName())
See also:
Version:
- SmartFoxServer Lite / Basic / Pro
getPlayerId
function getPlayerId (
) : Number
Retrieve the player id of the user.
The user must be a player inside a game room for this method to work properly.
This id is 1-based (player 1, player 2, etc.), but if the user is a spectator its value is -1.
The user must be a player inside a game room for this method to work properly.
This id is 1-based (player 1, player 2, etc.), but if the user is a spectator its value is -1.
Returns:
- The current player id.
Example:
-
trace("The user's player id is " + user.getPlayerId())
Version:
- SmartFoxServer Lite / Basic / Pro
getVariable
function getVariable (
varName:String)
Retrieve a User Variable.
Parameters:
varName:
the name of the variable to retrieve.
Returns:
- The User Variable's value.
Example:
-
var age:Number = room.getVariable("age")
See also:
Version:
- SmartFoxServer Lite / Basic / Pro
getVariables
function getVariables (
) : Object
Retrieve the list of all User Variables.
Returns:
- An associative array containing User Variables' values, where the key is the variable name.
Example:
-
var userVars:Array = user.getVariables() for (var v:String in userVars) trace("Name:" + v + " | Value:" + userVars[v])
See also:
Version:
- SmartFoxServer Lite / Basic / Pro
isModerator
function isModerator (
) : Boolean
A boolean flag indicating if the user is a Moderator in the current zone.
Returns:
-
trueif the user is a Moderator.
Example:
-
if (user.isModerator) trace("The user is a Moderator")
Version:
- SmartFoxServer Basic / Pro
isSpectator
function isSpectator (
) : Boolean
A boolean flag indicating if the user is a spectator in the current room.
Returns:
-
trueif the user is a spectator.
Example:
-
if (user.isSpectator) trace("The user is a spectator")
Version:
- SmartFoxServer Basic / Pro