rendered paste bodyAddVehicles(){
new lin = flines(FILE_CARS),bikc,bicc,boc,cc,heac,helc,mc,pc,qc,rand,vchosen[MAX_VEHICLES];
for(new i=0;i<MAX_VEHICLES;i++){
#if DEBUG == true
printf("Attempting to Add Vehicle %d",i);
#endif
startover:
new bool:done;
while(done == false){
#if DEBUG == true
printf("Entering While Loop");
#endif
rand = minrand(1,lin);
new modx,Float:vx,Float:vy,Float:vz,Float:va,mod2,Float:vx2,Float:vy2,Float:vz2,Float:va2,vcount;
GetVehicleInfo(rand,modx,vx,vy,vz,va);
#if DEBUG == true
printf("Vehicle found and recorded %d,%f,%f,%f,%f",modx,vx,vy,vz,va);
#endif
if( i <= MAX_CITY_VEHICLES && !IsPointInCity(CITY,vx,vy)) goto startover;
else if(i > MAX_CITY_VEHICLES && IsPointInCity(CITY,vx,vy)) goto startover;
#if DEBUG == true
print("City Check Complete");
#endif
for(new a=0;a<MAX_VEHICLES;a++){
if(vchosen[a] == rand) goto startover;
GetVehicleInfo(vchosen[a],mod2,vx2,vy2,vz2,va2);
new dis = GetPointDistanceToPointEx(vx,vy,vz,vx2,vy2,vz2);
if(dis <= 3) goto startover;
else if(dis <= 50){
vcount++;
if(vcount == 3) goto startover;
}
}
#if DEBUG == true
print("Distance Check Complete");
#endif
switch(GetModelType(modx)){
case TYPE_BIKE:{if(bikc < MAX_BIKEC){ AddStaticVehicleEx(cbikes[random(MAX_BIKES)],vx,vy,vz,va,-1,-1,300); vchosen[i] = rand; break;}}
case TYPE_BICYCLE:{ if(bicc < MAX_BICYCLEC){ AddStaticVehicleEx(cbicycles[random(MAX_BICYCLES)],vx,vy,vz,va,-1,-1,300); vchosen[i] = rand; break;}}
case TYPE_BOAT:{ if(boc < MAX_BOATC){ AddStaticVehicleEx(cboats[random(MAX_BOATS)],vx,vy,vz,va,-1,-1,300); vchosen[i] = rand; break;}}
case TYPE_CAR:{ if(cc < MAX_CARC){ AddStaticVehicleEx(ccars[random(MAX_CARS)],vx,vy,vz,va,-1,-1,300); vchosen[i] = rand; break;}}
case TYPE_HELI:{ if(helc < MAX_HELIC){ AddStaticVehicleEx(chelis[random(MAX_HELIS)],vx,vy,vz,va,-1,-1,300); vchosen[i] = rand; break;}}
case TYPE_MONSTER:{ if(mc < MAX_MONSTERC){ AddStaticVehicleEx(cmonsters[random(MAX_MONSTER)],vx,vy,vz,va,-1,-1,300); vchosen[i] = rand; break;}}
case TYPE_PLANE:{ if(pc < MAX_PLANEC && IsPointInAirport(CITY,vx,vy)){ AddStaticVehicleEx(cplanes[random(MAX_PLANES)],vx,vy,vz,va,-1,-1,300); vchosen[i] = rand; break;}}
case TYPE_QUAD:{ if(qc < MAX_QUADC){ AddStaticVehicleEx(cquads[0],vx,vy,vz,va,-1,-1,300); vchosen[i] = rand; break;}}
case TYPE_HEAVY:{ if(heac < MAX_HEAVYC){ AddStaticVehicleEx(cheavys[random(MAX_HEAVY)],vx,vy,vz,va,-1,-1,300); vchosen[i] = rand; break;}}
}
}
}
}
GetVehicleInfo(line,&model,&Float:x,&Float:y,&Float:z,&Float:a){
new temp[256],File:fhandle = fopen(FILE_CARS,io_read),idx;
for(new i=0;i==line;i++) fread(fhandle,temp,sizeof(temp));
temp = strrest(temp,0);
while(strfind(temp," ",false)!=-1) temp = strreplace(" ","",temp);
while(strfind(temp,"AddStaticVehicle(",false)!=-1) temp = strreplace("AddStaticVehicle(","",temp);
while(strfind(temp,"AddStaticVehicleEx(",false)!=-1) temp = strreplace("AddStaticVehicleEx(","",temp);
for(new i=0,j=strlen(temp);i<j;i++){
if(temp[i] == ')'){
strdel(temp,i,j);
break;
}
}
model = strval(strtok(temp,idx,','));
x = floatstr(strtok(temp,idx,','));
y = floatstr(strtok(temp,idx,','));
z = floatstr(strtok(temp,idx,','));
a = floatstr(strtok(temp,idx,','));
fclose(fhandle);
}