SA-MP Forums Archive
Pickup with arrays? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Pickup with arrays? (/showthread.php?tid=182315)



Pickup with arrays? - almighty - 10.10.2010

is it possible to make it so if tge pickupid == to any pickup in the array?... for example, i have this

if(pickupid == test[0])
{
SendClientMessage....
}
else if(pickupid == test[1])
{
Same as test[0]
}

is it possible to make it so it checks if the pickup id is one like
if(pickupid == test[])
{
Do
}


Re: Pickup with arrays? - Rachael - 10.10.2010

You can either loop through the array checking each one
pawn Код:
for(new i = 0; i < sizeof(test);i++)\
{
     if(test[i] == pickupid)
     {
         ...
     }
}
or you can create an entry in an array positioned according to the pickupid, and simply check the pickupid's data that way
pawn Код:
#define MAX_ARRAY_PICK    600
...
new test[MAX_ARRAY_PICKUP];
...
//pickup creation script
test[CreatePickup(1232,23,123 /* whatever */ )] = 1;
...
public OnPlayerPickupPickup(playerid,pickupid)
{
     if(pickupid < MAX_ARRAY_PICKUP)
     {
         if(test[pickupid] == 1)
         {
            ...
         }
     }
     return 1;
}



Respuesta: Pickup with arrays? - almighty - 10.10.2010

Interesting... i think i use it... just one question, would i set
"test[CreatePickup(1232,23,123 /* whatever */ )] = 1;" to 1 on ALL my pickups of the same type right?...


Re: Pickup with arrays? - Rachael - 10.10.2010

it depends how many different types of pickups you have, and if you want them to dissapear when collected, or stay.

eg test[1] = 1 for entrance pickup
test[22] = 2 gun pickup
test[6] = 3 cash pickup

its really limited only by your imagination and scripting skill

and you choose the pickup checking system according to which you need more, memory or speed.
the first method is slower but uses less memory.
the second is faster and uses more memory.