Scripting/Server/Classes/Element_data_v0_5_3/SetElementData
Stores value under key (a string of 1-63 characters). value may be null, a bool, an integer, a float or a string (up to 4000 characters); setting null removes the key. With sync = true (the default) every client gets the value at once and players who join later get it too, before onPlayerJoin. With sync = false the value stays on the server (passwords, internal state); a key that was synced before is then removed on the clients. Arrays, tables and class instances throw an error - store an id or a string instead. 512 keys per entity at most.
Syntax
entity.SetElementData(key, value [, sync = true])Arguments
- string key – Stores
valueunderkey(a string of 1-63 characters). - bool value – Stores
valueunderkey(a string of 1-63 characters). - any sync = true (optional) – With
sync = true(the default) every client gets the value at once and players who join later get it too, before onPlayerJoin.
Returns
true
Example
function onPlayerCommand( player, cmd, params )
{
if ( cmd == "setelementdata" )
{
// entity is a entity handle (see Element data (v0.5.3+))
local result = entity.SetElementData( "X", true );
MessagePlayer( "entity.SetElementData returned: " + result, player );
}
}This sample was generated from the signature – adapt the values to your gamemode.
Related pages
Section: Element data (v0.5.3+)
Categories: Server methods | Element data (v0.5.3+)