OnElementModelChange: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 8: | Line 8: | ||
==Parameters== | ==Parameters== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
int oldModel | int oldModel | ||
</syntaxhighlight> | </syntaxhighlight> | ||
* '''oldModel:''' The model of the element beforehand. | * '''oldModel:''' The model of the element beforehand. | ||
==Source== | ==Source== | ||
Line 23: | Line 22: | ||
This example sends a message to players when their model changes telling them what the model ID is and was. | This example sends a message to players when their model changes telling them what the model ID is and was. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function informPlayerOnModelChange(oldModel | function informPlayerOnModelChange(oldModel) | ||
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: ".. | outputChatBox("Model ID changing from: "..oldModel.." to: "..getElementModel(source), source, 0, 255, 0) -- Message for player | ||
end | end | ||
end | end |
Revision as of 03:57, 23 August 2015
Available only in MTA SA 1.2 and onwards This event is triggered when the model of an element is changed using setElementModel.
Parameters
int oldModel
- oldModel: The model of the element beforehand.
Source
The source of this event is the element that changed its model
Cancel Effect
This event doesn't 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) if ( getElementType(source) == "player" ) then -- Make sure the element is a player outputChatBox("Model ID changing from: "..oldModel.." to: "..getElementModel(source), source, 0, 255, 0) -- Message for player end end addEventHandler("onElementModelChange", root, informPlayerOnModelChange) -- Bind the event to every element
See Also
Element events
- onElementClicked
- onElementColShapeHit
- onElementColShapeLeave
- onElementDataChange
- onElementDestroy
- onElementDimensionChange
- onElementInteriorChange
- onElementModelChange
- onElementStartSync
- onElementStopSync
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled