IsElementOnScreen: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 13: | Line 13: | ||
Returns ''true'' if element is on screen, ''false'' if not. | Returns ''true'' if element is on screen, ''false'' if not. | ||
==Example== | ==Example== | ||
This function will check if you can see your | This function will check if you can see your killer when you die. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function player_Wasted ( killer, weapon, bodypart ) | function player_Wasted ( killer, weapon, bodypart ) | ||
Line 20: | Line 20: | ||
-- there was a killer | -- there was a killer | ||
if ( isElementOnScreen ( killer ) ) then | if ( isElementOnScreen ( killer ) ) then | ||
-- the | -- the killer was on screen | ||
outputChatBox ( "You can still see your killer!" | outputChatBox ( "You can still see your killer!", 255, 0, 0 ) | ||
else | else | ||
-- the | -- the killer was not on screen | ||
outputChatBox ( "You can not see your killer!" | outputChatBox ( "You can not see your killer!", 255, 0, 0 ) | ||
end | end | ||
end | end | ||
end | end | ||
addEventHandler ( "onClientPlayerWasted", | -- call player_Wasted when only the local player dies | ||
addEventHandler ( "onClientPlayerWasted", localPlayer, player_Wasted ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Client element functions}} | {{Client element functions}} |
Revision as of 13:27, 2 June 2013
This function will check if an element is on the screen. Elements behind objects but still in the camera view count as being on screen.
This function is particularly useful for detecting if dynamic objects are in "destroyed" state. Destroyed objects will return false.
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 killer 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 killer was on screen outputChatBox ( "You can still see your killer!", 255, 0, 0 ) else -- the killer was not on screen outputChatBox ( "You can not see your killer!", 255, 0, 0 ) end end end -- call player_Wasted when only the local player dies addEventHandler ( "onClientPlayerWasted", localPlayer, player_Wasted )
See Also
- getElementBoneMatrix
- getElementBonePosition
- getElementBoneRotation
- getElementBoundingBox
- getElementDistanceFromCentreOfMassToBaseOfModel
- getElementLighting
- getElementRadius
- isElementCollidableWith
- isElementLocal
- isElementOnScreen
- isElementStreamable
- isElementStreamedIn
- isElementSyncer
- isElementWaitingForGroundToLoad
- setElementBoneMatrix
- setElementBonePosition
- setElementBoneRotation
- setElementCollidableWith
- setElementStreamable
- updateElementRpHAnim
- Shared
- attachElements
- createElement
- destroyElement
- detachElements
- getAttachedElements
- getElementAlpha
- getElementAttachedOffsets
- getElementAttachedTo
- getElementByIndex
- getElementByID
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementCollisionsEnabled
- getElementColShape
- getElementData
- getAllElementData
- hasElementData
- getElementDimension
- getElementHealth
- getElementID
- getElementInterior
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRotation
- getElementsByType
- getElementsWithinColShape
- getElementsWithinRange
- getElementType
- getElementVelocity
- getLowLODElement
- getRootElement
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLowLOD
- isElementWithinColShape
- isElementWithinMarker
- setElementAlpha
- setElementAngularVelocity
- getElementAngularVelocity
- setElementAttachedOffsets
- setElementCallPropagationEnabled
- setElementCollisionsEnabled
- setElementData
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementModel
- setElementParent
- setElementPosition
- setElementRotation
- setElementVelocity
- setLowLODElement
- getPedContactElement
- getResourceDynamicElementRoot
- getResourceRootElement