SetElementDimension: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
m (→Example) |
||
Line 16: | Line 16: | ||
==Example== | ==Example== | ||
<section name="Server" class="server" show=" | <section name="Server" class="server" show="true"> | ||
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. | 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. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
Line 25: | Line 25: | ||
end | end | ||
end | end | ||
addEventHandler ( " | addEventHandler ( "onPlayerVehicleEnter", getRootElement ( ), onPlayerEnterVehicle ) | ||
function onPlayerExitVehicle ( theVehicle, seat, jacker ) | function onPlayerExitVehicle ( theVehicle, seat, jacker ) | ||
Line 33: | Line 33: | ||
end | end | ||
end | end | ||
addEventHandler ( " | addEventHandler ( "onPlayerVehicleExit", getRootElement ( ), onPlayerExitVehicle ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> |
Revision as of 17:27, 4 April 2009
This function allows you to set the dimension of any element. The dimension determines what/who the element is visible to.
Syntax
bool setElementDimension ( element theElement, int dimension )
Required Arguments
- theElement: The element in which you'd like to set the dimension of.
- dimension: An integer representing the dimension ID
Returns
Returns true if theElement and dimension are valid, false otherwise.
Example
Click to collapse [-]
ServerIn 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", getRootElement ( ), 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", getRootElement ( ), 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