13.08.2011, 20:06
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:
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));
}