onElementModelChange | Multi Theft Auto: Wiki Skip to content

onElementModelChange

Client-side
Server-side
Shared

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

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

Canceling

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

Code Examples

server

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 Functions