Revision [833]
Last edited on 2010-09-19 18:33:26 by AdminSkyld [Felt the warning needed improving some more]Additions:
**{{color fg="red" text="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##.
Deletions:
Additions:
##TServerPlayer## is the class, derived from ##[[TGaniObject]]##, from which [[TServerNPC NPCs]] (including GUI scripts) as well as [[TPlayer 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:
… 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.
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:
… 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.
Deletions:
Construction of a stand-alone TServerPlayer object is impossible, but the properties of an offline player can be loaded this way.
**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.
Additions:
**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.
Additions:
temp.pl = new TServerPlayer("account");
temp.pl.destroy();
temp.pl.destroy();
Deletions:
temp.pl.destroy();
Additions:
temp.pl = new TServerPkayer("account");
Deletions:
Additions:
Syntax: ##new TServerPlayer("account")##
TServerPlayer is the class, derived from [[TGaniObject]], from which [[TServerNPC NPCs]] (including GUI scripts) as well as [[TPlayer players]] (i.e., your character) are created.
Construction of a stand-alone TServerPlayer object is impossible, but the properties of an offline player can be loaded this way.
%%function onCreated() {
temp.pl = new TServerPkayer("account ");
temp.hat = temp.pl.attr[2];
temp.pl.destroy();
}%%
TServerPlayer is the class, derived from [[TGaniObject]], from which [[TServerNPC NPCs]] (including GUI scripts) as well as [[TPlayer players]] (i.e., your character) are created.
Construction of a stand-alone TServerPlayer object is impossible, but the properties of an offline player can be loaded this way.
%%function onCreated() {
temp.pl = new TServerPkayer("account ");
temp.hat = temp.pl.attr[2];
temp.pl.destroy();
}%%
Deletions:
TServerPlayer is the class, derived from [[TGaniObject]], from which [[TServerNPC NPCs]] (including GUI scripts) as well as [[TPlayer players]] (i.e., your character) are created. Note, that creation of a TServerPlayer is done internally, and so the construct shown above does not actually work (or should not, if it does).
Construction of a stand-alone TServerPlayer object is impossible. However, some properties are inherited from this class (e.g., [[chat]]).
Additions:
TServerPlayer is the class, derived from [[TGaniObject]], from which [[TServerNPC NPCs]] (including GUI scripts) as well as [[TPlayer players]] (i.e., your character) are created. Note, that creation of a TServerPlayer is done internally, and so the construct shown above does not actually work (or should not, if it does).