RemoveElementData: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
Line 16: Line 16:


==Example==  
==Example==  
<section class="server" name="Example" show="true">
This will create an element data for know if a player has spawned.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--TODO
function spawn()
</syntaxhighlight>
    setElementData(source,"spawned",true)
end
addEventHandler ( "onPlayerSpawn", getRootElement(), spawn )
function wasted()
    removeElementData(source,"spawned")
end
addEventHandler ( "onPlayerWasted", getRootElement(), wasted )</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Element_functions}}
{{Element_functions}}
[[Category:Needs Example]]
[[Category:Needs Example]]

Revision as of 15:13, 14 January 2011

This function removes the element data with the given key for that element. The element data removal is synced with all the clients.

Syntax

bool removeElementData ( element theElement, string key ) 

Required Arguments

  • theElement: The element you wish to remove the data from.
  • key: The key string you wish to remove.

Returns

Returns true if the data was removed succesfully, false if the given key does not exist in the element or the element is invalid.

Example

Click to collapse [-]
Example

This will create an element data for know if a player has spawned.

function spawn()
    setElementData(source,"spawned",true)
end
addEventHandler ( "onPlayerSpawn", getRootElement(), spawn )
function wasted()
    removeElementData(source,"spawned")
end
addEventHandler ( "onPlayerWasted", getRootElement(), wasted )

See Also