Closest Dynamic Object
#2

pawn Код:
stock GetClosestDynamicObject(playerid)
{
    new Float:px,Float:py,Float:pz,
    Float:ox,Float:oy,Float:oz,Float:dist,result = 12345;
    GetPlayerPos(playerid,px,py,pz);
    for(new o; o < CountDynamicObjects(); o++)
    {
        GetDynamicObjectPos(o,ox,oy,oz);
        dist = floatsqroot(floatpower(floatabs(floatsub(px,ox)),2)+floatpower(floatabs(floatsub(py,oy)),2)+floatpower(floatabs(floatsub(pz,oz)),2));
        if(dist < result)
        {
            result = dist;
            return o;
        }
    }
    return 1;
}
Example
pawn Код:
new objectid = GetClosestDynamicObject(playerid);
Reply


Messages In This Thread
Closest Dynamic Object - by Oh - 18.01.2012, 05:48
Re: Closest Dynamic Object - by T0pAz - 18.01.2012, 06:32
Re: Closest Dynamic Object - by T0pAz - 18.01.2012, 08:52
Re: Closest Dynamic Object - by Oh - 18.01.2012, 09:01
Re: Closest Dynamic Object - by PrawkC - 18.01.2012, 09:13
Re: Closest Dynamic Object - by T0pAz - 18.01.2012, 09:14
Re: Closest Dynamic Object - by Oh - 18.01.2012, 09:16
Re: Closest Dynamic Object - by T0pAz - 18.01.2012, 09:19
Re: Closest Dynamic Object - by Oh - 18.01.2012, 09:33

Forum Jump:


Users browsing this thread: 1 Guest(s)