Is there a GetDistanceFromPlayerToPoint function? - 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: Is there a GetDistanceFromPlayerToPoint function? (
/showthread.php?tid=121109)
Is there a GetDistanceFromPlayerToPoint function? -
Celson - 15.01.2010
Obviously there is a IsPlayerInRangeOfPoint function, but I wanna do something like...
Код:
new Float:thedistance
GetDistanceFromPlayerToPoint(playerid,X,Y,Z,thedistance);
So then I could do something like...
Код:
format(string, sizeof(string), "Distance: %.0f",thedistance);
Anybody know of any functions that I could do this with?
Re: Is there a GetDistanceFromPlayerToPoint function? -
Correlli - 15.01.2010
pawn Код:
/* credits to the original author (i don't know who created this function) */
stock Float:GetPlayerDistanceToPoint(playerid, {Float,_}:...)
{
new
num = numargs(), Float:pos[3];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
if(num == 3) return floatsqroot(floatpower(floatabs(floatsub(pos[0], Float:getarg(1))), 2) + floatpower(floatabs(floatsub(pos[1], Float:getarg(2))), 2));
else if(num == 4) return floatsqroot(floatpower(floatabs(floatsub(pos[0], Float:getarg(1))), 2) + floatpower(floatabs(floatsub(pos[1], Float:getarg(2))), 2) + floatpower(floatabs(floatsub(pos[2], Float:getarg(3))), 2));
return -1.0;
}
Re: Is there a GetDistanceFromPlayerToPoint function? -
Celson - 15.01.2010
Thanks