#define FILTERSCRIPT
#include <a_samp>
forward PickupTimer(numPickups);
// Float:gRandomPlayerSpawns[Number of locations][Number of coordinates (in this case, XYZ so 3]
new Float:gRandomPickupSpawns[4][3] = {
{1958.3783,1343.1572,15.3746},
{2199.6531,1393.3678,10.8203},
{2483.5977,1222.0825,10.8203},
{2637.2712,1129.2743,11.1797}
};
new PickupSet[MAX_PICKUPS][sizeof(gRandomPickupSpawns)]; /* making an 2D array 1 dimension the size of maximum allowed pickups in SAMP
and another the size of the location array
*/
new pickuptime; // variable of timer ID so we can kill the timer within itself
new pIdx; // keeps track of how many times PickupTimer is called and plants a pickup
public OnFilterScriptInit()
{
pickuptime = SetTimerEx("PickupTimer",10000,true,"d", 2); // last parameter for 2 pickups, 3 for 3 pickups, etc..
return 1;
}
public PickupTimer(numPickups)
{
if(pIdx == numPickups) return KillTimer(pickuptime); // if we have reached our goal of pickups, stop the timer!
new randomIdx = random(sizeof(gRandomPickupSpawns));
for(new i=0;i<MAX_PICKUPS;i++)
{
if(PickupSet[i][randomIdx] == 0) // is the location available?
{
new pickup = CreatePickup(1212,1,gRandomPickupSpawns[randomIdx][0],gRandomPickupSpawns[randomIdx][1],gRandomPickupSpawns[randomIdx][2]);
PickupSet[pickup][randomIdx] = 1; // this indicates that this pickup has already been set at a location and the location can not be used again
pIdx++;
}
}
return 1;
}
public OnFilterScriptExit()
{
return 1;
}