Hallo, ich spawne meine Vehikel jetzt aus einer Datei, allerdings werden die For-Schleifen nicht ausgeführt ...
Hier der Code:
public OnGameModeInit()
{
[...]
// Autos per Datei:
new File:VehicleFile;
new blank[256];
new count = 0;
VehicleFile = fopen(VEHIKEL_DATEI);
while(fread(VehicleFile, blank, sizeof(blank))) {
count++;
}
fclose(VehicleFile);
vehcount = count;
new vehmes[256];
format(vehmes,sizeof(vehmes),"Verifying %s (Complete) - %d Vehicle Spawns Verified!", VEHIKEL_DATEI, vehcount);
printf(vehmes);
new SplitDiv[99][1024];
new filestring[256];
new File: file = fopen(VEHIKEL_DATEI, io_read);
format(filestring,sizeof(filestring),"%d",vehcount);
print(filestring);
for(new vehicleid = 1;vehicleid<=vehcount;vehicleid++)
{
fread(file, filestring);
split(filestring, SplitDiv, ',');
AutoInfo[vehicleid][id] = strval(SplitDiv[0]);
AutoInfo[vehicleid][vid] = strval(SplitDiv[1]);
AutoInfo[vehicleid][x] = floatstr(SplitDiv[2]);
AutoInfo[vehicleid][y] = floatstr(SplitDiv[3]);
AutoInfo[vehicleid][z] = floatstr(SplitDiv[4]);
AutoInfo[vehicleid][angle] = floatstr(SplitDiv[5]);
AutoInfo[vehicleid][color1] = strval(SplitDiv[6]);
AutoInfo[vehicleid][color2] = strval(SplitDiv[7]);
AutoInfo[vehicleid][mod1] = strval(SplitDiv[8]);
AutoInfo[vehicleid][mod2] = strval(SplitDiv[9]);
AutoInfo[vehicleid][mod3] = strval(SplitDiv[10]);
AutoInfo[vehicleid][mod4] = strval(SplitDiv[11]);
AutoInfo[vehicleid][mod5] = strval(SplitDiv[12]);
AutoInfo[vehicleid][mod6] = strval(SplitDiv[13]);
AutoInfo[vehicleid][mod7] = strval(SplitDiv[14]);
AutoInfo[vehicleid][mod8] = strval(SplitDiv[15]);
AutoInfo[vehicleid][mod9] = strval(SplitDiv[16]);
AutoInfo[vehicleid][mod10] = strval(SplitDiv[17]);
AutoInfo[vehicleid][mod11] = strval(SplitDiv[18]);
AutoInfo[vehicleid][mod12] = strval(SplitDiv[19]);
AutoInfo[vehicleid][mod13] = strval(SplitDiv[20]);
AutoInfo[vehicleid][mod14] = strval(SplitDiv[21]);
AutoInfo[vehicleid][mod15] = strval(SplitDiv[22]);
AutoInfo[vehicleid][mod16] = strval(SplitDiv[23]);
AutoInfo[vehicleid][mod17] = strval(SplitDiv[24]);
AutoInfo[vehicleid][paintjob] = strval(SplitDiv[25]);
AutoInfo[vehicleid][owner] = strval(SplitDiv[26]);
AddStaticVehicleEx(AutoInfo[vehicleid][vid], AutoInfo[vehicleid][x], AutoInfo[vehicleid][y], AutoInfo[vehicleid][z], AutoInfo[vehicleid][angle], AutoInfo[vehicleid][color1], AutoInfo[vehicleid][color2],-1);
new addmess[256];
format(addmess,sizeof(addmess),"--:: Vehicle %d successfully Loaded and placed - owner: %d ::--",vehicleid,AutoInfo[vehicleid][vid],AutoInfo[vehicleid][owner]);
print(addmess);
}
fclose(file);
for(new c=1;c<=vehcount;c++)
{
ModVehicle(c);
}
[..]
return 1;
}
Die Datei mit den Vehikeln existiert und ist auch im richtigen ordner, er sagt mir ja, wie viele Vehikel in der Datei sind!