#include forward PickupTimer(numPickups); // Float:gRandomPlayerSpawns[Number of locations][Number of coordinates (in this case, XYZ so 3] new Float:gRandomPickupSpawns[23][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}, {2000.0106,1521.1111,17.0625}, {2024.8190,1917.9425,12.3386}, {2261.9048,2035.9547,10.8203}, {2262.0986,2398.6572,10.8203}, {2244.2566,2523.7280,10.8203}, {2335.3228,2786.4478,10.8203}, {2150.0186,2734.2297,11.1763}, {2158.0811,2797.5488,10.8203}, {1969.8301,2722.8564,10.8203}, {1652.0555,2709.4072,10.8265}, {1564.0052,2756.9463,10.8203}, {1271.5452,2554.0227,10.8203}, {1441.5894,2567.9099,10.8203}, {1480.6473,2213.5718,11.0234}, {1400.5906,2225.6960,11.0234}, {1598.8419,2221.5676,11.0625}, {1318.7759,1251.3580,10.8203}, {1558.0731,1007.8292,10.8125}, {1705.2347,1025.6808,10.8203} }; new PickupSet[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 new prevRand; // keeps track of previously random generated number main() { } public OnGameModeInit() { pickuptime = SetTimerEx("PickupTimer",1000,true,"d", 10); // last parameter for 2 pickups, 3 for 3 pickups, etc.. return 1; } public PickupTimer(numPickups) { new randomIdx = random(sizeof(gRandomPickupSpawns)); if(pIdx == numPickups) return KillTimer(pickuptime); // if we have reached our goal of pickups, stop the timer! if(randomIdx == prevRand){ // if generated random number is equal to one already set.. generate a new one randomIdx = random(sizeof(gRandomPickupSpawns)); return 1; } prevRand = randomIdx; for(new i=0;i<=sizeof(gRandomPickupSpawns);i++) { if(PickupSet[randomIdx] == 0) // is the location available? { new pickup = CreatePickup(1212,1,gRandomPickupSpawns[randomIdx][0],gRandomPickupSpawns[randomIdx][1],gRandomPickupSpawns[randomIdx][2]); PickupSet[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 OnGameModeExit() { return 1; }