05.05.2014, 16:54
As the title says, my stock stopped working after I added a loop for creating objects. And I've already implemented a warning to prevent the amount of objects and the amount of cars to not exceed the amount of spawn coordinates.
pawn Код:
stock CreateDynCars()
{
vcleanup();
for(spawncar=0;spawncar<MAX_CARS;spawncar++)
{
new model, color1, color2, spawnid;
model = random(11);
color1 = random(11);
color2 = random(11);
spawnloop:
spawnid = random(sizeof(vSpawns));
if(SpawnUsed[spawnid] == true) goto spawnloop;
SpawnUsed[spawnid] = true;
switch(model)
{
case 0:{model = 404;}
case 1:{model = 405;}
case 2:{model = 410;}
case 3:{model = 421;}
case 4:{model = 422;}
case 5:{model = 426;}
case 6:{model = 436;}
case 7:{model = 445;}
case 8:{model = 458;}
case 9:{model = 491;}
case 10:{model = 492;}
}
switch(color1)
{
case 0:{color1 = 8;}
case 1:{color1 = 9;}
case 2:{color1 = 10;}
case 3:{color1 = 11;}
case 4:{color1 = 12;}
case 5:{color1 = 13;}
case 6:{color1 = 14;}
case 7:{color1 = 15;}
case 8:{color1 = 37;}
case 9:{color1 = 38;}
case 10:{color1 = 39;}
}
switch(color2)
{
case 0:{color2 = 8;}
case 1:{color2 = 9;}
case 2:{color2 = 10;}
case 3:{color2 = 11;}
case 4:{color2 = 12;}
case 5:{color2 = 13;}
case 6:{color2 = 14;}
case 7:{color2 = 15;}
case 8:{color2 = 37;}
case 9:{color2 = 38;}
case 10:{color2 = 39;}
}
DynVehicle[spawncar] = CreateVehicle(model,vSpawns[spawnid][0],vSpawns[spawnid][1],vSpawns[spawnid][2],vSpawns[spawnid][3],color1,color2,-1);
engloop:
vInfo[DynVehicle[spawncar]][engine] = random(875);
if(vInfo[DynVehicle[spawncar]][engine] <= 250) goto engloop;
SetVehicleHealth(DynVehicle[spawncar],vInfo[DynVehicle[spawncar]][engine]);
vInfo[DynVehicle[spawncar]][tires] = random(4);
vInfo[DynVehicle[spawncar]][gas] = random(50);
new str[128];
format(str,sizeof(str),"Engine: %.0f\nTires: %i\nGas: %i", vInfo[DynVehicle[spawncar]][engine],vInfo[DynVehicle[spawncar]][tires],vInfo[DynVehicle[spawncar]][gas]);
CarInfo[spawncar] = Create3DTextLabel(str,COLOR_WHITE,0,0,0,3,-1,0);
Attach3DTextLabelToVehicle(CarInfo[spawncar],DynVehicle[spawncar],0,0,1);
}
for(new i=0;i<MAX_DUMPS;i++)
{
new spawnid;
spawnloop:
spawnid = random(sizeof(vSpawns));
if(SpawnUsed[spawnid] == true) goto spawnloop;
SpawnUsed[spawnid] = true;
Dump[i] = CreateObject(1415,vSpawns[spawnid][0],vSpawns[spawnid][1],vSpawns[spawnid][2] - 1,0,0,vSpawns[spawnid][3] + 180);
DumpInfo[i] = Create3DTextLabel("Dumpster\n(/search)",COLOR_WHITE,vSpawns[spawnid][0],vSpawns[spawnid][1],vSpawns[spawnid][2],5,0,0);
}
return 1;
}