IsElementInAir: Difference between revisions
Jump to navigation
Jump to search
m (Changed syntax a little) |
m (Changed syntax a little) |
||
| Line 16: | Line 16: | ||
assert(type(element) == 'userdata',('Expected element at argument 1, got %s!'):format(type(element))) | assert(type(element) == 'userdata',('Expected element at argument 1, got %s!'):format(type(element))) | ||
assert(getElementType(element) == 'ped' or getElementType(element) == 'vehicle', | assert(getElementType(element) == 'ped' or getElementType(element) == 'vehicle', | ||
('Expected element at argument 1, got %s!'):format( | ('Expected element at argument 1, got %s!'):format(getElementType(element)) | ||
) | ) | ||
if getElementType(element) == 'ped' then | if getElementType(element) == 'ped' then | ||
Revision as of 07:19, 7 June 2022
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(getElementType(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