SetElementData: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
{{Server client function}}
{{Server client function}}
__NOTOC__  
__NOTOC__  
This function stores [[element data]] under a certain key, attached to an element. Element data set using this is then synced with all clients or the server (depending if used client-side or not). As such you should avoid passing data that is not able to be synced into this function (i.e. xmlnodes, acls, aclgroups etc.) Server-created elements are able to be synced.
This function stores [[element data]] under a certain key, attached to an element. Element data set using this is then synced with all clients or the server. As such you should avoid passing data that is not able to be synced into this function (i.e. xmlnodes, acls, aclgroups etc.) Server-created elements are able to be synced.


==Syntax==  
==Syntax==  
<section name="Client" class="client" show="true">
 
<section name="Server and Client" class="both" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setElementData ( element theElement, string key, [bool synchronize], var value )
bool setElementData ( element theElement, string key, [bool synchronize], var value )
</syntaxhighlight>  
</syntaxhighlight>  
</section>  
</section>  
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">
bool setElementData ( element theElement, string key, var value )
</syntaxhighlight>
</section>


===Required Arguments===  
===Required Arguments===  

Revision as of 00:40, 24 July 2009

This function stores element data under a certain key, attached to an element. Element data set using this is then synced with all clients or the server. As such you should avoid passing data that is not able to be synced into this function (i.e. xmlnodes, acls, aclgroups etc.) Server-created elements are able to be synced.

Syntax

Click to collapse [-]
Server and Client
bool setElementData ( element theElement, string key, [bool synchronize], var value )

Required Arguments

  • theElement: The element you wish to attach the data to.
  • key: The key you wish to store the data under.
  • value: The value you wish to store. See element data for a list of acceptable datatypes.

Optional Arguments

  • synchronize: Determines whether or not the data will be synchronized with the server and remote clients.

Returns

Returns true if the data was set succesfully, false otherwise.

Example

Click to expand [+]
Server

See Also