- Documentation
- Client functions
- isElementOnScreen
Function
isElementOnScreen
Checks whether an element is visible on the player's screen.
Syntax
bool isElementOnScreen(element theElement)Arguments
theElementelement- The element.
Returns
true if on screen.
Example
addEventHandler("onClientRender", root, function()
for _, veh in ipairs(getElementsByType("vehicle")) do
if isElementOnScreen(veh) then
local x, y, z = getElementPosition(veh)
local sx, sy = getScreenFromWorldPosition(x, y, z + 1.5)
if sx then dxDrawText(getVehicleName(veh), sx, sy) end
end
end
end)