SetElementVisibleTo: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Needs_Checking|Can an element only be visible to one element (and its children) at a time? If so, do we need clearEntityVisibleTo? If not, surely we need to remove the root element before using this function?|[[User:EAi|EAi]]}}
{{Needs_Checking|Can an element only be visible to one element (and its children) at a time? If so, do we need clearElementVisibleTo? If not, surely we need to remove the root element before using this function?|[[User:EAi|EAi]]}}


This function can change an [[entity]] [[element]]'s [[visibility]]. This does not work with all entities - [[vehicle]]s, [[player]]s and [[object]]s are exempt. This is because these objects are required for accurate sync (they're physical objects). This function is particularily useful for changing the visibility of markers, radar blips and radar areas.
This function can change an [[element]] [[element]]'s [[visibility]]. This does not work with all entities - [[vehicle]]s, [[player]]s and [[object]]s are exempt. This is because these objects are required for accurate sync (they're physical objects). This function is particularily useful for changing the visibility of markers, radar blips and radar areas.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setEntityVisibleTo ( entity theEntity, element visibleTo, bool visible )   
bool setElementVisibleTo ( element theElement, element visibleTo, bool visible )   
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''theEntity:''' The entity you want to control the visibility of.
*'''theElement:''' The element you want to control the visibility of.
*'''visibleTo:''' The element you wish the entity to be visible or invisible to. Any child elements that are players will also be able to see the entity. See [[visibility]].
*'''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]].


===Returns===
===Returns===
Returns ''true'' if the entity's visibility was changed successfully, ''false'' otherwise, for example if you are trying to change the visibility of a vehicle, player or object.
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.


==Example==  
==Example==  
Line 24: Line 24:
if ( someguy ) then
if ( someguy ) then
-- Get the player position into the variables x, y and z
-- Get the player position into the variables x, y and z
x, y, z = getEntityPosition ( someguy )
x, y, z = getElementPosition ( someguy )
-- Create a marker at the player's position
-- Create a marker at the player's position
myMarker = createMarker ( x, y, z )
myMarker = createMarker ( x, y, z )
-- Make the marker only visible to that player
-- Make the marker only visible to that player
setEntityVisibleTo ( myMarker, someguy, true )
setElementVisibleTo ( myMarker, someguy, true )
end
end
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Entity_functions}}
{{Element_functions}}

Revision as of 23:55, 20 July 2006


Dialog-information.png This article needs checking.

Reason(s): Can an element only be visible to one element (and its children) at a time? If so, do we need clearElementVisibleTo? If not, surely we need to remove the root element before using this function?

This function can change an element element's visibility. This does not work with all entities - vehicles, players and objects are exempt. This is because these objects are required for accurate sync (they're physical objects). This function is particularily useful for changing the visibility of markers, radar blips and radar areas.

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.

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.

Example

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

-- Find the player called someguy
someguy = getFromNick ( "someguy" )
-- If the player was found then
if ( someguy ) then
	-- Get the player 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 )
	-- Make the marker only visible to that player
	setElementVisibleTo ( myMarker, someguy, true )
end

See Also