IsElementVisibleTo: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
 
(14 intermediate revisions by 9 users not shown)
Line 1: Line 1:
[[Category:Incomplete]]
{{Server function}}
 
__NOTOC__  
__NOTOC__  
This function is for blahblah.. not defined yet
This checks if an element is visible to a player. This does not check if the player can literally see the element, just that they are aware that it exists. Some so-called [[per-player elements]] are able to be visible only to some players, as such this checks if this is the case for a particular element/player combination.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
INSERT SYNTAX HERE             
bool isElementVisibleTo ( element theElement, element visibleTo )         
</syntaxhighlight>  
</syntaxhighlight>  
{{OOP||[[element]]:isVisibleTo||setElementVisibleTo}}


===Required Arguments===  
===Required Arguments===  
*'''argumentName:''' description
*'''theElement:''' The element you want to check the visibility of
 
*'''visibleTo:''' The player you want to check against
===Optional Arguments===
{{OptionalArg}}
*'''argumentName2:''' descriptiona
*'''argumentName3:''' description


===Returns===
===Returns===
Returns ''true'' if blah, ''false'' otherwise.
Returns ''true'' if element is visible to the specified player, ''false'' if not or an invalid argument was passed to the function.


==Example==  
==Example==  
This example does...
This checks if the player is visible to them selves.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">addEventHandler("onPlayerSpawn",root,function()
--This line does...
    if not isElementVisibleTo(source,source) then --if the player is not visible to them selves
blabhalbalhb --abababa
          setElementVisibleTo(source,source,true) --then make them visible to them selves.
--This line does this...
    end
mooo
end)
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{FunctionArea_Functions}}
{{Element_functions|server}}

Latest revision as of 22:31, 6 September 2024

This checks if an element is visible to a player. This does not check if the player can literally see the element, just that they are aware that it exists. Some so-called per-player elements are able to be visible only to some players, as such this checks if this is the case for a particular element/player combination.

Syntax

bool isElementVisibleTo ( element theElement, element visibleTo )          

OOP Syntax Help! I don't understand this!

Method: element:isVisibleTo(...)
Counterpart: setElementVisibleTo


Required Arguments

  • theElement: The element you want to check the visibility of
  • visibleTo: The player you want to check against

Returns

Returns true if element is visible to the specified player, false if not or an invalid argument was passed to the function.

Example

This checks if the player is visible to them selves.

addEventHandler("onPlayerSpawn",root,function()
     if not isElementVisibleTo(source,source) then --if the player is not visible to them selves
          setElementVisibleTo(source,source,true) --then make them visible to them selves.
     end
end)

See Also