OnElementModelChange: Difference between revisions
Jump to navigation
Jump to search
ThePiotrek (talk | contribs) m (I think 1.2 is no longer the new version.) |
No edit summary |
||
(6 intermediate revisions by 4 users not shown) | |||
Line 5: | Line 5: | ||
==Parameters== | ==Parameters== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
int oldModel | int oldModel, int newModel | ||
</syntaxhighlight> | </syntaxhighlight> | ||
* '''oldModel:''' | * '''oldModel:''' an [[int]] representing the model of the [[element]] before the change occurred. | ||
* '''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 | ==Cancel effect== | ||
This event | This event does NOT support [[Event system#Canceling|cancellation]]. Use [[setElementModel]] with the old value to reverse. | ||
==Example== | ==Example== | ||
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, 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: ".. | outputChatBox("Model ID changing from: "..oldModel.." to: ".. newModel, source, 0, 255, 0) -- Message for player | ||
end | end | ||
end | end | ||
Line 27: | Line 28: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{See also/Server event|Element events}} | |||
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
- onElementClicked
- onElementColShapeHit
- onElementColShapeLeave
- onElementDataChange
- onElementDestroy
- onElementDimensionChange
- onElementInteriorChange
- onElementModelChange
- onElementStartSync
- onElementStopSync
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled