Pickup with arrays?
#1

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
}
Reply
#2

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;
}
Reply
#3

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?...
Reply
#4

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)