Revision [832]

This is an old revision of TServerPlayer made by AdminSkyld on 2010-09-19 18:28:34.
 
Usage

Syntax: new TServerPlayer("account")

Explanation

TServerPlayer is the class, derived from TGaniObject, from which NPCs (including GUI scripts) as well as players (i.e. your character) are created. Objects of this type typically contain attributes regarding the player, such as their attributes (health, gralats), images (head, body) and colours, and also client/clientr flags.

Example

Typically, TServerPlayer objects are created automatically by the NPC-Server when a player logs onto the server. These objects can be returned either by finding an object in the players/allplayers arrays, or by using findplayer/findplayerbycommunityname.

Also, the player object usually refers to the TServerPlayer object of the current player. You cannot create new fake players by creating new TServerPlayer objects, however, you can create new TServerPlayer objects in order to access the saved attributes of a player who is currently offline, for example:

function onCreated() {
  temp.pl = new TServerPlayer("account");
  temp.hat = temp.pl.attr[2];
  temp.pl.destroy();
}

… will load the attributes of player with account name "account", and then set the hat image before destroying the TServerPlayer object again. This functionality is only available serverside.

VERY IMPORTANT WARNING: When creating TServerPlayer objects to read offline attributes, you MUST destroy the TServerPlayer object when you are finished with it because it will not be deleted automatically by the garbage collector. If you do not destroy the objects, it will result in a memory leak and then bad things will happen.

Categories

CategoryClassObject

There is one comment on this page. [Display comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki