setElementVisibleTo | Multi Theft Auto: Wiki Skip to content

setElementVisibleTo

Client-side
Server-side
Shared

Pair: isElementVisibleTo

Manual Review Required

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


This function can change an element's visibility.

OOP Syntax Help! I don't understand this!

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

  • bool: value

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.

Code Examples

shared

This example creates a marker and makes it only visibile to the player called 'someguy'.

-- Find the player called someguy
local someguy = getPlayerFromName ( "someguy" )
-- If the player was found then
if ( someguy ) then
-- Get the player's position into the variables x, y and z
x, y, z = getElementPosition ( someguy )
-- Create a marker at the player's position
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.
end

See Also

Element Functions