SA-MP Script: Detect collision between two cars - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: SA-MP Script: Detect collision between two cars (
/showthread.php?tid=175735)
SA-MP Script: Detect collision between two cars -
p3t3r313 - 10.09.2010
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!
Re: SA-MP Script: Detect collision between two cars -
Zamaroht - 11.09.2010
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.
Re: SA-MP Script: Detect collision between two cars -
Rac3r - 11.09.2010
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.
Re: SA-MP Script: Detect collision between two cars -
p3t3r313 - 11.09.2010
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!