SA-MP Script: Detect collision between two cars
#1

Hi, my name is Peter and i am new arround here.

I would like to know if it is possible (and how) to detect when a car hits another car and return its id.

Thanks in advance!
Reply
#2

Natively, no.
However, you can make a couple of workarounds (which most likely won't be 100% precise although), for example, in a timer you could keep track of vehicles' healths, velocitys, and positions, and using that data try to 'guess' when two vehicles could have collided.
Reply
#3

OnVehicleUpdateDamage gets called for all vehicles, except motorbikes.

I suppose with a bit of calculating, you could work out if two vehicles hit each other. More accurate in my opinion than a timer.

Too early to code lol Here is what I would do :

OnVehicleDamage - Store ID, tickcount and pos to a [vehicleid] array
Each time it gets called, check if it's < 10 ticks (guess), if so, IsPlayerInRangeOfPoint (saved pos), return stored ID.
Reply
#4

Thanks a lot!

@Rac3r That's exactly what i was thinking, but thank you for the callback, i didn't find it.

Promise i'll post my gamemode when it's done. Thanks again!
Reply


Forum Jump:


Users browsing this thread: