SA-MP Forums Archive
distance shooting - 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: distance shooting (/showthread.php?tid=198190)



distance shooting - Seven. - 11.12.2010

when i kill someone, how do i get the distance from where he/she has been killed.

example:

Plater has killed you with a m4 the distance was: ?


Re: distance shooting - Mauzen - 11.12.2010

You can calculate the distance with this formula:

distance = floatsqroot( (player1x - player2x) * (player1x - player2x) + (player1y - player2y) * (player1y - player2y) + (player1z - player2z) * (player1z - player2z) )

Just use this in OnPlayerDeath


Re: distance shooting - BlackWolf120 - 11.12.2010

hi,
could u give me a little example how to get the players coordinates ( x, y and z)?
I know that u can get a players position with GetPlayerPos(...); but how to do this in ur formula?
Because there i have to know each single coordinate of playerid and killerid.
pls gimme a little hint


Re: distance shooting - Seven. - 11.12.2010

Thanks mauzen, But i ain't quite understanding it.. Do you have a example? Sorry if i bother you but sometimes i am really clueless :S


Re: distance shooting - Vince - 11.12.2010

pawn Код:
// Created by ******
stock Float:GetDistanceBetweenPoints(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2)
{
    x1 -= x2;
    y1 -= y2;
    z1 -= z2;
    return floatsqroot((x1 * x1) + (y1 * y1) + (z1 * z1));
}
Then just GetPlayerPos of both players and insert them in the function.


Re: distance shooting - Seven. - 11.12.2010

Alrights, thanks!


Re: distance shooting - BlackWolf120 - 11.12.2010

thx too