SA-MP Forums Archive
Detect a position. - 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)
+--- Thread: Detect a position. (/showthread.php?tid=565183)



Detect a position. - Baltimore - 25.02.2015

Hello!

I want to know how to detect if we are beside the vehicle fuel cap for refueling.

Thank you .


Re: Detect a position. - DanishHaq - 25.02.2015

You'd have to do it for each vehicle as the fuel caps are of course not in the same place (some are left of the vehicle, some are right, some don't even exist on a given vehicle, some are higher, some are lower), and you'd have to make some calculations too for each of the vehicle (get the vehicle pos and then add to/remove from the coordinates to find where the fuel cap exactly is). After that you'd have to check if the player is near the fuel cap on a very small radius (I'd recommend 2, but you can do your bits and bobs to make it more accurate, again, this can vary (but very small) for each vehicle) with IsPlayerInRangeOfPoint. So in context it's completely possible but just requires a lot of work, a lot.

A quick way out of this would just to check if the player is near the vehicle, you would just use GetVehiclePos and then GetPlayerDistanceFromPoint or IsPlayerInRangeOfPoint (I'd use this instead of GPDFP) to determine this.


Re: Detect a position. - Baltimore - 25.04.2015

UP, please.


Re: Detect a position. - Baltimore - 23.06.2015

UP, please.


Re : Detect a position. - KillerDVX - 23.06.2015

Try this ? : https://sampwiki.blast.hk/wiki/GetPlayerDistanceFromPoint