User
| Kind of class: | public class |
|---|---|
| Package: | it.gotoandplay.smartfoxserver.data |
| Inherits from: | none |
| Version: | 1.0.0 |
| Author: | The gotoAndPlay() Team http://www.smartfoxserver.com http://www.gotoandplay.it |
| Classpath: | it.gotoandplay.smartfoxserver.data.User |
| File last modified: | Monday, 10 December 2007, 16:16:30 |
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 : int
- Get the id of the user.
- getName : String
- Get the name of the user.
- getVariable (varName:String) : *
- Retrieve a User Variable.
- getVariables : Array
- 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 : int
- Retrieve the player id of the user.
Instance methods
getId
public function getId (
) : int
Get the id of the user.
Returns:
- The user id.
Example:
-
trace("User id:" + user.getId())
See also:
Version:
- SmartFoxServer Basic / Pro
getName
public function getName (
) : String
Get the name of the user.
Returns:
- The user name.
Example:
-
trace("User name:" + user.getName())
See also:
Version:
- SmartFoxServer Basic / Pro
getPlayerId
public function getPlayerId (
) : int
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 Basic / Pro
getVariable
public 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:int = room.getVariable("age") as int
See also:
Version:
- SmartFoxServer Basic / Pro
getVariables
public function getVariables (
) : Array
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 Basic / Pro
isModerator
public 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
public 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