IsElementOnScreen: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(→Syntax) |
||
Line 2: | Line 2: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool isElementOnScreen ( element theElement ) | bool isElementOnScreen ( element theElement ) | ||
</syntaxhighlight> | |||
===Required Arguments=== | |||
*'''theElement:''' The element of which you wish to check wether it's being rendered on screen. | |||
===Returns=== | |||
Returns ''true'' if element is on screen, ''false'' if not. | |||
==Example== | |||
This function will check if you can see your kill when you die. | |||
<syntaxhighlight lang="lua"> | |||
function player_Wasted ( ammo, attacker, weapon, bodypart ) | |||
-- if there even was an attacker | |||
if ( attacker ) then | |||
-- there was an attacker | |||
if ( isElementOnScreen ( attacker ) ) then | |||
-- the player killed can see his killer | |||
outputChatBox ( "You can still see your killer!", source, 255, 0, 0 ) | |||
else | |||
-- the player killed can not see his killer | |||
outputChatBox ( "You can not see your killer!", source, 255, 0, 0 ) | |||
end | |||
end | |||
end | |||
addEventHandler ( "onPlayerWasted", getRootElement(), player_Wasted ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Incomplete]] | [[Category:Incomplete]] |
Revision as of 20:58, 3 July 2008
Syntax
bool isElementOnScreen ( element theElement )
Required Arguments
- theElement: The element of which you wish to check wether it's being rendered on screen.
Returns
Returns true if element is on screen, false if not.
Example
This function will check if you can see your kill when you die.
function player_Wasted ( ammo, attacker, weapon, bodypart ) -- if there even was an attacker if ( attacker ) then -- there was an attacker if ( isElementOnScreen ( attacker ) ) then -- the player killed can see his killer outputChatBox ( "You can still see your killer!", source, 255, 0, 0 ) else -- the player killed can not see his killer outputChatBox ( "You can not see your killer!", source, 255, 0, 0 ) end end end addEventHandler ( "onPlayerWasted", getRootElement(), player_Wasted )