SA-MP Forums Archive
Get amount of near objects - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Get amount of near objects (/showthread.php?tid=619755)



Get amount of near objects - PeanutButter - 21.10.2016

Hi,

I'm trying to get the near objects for my inventory scripts.

This is the command to get the near objects
PHP код:
CMD:pick(playeridparams[])
{
    new 
nearobj[216];
    
printf("get object %i"GetLastInvID());
        for(new 
iGetLastInvID(); i++)
        {
            new 
Float:xFloat:yFloat:z;
            
GetObjectPos(Dropped[i], xyz);
            if(
IsPlayerInRangeOfPoint(playerid5.0xyz))
            {
                for(new 
jGetLastInvID(); j++)
                {
                    if(
GetNearObjects(playeridGetObjectIDFromInvID(i)))
                    {
                        
format(nearobjsizeof(nearobj), "%s\n%s"nearobjGetObjectNameFromInvID(i));
                    }
                    
                }
            }
        }
        
Dialog_Show(playeridpickitemDIALOG_STYLE_LIST"Near objects"nearobj"Select""Cancel");
        return 
1;

I need a funtion that returns the amount of objects that are near the player. ( Dropped[MAX_OBJECTS] )
PHP код:
stock GetNearObjects(playerid,id)
{
    new 
amountofnearobjects;
    return 
amountofnearobjects;
    
// I need a funtion that returns the amount of objets nearby