OnClientElementDataChange: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 3: Line 3:
This event is triggered whenever an element's ''[[element data]]'' is changed.
This event is triggered whenever an element's ''[[element data]]'' is changed.


==Syntax==  
==Parameters==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
void onClientElementDataChange ( string name )
string dataName
</syntaxhighlight>  
</syntaxhighlight>  
*'''dataName''': A string representing the element data that was changed
==Source==
The [[event system#Event source|source]] of this event is the [[element]] that had its element data changed


==Example==  
==Example==  
This example tells the client whenever a HOT AIR "class" element data is changed.
This example tells the client whenever a player's "score" element data is changed.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addEventHandler ( "onClientElementDataChange", getRootElement(),
addEventHandler ( "onClientElementDataChange", getRootElement(),
function ( dataName )
function ( dataName )
if getElementType ( source ) == "player" and dataName == "class" then
if getElementType ( source ) == "player" and dataName == "score" then
outputChatBox ( getPlayerName(source).." changed his class to "..getElementData ( source, "class" )
outputChatBox ( getPlayerName(source).."'s new score is "..getElementData ( source, "score".."!" )
end
end
end )
end )
</syntaxhighlight>
</syntaxhighlight>

Revision as of 13:09, 22 October 2007

This event is triggered whenever an element's element data is changed.

Parameters

string dataName
  • dataName: A string representing the element data that was changed

Source

The source of this event is the element that had its element data changed

Example

This example tells the client whenever a player's "score" element data is changed.

addEventHandler ( "onClientElementDataChange", getRootElement(),
function ( dataName )
	if getElementType ( source ) == "player" and dataName == "score" then
		outputChatBox ( getPlayerName(source).."'s new score is "..getElementData ( source, "score".."!" )
	end
end )