setElementDimension | Multi Theft Auto: Wiki Skip to content

setElementDimension

Client-side
Server-side
Shared

Pair: getElementDimension

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function allows you to set the dimension of an element. See Dimension for the in-depth explanation and the list of valid element types.

Syntax

setElementDimension ( )

Code Examples

server

In this example the player's dimension is set to ID 1 when they enter a vehicle, and set back to dimension 0 when they exit the vehicle.

function onPlayerEnterVehicle ( theVehicle, seat, jacked )
if ( getElementDimension ( source ) == 0 ) then -- if the player is in dimension 0
setElementDimension ( source, 1 ) -- set his dimension to 1
setElementDimension ( theVehicle, 1 ) -- set his vehicle's dimension to 1 as well
end
end
addEventHandler ( "onPlayerVehicleEnter", root, onPlayerEnterVehicle )
function onPlayerExitVehicle ( theVehicle, seat, jacker )
if ( getElementDimension ( source ) == 1 ) then -- if the player is in dimension 1
setElementDimension ( source, 0 ) -- set his dimension back to 0
setElementDimension ( theVehicle, 0 ) -- set his vehicle's dimension back to 0 as well
end
end
addEventHandler ( "onPlayerVehicleExit", root, onPlayerExitVehicle )

See Also

Element Functions