IsElementOnScreen: Difference between revisions
Jump to navigation
Jump to search
m (Removed TOC) |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Client function}} | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
Line 12: | Line 13: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function player_Wasted ( killer, weapon, bodypart ) | function player_Wasted ( killer, weapon, bodypart ) | ||
-- if there even was | -- if there even was a killer and the killer isn't the killed player itself | ||
if ( | if ( killer ) and ( killer ~= source ) then | ||
-- there was | -- there was a killer | ||
if ( isElementOnScreen ( | if ( isElementOnScreen ( killer ) ) then | ||
-- the player killed can see his killer | -- the player who was killed can see his killer | ||
outputChatBox ( "You can still see your killer!", source, 255, 0, 0 ) | outputChatBox ( "You can still see your killer!", source, 255, 0, 0 ) | ||
else | else | ||
-- the player killed can not see his killer | -- the player who was killed can not see his killer | ||
outputChatBox ( "You can not see your killer!", source, 255, 0, 0 ) | outputChatBox ( "You can not see your killer!", source, 255, 0, 0 ) | ||
end | end | ||
Line 26: | Line 27: | ||
addEventHandler ( "onClientPlayerWasted", getRootElement(), player_Wasted ) | addEventHandler ( "onClientPlayerWasted", getRootElement(), player_Wasted ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 08:02, 4 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 ( killer, weapon, bodypart ) -- if there even was a killer and the killer isn't the killed player itself if ( killer ) and ( killer ~= source ) then -- there was a killer if ( isElementOnScreen ( killer ) ) then -- the player who was killed can see his killer outputChatBox ( "You can still see your killer!", source, 255, 0, 0 ) else -- the player who was killed can not see his killer outputChatBox ( "You can not see your killer!", source, 255, 0, 0 ) end end end addEventHandler ( "onClientPlayerWasted", getRootElement(), player_Wasted )