setElementVisibleTo
Client-side
Server-side
Shared
Pair: isElementVisibleTo
This function can change an element's visibility. This can be a marker, blip or radararea.
Note
- Visibility settings of lower elements in the element tree override higher ones - if visibility for root is set to false and for a player is set to true, it will be visible to the player.
- Setting visibility for one element will also set visibility for all of its children. Order of setElementVisibleTo calls doesn't matter.
Tip
- If you want to clear all visibility settings of an element, try clearElementVisibleTo.
- If the element doesn't need to exist on the server side, you can simply create it on the client side (for example, a blip). In that case, you don't need to use this function, because only the client on which the element was created will see it.
OOP Syntax Help! I don't understand this!
- Method:element:setVisibleTo(...)
Syntax
bool setElementVisibleTo ( element theElement, element visibleTo, bool visible )Required arguments
- theElement: The element you want to control the visibility of.
- visibleTo: The element you wish the element to be visible or invisible to. Any child elements that are players will also be able to see the element. See visibility.
- visible: Whether you are making it visible or invisible to the player.
Returns
Returns true if the element's visibility was changed successfully, false otherwise, for example if you are trying to change the visibility of a vehicle, player or object.
- bool: result
Code Examples
server
This example creates a marker and makes it only visibile to the player called 'someguy'.
-- Find the player called someguylocal someguy = getPlayerFromName("someguy")-- If the player was found thenif (someguy) then -- Get the player's position into the variables x, y and z local x, y, z = getElementPosition(someguy) -- Create a marker at the player's position local myMarker = createMarker(x, y, z)
-- Then make the marker invisible to the whole dimension (root for the first) setElementVisibleTo(myMarker, root, false) -- Set marker visibility to true for someguy setElementVisibleTo(myMarker, someguy, true)
-- The order in which you do the visibility changes does not matter, but ideally trues should be set before falses in order to prevent a momentary flicker.endSee Also
Element Functions
- addElementDataSubscriber
- attachElements
- clearElementVisibleTo
- cloneElement
- createElement
- destroyElement
- detachElements
- getAllElementDataUpdated
- getAttachedElements
- getElementAlpha
- getElementAngularVelocity
- getElementAttachedOffsets
- getElementAttachedTo
- getElementBonePosition
- getElementBoneQuaternionNew
- getElementBoneRotation
- getElementBoundingBox
- getElementByID
- getElementByIndex
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementCollisionsEnabled
- getElementColShape
- getElementData
- getElementDimension
- getElementDistanceFromCentreOfMassToBaseOfModel
- getElementHealth
- getElementID
- getElementInterior
- getElementLighting
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRadius
- getElementRotation
- getElementsByType
- getElementsWithinColShape
- getElementsWithinRange
- getElementSyncer
- getElementType
- getElementVelocity
- getElementZoneName
- getLowLODElement
- getRootElement
- hasElementData
- hasElementDataSubscriber
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementCollidableWith
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLocal
- isElementLowLOD
- isElementOnFireNew
- isElementOnScreen
- isElementStreamable
- isElementStreamedIn
- isElementSyncer
- isElementVisibleTo
- isElementWaitingForGroundToLoad
- isElementWithinColShape
- isElementWithinMarker
- removeElementData
- removeElementDataSubscriber
- setElementAlpha
- setElementAngularVelocity
- setElementAttachedOffsets
- setElementBonePosition
- setElementBoneQuaternionNew
- setElementBoneRotation
- setElementCallPropagationEnabled
- setElementCollidableWith
- setElementCollisionsEnabled
- setElementDataUpdated
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementLightingNew
- setElementMatrix
- setElementModel
- setElementOnFireNew
- setElementParent
- setElementPosition
- setElementRotation
- setElementStreamable
- setElementSyncer
- setElementVelocity
- setElementVisibleTo
- setLowLODElement
- updateElementRpHAnim
Element Events
- onClientElementColShapeHit
- onClientElementColShapeLeave
- onClientElementDataChange
- onClientElementDestroy
- onClientElementDimensionChange
- onClientElementInteriorChange
- onClientElementModelChange
- onClientElementStreamIn
- onClientElementStreamOut
- onElementClicked
- onElementColShapeHit
- onElementColShapeLeave
- onElementDataChange
- onElementDestroy
- onElementDimensionChange
- onElementInteriorChange
- onElementModelChange
- onElementStartSync
- onElementStopSync