/rob closest player help
#3

use this stock
pawn Код:
stock GetNearestPlayer(playerid)
{
    new Float:dist = 1000.0;
    new targetid = INVALID_PLAYER_ID;
    new Float:x1,Float:y1,Float:z1;
    new Float:x2,Float:y2,Float:z2;
    new Float:tmpdis;
    GetPlayerPos(playerid,x1,y1,z1);
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if(i == playerid) continue;
        GetPlayerPos(i,x2,y2,z2);
        tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
        if(tmpdis < dist)
        {
            dist = tmpdis;
            targetid = i;
        }
    }
    return targetid;
}
EDIT: didnt refreshed the page so didnt saw the above reply. Sry for double post
Reply


Messages In This Thread
/rob closest player help - by AmirRFCNR - 29.08.2014, 15:30
Re: /rob closest player help - by Thogy - 29.08.2014, 15:42
Re: /rob closest player help - by BroZeus - 29.08.2014, 15:43
Re: /rob closest player help - by Stinged - 29.08.2014, 15:44
Re : /rob closest player help - by AmirRFCNR - 29.08.2014, 21:58
Re: /rob closest player help - by Noliax8 - 29.08.2014, 22:57
Re : /rob closest player help - by AmirRFCNR - 30.08.2014, 14:52
Re: /rob closest player help - by Lukka_Vercetti - 30.08.2014, 15:46
Re : Re: /rob closest player help - by AmirRFCNR - 30.08.2014, 16:23
Re: /rob closest player help - by Lukka_Vercetti - 30.08.2014, 16:29

Forum Jump:


Users browsing this thread: 3 Guest(s)