OnElementModelChanged: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Redirected page to OnElementModelChange)
 
Line 1: Line 1:
__NOTOC__
#REDIRECT [[onElementModelChange]]
{{Server event}}
{{New feature|3.0120|1.2|
'''Available only in MTA SA 1.2 and onwards'''
}}
This event is triggered when an element (ped, object or vehicle) has their model changed.
 
==Parameters==
<syntaxhighlight lang="lua">
int oldModel, int newModel
</syntaxhighlight>
 
* '''oldModel:''' The model that the element had before the change
* '''newModel:''' The model that the element has changed to
 
==Source==
The source of this event is the element that changed its model
 
==Cancel Effect==
This event doesn't support cancellation.
 
==Example==
This example sends a message to players when their model changes telling them what the model ID is and was.
<syntaxhighlight lang="lua">
function informPlayerOnModelChange(oldModel, newModel)
    if ( getElementType(source) == "player" ) then -- Make sure the element is a player
        outputChatBox("Model ID changing from: "..oldModel.." to: "..newModel, source, 0, 255, 0) -- Message for player
    end
end
addEventHandler("onElementModelChanged", root, informPlayerOnModelChange) -- Bind the event to every element
</syntaxhighlight>
 
==See Also==
===Element events===
{{Element_events}}
===Event functions===
{{Event_functions}}

Latest revision as of 11:02, 23 December 2011