distance shooting
#1

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: ?
Reply
#2

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
Reply
#3

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
Reply
#4

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
Reply
#5

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.
Reply
#6

Alrights, thanks!
Reply
#7

thx too
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)