IsElementInAir
Jump to navigation
Jump to search
This function checks if an element is in air.
Syntax
bool isElementInAir ( element theElement )
Returns
Returns true if the element is in air, false otherwise.
Code
function isElementInAir(element)
assert(type(element) == 'userdata',('Expected element at argument 1, got %s!'):format(type(element)))
assert(getElementType(element) == 'ped' or getElementType(element) == 'vehicle',
('Expected element at argument 1, got %s!'):format(type(element))
)
if getElementType(element) == 'ped' then
return not (isPedOnGround(element) or getPedContact(element))
elseif getElementType(element) == 'vehicle' then
return not isVehicleOnGround(element)
end
end
Example
Click to collapse [-]
ClientThis script tells if the player is in air or not.
addCommandHandler('air', function()
iprint(isElementInAir(localPlayer) and 'Indeed it is' or "Nope it's not")
end)
</syntaxhighlight>
Author: Hydra, Tracer