GetPlayerNearVehicle??? - 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: GetPlayerNearVehicle??? (
/showthread.php?tid=194391)
GetPlayerNearVehicle??? -
WillyP - 29.11.2010
Hey, I need some help with checking if people are within a X distance from a vehicle. I don't understand if you would put GetClosestVehicle? I need some maor ideas.
Re: GetPlayerNearVehicle??? -
JaTochNietDan - 29.11.2010
You want their distance to a vehicle? Well all you need is getdistance then
pawn Код:
Float:GetDistance(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2)
{
return Float:floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
Example of using it like you want to:
pawn Код:
new Float:x[2],Float:y[2],Float:z[2],distance;
GetVehiclePos(vehicleid,x[0],y[0],z[0]);
GetPlayerPos(playerid,x[1],y[1],z[1]);
distance = floatround(GetDistance(x[0],y[0],z[0],x[1],y[1],z[1]));
printf("Distance to car: %d",distance);
if(distance < 5000) // He's less than 5000 from the car!
Hope that helps!
Re: GetPlayerNearVehicle??? -
WillyP - 29.11.2010
Thank you very much JaToch!