18.04.2011, 13:04
(
Последний раз редактировалось blackwave; 18.04.2011 в 14:20.
)
It's a function that should work properly to get distance between the player which used the command and the playerid chosen:
I tested myself this command and just me give some weird distances, as: 2290, 2280, 2287...
It may not be due it's myself, and distance from to me is 0, but I think something is wrong on function, or I've made the code wrong. Anyway hope anyone can help me. Thanks,
pawn Код:
stock GetPlayerDistanceToPoint(playerid,Float:x,Float:y,Float:z)
{
new Float:x1,Float:y1,Float:z1;
new Float:dis;
GetPlayerPos(playerid,x1,y1,z1);
dis = floatsqroot((x-x1)*(x-x1)+(y-y1)*(y-y1)+(z-z1)*(z-z1));
return floatround(dis);
}
pawn Код:
CMD:getdistance(playerid, params[])
{
new id, string[230];
new Float:x,Float:y,Float:z;
if(sscanf(params, "u", id)) return Msg(playerid, color, ""#red"USAGE: "#green"/getdistance <playerid>");
if(!Connect(playerid)) return Msg(playerid, color, NOT_CONNECTED);
format(string,sizeof(string),""#red"Distance to "#green"%s (id: %d): "#blue"%d",GetMyName(id),id,GetPlayerDistanceToPoint(playerid,x,y,z));
Msg(playerid, color, string);
return 1;
}
It may not be due it's myself, and distance from to me is 0, but I think something is wrong on function, or I've made the code wrong. Anyway hope anyone can help me. Thanks,