hello
I want to know how to catch if a player is ramming another player with vehicle
either finding the player who is ramming or finding that a player is getting rammed by a vehicle
thank you
hello
I want to know how to catch if a player is ramming another player with vehicle
either finding the player who is ramming or finding that a player is getting rammed by a vehicle
thank you
Have a look at something like this:
this is for the time victim dies, Iām looking for when a player gets hit by a vehicle while he remains alive
It is for any damage done, not just if they die. You will have to tweak it to your needs. The event includes the ID of the player that caused the damage, just use this instead of the player killer.
you were right sorry, I found the HasPedBeenDamagedByWeapon function so we can check if was damaged by WEAPON_RAMMED_BY_CAR but there is one question, how about I want to know the player was damaged by vehicle lately? like 3 seconds ago something like that
ok I tested HasPedBeenDamagedByWeapon and always returns false!
Citizen.CreateThread(function()
while true do
local myPed = PlayerPedId()
print(
HasPedBeenDamagedByWeapon(myPed, GetHashKey("WEAPON_RAMMED_BY_CAR"), 0),
HasPedBeenDamagedByWeapon(myPed, GetHashKey("WEAPON_RUN_OVER_BY_CAR"), 0)
)
Wait(100)
end
end)
prints false, false when gets hit by a car
Just use the args from the event to get the necessary data, this code might be a better example:
Then if you want to only check recent damage events you can cache the damage data then clear it every say 5 seconds.