[Include] CPTP:ClosestPlayerToPoint(x,y,z)
#8

Quote:
Originally Posted by xkirill
Посмотреть сообщение
would be nicer if it had some math in it.
pawn Код:
// Too lazy for 3d,so ... 2d will be enough I guess ...
stock ClosestPlayerToPoint(Float:x,Float:y) {
    new iClosest,d[MAX_PLAYERS],Float:x,Float:y,Float:z;
    foreach(new i : Player) {
        GetPlayerPos(i,x,y,z);
        d[i]=Floatsqroot(Floatpower(x,2) + Floatpower(y,2));
        if(d[i] < d[i-1]) {
                iClosest=i;
        }
    }
    return iClosest;
}
All what's left is Z ;)
(Height for 3d distance,in my code it's 2d,because it calculates x and y distance)
that code has some errors for your in formation u have declared x and y twice one in stock ClosestPlayerToPoint(Float:x,Float:y)
and one in new iClosest,d[MAX_PLAYERS],Float:x,Float:y,Float:z;
so the declaration of x and y lines should be removed.
Reply


Messages In This Thread
CPTP:ClosestPlayerToPoint(x,y,z) - by BroZeus - 15.03.2014, 16:51
Re: CPTP:ClosestPlayerToPoint(x,y,z) - by Emmet_ - 15.03.2014, 17:11
Re: CPTP:ClosestPlayerToPoint(x,y,z) - by Marricio - 15.03.2014, 17:30
Re: CPTP:ClosestPlayerToPoint(x,y,z) - by BroZeus - 16.03.2014, 03:35
Re: CPTP:ClosestPlayerToPoint(x,y,z) - by MP2 - 16.03.2014, 03:47
Re: CPTP:ClosestPlayerToPoint(x,y,z) - by BroZeus - 16.03.2014, 08:15
Re: CPTP:ClosestPlayerToPoint(x,y,z) - by Kaperstone - 16.03.2014, 08:35
Re: CPTP:ClosestPlayerToPoint(x,y,z) - by BroZeus - 16.03.2014, 09:03
Re: CPTP:ClosestPlayerToPoint(x,y,z) - by Kaperstone - 16.03.2014, 13:44
Re: CPTP:ClosestPlayerToPoint(x,y,z) - by Vinnyy - 16.03.2014, 18:02

Forum Jump:


Users browsing this thread: 1 Guest(s)