GetElementDimension: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Fernando187 (talk | contribs) m (add link to Dimension) |
||
(10 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
This function allows you to retrieve the dimension of | {{Server client function}} | ||
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. | |||
==Syntax== | ==Syntax== | ||
Line 6: | Line 7: | ||
int getElementDimension ( element theElement ) | int getElementDimension ( element theElement ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[element]]:getDimension|dimension|setElementDimension}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
Line 11: | Line 13: | ||
===Returns=== | ===Returns=== | ||
Returns an integer for the dimension if 'theElement' is valid, 'false' otherwise. | Returns an integer for the dimension if '''theElement''' is valid, ''false'' otherwise. | ||
==Example== | ==Example== | ||
This example puts all vehicles with drivers in dimension 1, while all other vehicles are in dimension 0. This would have the effect of making on-foot players invisible to drivers, and vice versa. It'd also make entering a vehicle as passenger after the driver has entered impossible, as the vehicle would appear to vanish to any on foot players. | |||
<section show="true" name="Server" class="server"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function onPlayerEnterVehicle ( theVehicle, seat, jacked ) | 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 | end | ||
addEventHandler ( "onPlayerVehicleEnter", root, onPlayerEnterVehicle ) | |||
function onPlayerExitVehicle ( theVehicle, seat, jacker ) | 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 | end | ||
addEventHandler ( "onPlayerVehicleExit", root, onPlayerExitVehicle ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{Element functions}} | {{Element functions}} |
Latest revision as of 09:51, 14 October 2024
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.
Syntax
int getElementDimension ( element theElement )
OOP Syntax Help! I don't understand this!
- Method: element:getDimension(...)
- Variable: .dimension
- Counterpart: setElementDimension
Required Arguments
- theElement: The element in which you'd like to retrieve the dimension of.
Returns
Returns an integer for the dimension if theElement is valid, false otherwise.
Example
This example puts all vehicles with drivers in dimension 1, while all other vehicles are in dimension 0. This would have the effect of making on-foot players invisible to drivers, and vice versa. It'd also make entering a vehicle as passenger after the driver has entered impossible, as the vehicle would appear to vanish to any on foot players.
Click to collapse [-]
Serverfunction 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
- attachElements
- createElement
- destroyElement
- detachElements
- getAttachedElements
- getElementAlpha
- getElementAttachedOffsets
- getElementAttachedTo
- getElementByIndex
- getElementByID
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementCollisionsEnabled
- getElementColShape
- getElementData
- getAllElementData
- hasElementData
- getElementDimension
- getElementHealth
- getElementID
- getElementInterior
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRotation
- getElementsByType
- getElementsWithinColShape
- getElementsWithinRange
- getElementType
- getElementVelocity
- getLowLODElement
- getRootElement
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLowLOD
- isElementWithinColShape
- isElementWithinMarker
- setElementAlpha
- setElementAngularVelocity
- getElementAngularVelocity
- setElementAttachedOffsets
- setElementCallPropagationEnabled
- setElementCollisionsEnabled
- setElementData
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementModel
- setElementParent
- setElementPosition
- setElementRotation
- setElementVelocity
- setLowLODElement
- getPedContactElement
- getResourceDynamicElementRoot
- getResourceRootElement