04.01.2012, 19:05
So, how to count script cars? Im using AddStaticVehicle and AddStaticVehicleEx.
//Top of script:
new VehInfo[MAX_VEHICLES]=0;
//OnVehicleSpawn:
VehInfo[vehicleid] = 1;//Vehicle exists
//In a script to count vehicles:
new count=0;
for(new i = 0; i < MAX_VEHICLES; i++)
{
if(VehInfo[i] == 1)
{
count++;
}
}
printf("There are %d vehicles.",count);
new gStaticCars; // Global var
// GameModeInit
AddStaticVehicle(...);
AddStaticVehicle(...);
AddStaticVehicle(...);
gStaticCars = AddStaticVehicle(...); // This is to be the last vehicle that was created!
printf("There are %d cars.", gStaticCars);
new DynCars;
for(new v = 1; v < MAX_VEHICLES; ++v)
{
if(!GetVehicleModel(v)) continue;
DynCars++;
}