OnElementDimensionChange: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server event}}
{{Server event}}
{{New feature/item|3.0160|1.5.8|20724|This event is triggered when the dimension of an [[element]] is changed using [[setElementDimension]].}}
{{Added feature/item|1.5.9|1.5.8|20724|This event is triggered when the dimension of an [[element]] is changed using [[setElementDimension]].}}


==Parameters==
==Parameters==
Line 7: Line 7:
int oldDimension, int newDimension
int oldDimension, int newDimension
</syntaxhighlight>
</syntaxhighlight>
*'''oldDimension''': an [[int]] representing the dimension the [[element]] was in before.
*'''oldDimension''': An [[int]] representing the dimension the [[element]] was in before.
*'''newDimension''': an [[int]] representing the dimension the [[element]] is in now.
*'''newDimension''': An [[int]] representing the dimension the [[element]] is in now.


==Source==
==Source==
Line 14: Line 14:


==Example==
==Example==
This example prints the old and the new dimension of a vehicle
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
local vehicle = createVehicle ( 411, 0, 0, 3 )
local vehicle = createVehicle (411, 0, 0, 3) -- create a vehicle
setTimer ( setElementDimension, 1000, 1, vehicle, 10 )
setTimer (setElementDimension, 1000, 1, vehicle, 10) -- set a new dimension to the vehicle after 1 second


addEventHandler ( "onElementDimensionChange", vehicle,
-- add an event handler to onElementDimensionChange attached to the vehicle
function ( oldDimension, newDimension )
addEventHandler ("onElementDimensionChange", vehicle,
outputChatBox ( inspect ( source ) .. "'s dimension changed from " .. oldDimension .. " to " .. newDimension )
function (oldDimension, newDimension)
-- print the old and the new vehicle's dimension
outputChatBox (inspect (source) .. "'s dimension changed from " .. oldDimension .. " to " .. newDimension)
end
end
)
)

Latest revision as of 14:32, 31 December 2022

This event is triggered when the dimension of an element is changed using setElementDimension.

Parameters

int oldDimension, int newDimension
  • oldDimension: An int representing the dimension the element was in before.
  • newDimension: An int representing the dimension the element is in now.

Source

The source of this event is the element that changed its dimension.

Example

This example prints the old and the new dimension of a vehicle

local vehicle = createVehicle (411, 0, 0, 3) -- create a vehicle
setTimer (setElementDimension, 1000, 1, vehicle, 10) -- set a new dimension to the vehicle after 1 second

-- add an event handler to onElementDimensionChange attached to the vehicle
addEventHandler ("onElementDimensionChange", vehicle,
	function (oldDimension, newDimension)
		 -- print the old and the new vehicle's dimension
		outputChatBox (inspect (source) .. "'s dimension changed from " .. oldDimension .. " to " .. newDimension)
	end
)

Requirements

Minimum server version 1.5.8-9.20724
Minimum client version n/a

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version server="1.5.8-9.20724" />

See Also

Element events


Event functions

Shared