17.03.2011, 13:44
Well, that function indeed can be optimized a bit
Should be at least 100% faster now
pawn Код:
forward Float:GetPlayerDistanceToPoint(playerid,Float:x,Float:y);
public Float:GetPlayerDistanceToPoint(playerid,Float:x,Float:y) // Make it return a Float safes a flaotround and a variable
// Well, depends on if you can use it like that or if you need it as int
{
new Float:x1,Float:y1,Float:z1;
GetPlayerPos(playerid,x1,y1,z1);
return floatsqroot(floatsub(x,x1) * floatsub(x,x1)) + floatsub(y,y1) * floatsub(y,y1)); // You dont need floatabs, as squared numbers are always positive
// Also do not use floatpower, but just *, because floatpower is extremely slow
}