I wanted to know the ways to detect when a player falls from a bike.
After some research i found 2 ways to detect it (both are untested, errors may occur: that's only the concept):
addEventHandler( "onClientPlayerDamage", root,
function(attacker, weapon, bodypart, loss)
if getElementType( attacker ) == "vehicle" then
--thus player has fallen
end
end
)
but i'm not sure if falling from a motorbike/bike ALWAYS damage the player (or ped if with "onClientPedDamage")
and
addEventHandler("onClientVehicleCollision", root,
function(theHitElement, force, bodypart, collisionX, collisionY, collisionZ, normalX, normalY, normalZ, hitElementForce, model)
local isSourceEqualToTheVehOfThePlayer = true --check for the localPlayer or the player or the ped etc
if isSourceEqualToTheVehOfThePlayer then
--the event is called Before the fall if i remember correctly
--so check if after the event (50ms) the checked player has his vehicle
setTimer(
function(thePlayer, theVehicle)
if not getPedOccupiedVehicle( thePlayer ) then
--our player is not a good driver
end
end
, 50, 1, getVehicleOccupant( source ), source )
end
end
)
but i'm not sure if it is 100% correct and i'm sure it's not a "clean" way to solve the problem.
So the answer is: do falling from a bike always cause damage? and are there other ways to achieve this i'm not aware of? (maybe i didn't found the event for this)
also sorry for any english error