distance
#9

Quote:
Originally Posted by [MG]Dimi
View Post
Nver heard of something like that.
Inform yourself better.

As to the problem: That function GetDistanceBetweenPlayers (which is really awfully coded) returns an integer variable, not a float. In order to return a float from that function, you need to remove the floatround() in it. This function will return a float value and is coded a lot cleaner:

pawn Code:
stock Float:GetDistanceBetweenPlayers(p1, p2)
{
    if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
        return FLOAT_NAN;

    new
        Float:x1,
        Float:y1,
        Float:z1,
        Float:x2,
        Float:y2,
        Float:z2;

    GetPlayerPos(p1,x1,y1,z1);
    GetPlayerPos(p2,x2,y2,z2);
   
    return GetDistanceBetweenPoints(x1, y1, z1, x2, y2, z2);
}

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));
}
Reply


Messages In This Thread
distance - by Headshot1108 - 13.08.2011, 19:09
Re: distance - by Riddick94 - 13.08.2011, 19:17
Re: distance - by Headshot1108 - 13.08.2011, 19:25
Re: distance - by Headshot1108 - 13.08.2011, 19:38
Re: distance - by [MG]Dimi - 13.08.2011, 19:52
Re: distance - by Headshot1108 - 13.08.2011, 19:58
Re: distance - by [MG]Dimi - 13.08.2011, 20:00
Re: distance - by Headshot1108 - 13.08.2011, 20:02
Re: distance - by Vince - 13.08.2011, 20:06
Re: distance - by Headshot1108 - 13.08.2011, 20:06
Re: distance - by [MG]Dimi - 13.08.2011, 20:09
Re: distance - by Headshot1108 - 13.08.2011, 20:37
Re: distance - by Vince - 13.08.2011, 20:55
Re: distance - by Headshot1108 - 13.08.2011, 21:21

Forum Jump:


Users browsing this thread: 2 Guest(s)