Syntax: new TServerPlayer("account")


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.


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() { = new TServerPlayer("account");
  temp.hat =[2];;

… 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. If the memory continues to leak in this fashion, it will cause significant problems (i.e. slowness, or even total failure) not just for your GServer/NPC-Server, but also for other servers on the same machine. In short, don't be caught causing problems just because you forgot to destroy your TServerPlayer.



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

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