Quote:
Originally Posted by gamer931215
Use a variable, like in this example:
pawn Code:
new bool:VehicleUsed[30];
//call this if you need a random id between 0/30 stock GetRandomVehicleID() { for(new i = 0;i<30;i++) { if(!VehicleUsed[i]) { VehicleUsed[i] = true; return i; } } return -1; //no vehicles left }
//call this if youre changing your maps stock ResetVehicles() { for(new i = 0;i<30;i++) { VehicleUsed[i] = false; } }
If your not always using 30 vehicles, then use a parameter to get the map like this:
pawn Code:
stock GetRandomVehicleID(map) { switch(map) { case 0: { for(new i = 0;i<30;i++) { if(!VehicleUsed[i]) { VehicleUsed[i] = true; return i; } } } } return -1; //no vehicles left }
or just use the parameter to set the limit for the loop
|
So in stead off
pawn Code:
new rand1=random(30);
PutPlayerInVehicle(i, CarMap1[rand1], 0);
I have to use this:
pawn Code:
PutPlayerInVehicle(i,GetRandomVehicleID(1),0);//for map 1