getElementDimension | Multi Theft Auto: Wiki Skip to content

getElementDimension

Client-side
Server-side
Shared

Pair: setElementDimension

Manual Review Required

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


This function allows you to retrieve the dimension of an element. See Dimension for the list of valid element types. The dimension determines what/who the element is visible to.

OOP Syntax Help! I don't understand this!

  • Method:element:getDimension(...)
  • Variable: .dimension

Syntax

int getElementDimension ( element theElement )
Required Arguments
  • theElement: The element in which you'd like to retrieve the dimension of.

Returns

  • int: value

Returns an integer for the dimension if theElement is valid, false otherwise.

Code Examples

shared
function onPlayerEnterVehicle ( theVehicle, seat, jacked )
if ( getElementDimension ( source ) == 0 and seat == 0 ) then -- if the player is in dimension 0 and is entering the driver seat
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 and seat == 0 ) then -- if the player is in dimension 1 and was in the driver's seat
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