Function problem
#1

It's a function that should work properly to get distance between the player which used the command and the playerid chosen:
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;
}
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,
Reply


Messages In This Thread
Function problem [Resolved] - by blackwave - 18.04.2011, 13:04
Re: Function problem - by Mauzen - 18.04.2011, 13:27
Re: Function problem - by blackwave - 18.04.2011, 13:41
Re: Function problem - by Mauzen - 18.04.2011, 13:51
Re: Function problem - by blackwave - 18.04.2011, 14:00

Forum Jump:


Users browsing this thread: 2 Guest(s)