OnElementModelChange: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{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 ...")
 
No edit summary
 
(10 intermediate revisions by 8 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server event}}
{{Server event}}
{{New feature|3.0120|1.2|
This event is triggered when the model of an [[element]] is changed using [[setElementModel]].
'''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==
==Parameters==
Line 11: Line 8:
</syntaxhighlight>  
</syntaxhighlight>  


* '''oldModel:''' The model that the element had before the change
* '''oldModel:''' an [[int]] representing the model of the [[element]] before the change occurred.
* '''newModel:''' The model that the element has changed to
* '''newModel:''' an [[int]] representing the new model of the [[element]].


==Source==
==Source==
The source of this event is the element that changed its model
The [[event system#Event source|source]] of this event is the [[element]] that changed its model


==Cancel Effect==
==Cancel effect==
This event doesn't support cancellation.
This event does NOT support [[Event system#Canceling|cancellation]]. Use [[setElementModel]] with the old value to reverse.


==Example==  
==Example==  
Line 25: Line 22:
function informPlayerOnModelChange(oldModel, newModel)
function informPlayerOnModelChange(oldModel, newModel)
     if ( getElementType(source) == "player" ) then -- Make sure the element is a player
     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
         outputChatBox("Model ID changing from: "..oldModel.." to: ".. newModel, source, 0, 255, 0) -- Message for player
     end
     end
end
end
Line 31: Line 28:
</syntaxhighlight>
</syntaxhighlight>


==See Also==
{{See also/Server event|Element events}}
===Element events===
{{Element_events}}
===Event functions===
{{Event_functions}}

Latest revision as of 20:36, 7 November 2019

This event is triggered when the model of an element is changed using setElementModel.

Parameters

int oldModel, int newModel
  • oldModel: an int representing the model of the element before the change occurred.
  • newModel: an int representing the new model of the element.

Source

The source of this event is the element that changed its model

Cancel effect

This event does NOT support cancellation. Use setElementModel with the old value to reverse.

Example

This example sends a message to players when their model changes telling them what the model ID is and was.

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("onElementModelChange", root, informPlayerOnModelChange) -- Bind the event to every element

See Also

Element events


Event functions