What can be in this code... it keeps server crashing at new SplitDiv[40][V_AMOUNT];...
And ofc vehicles.txt file is there, so that is not problem.
Код:
#define V_AMOUNT 1919
public LoadVehicles()
{
if(fexist("vehicles.txt"))
{
new string[125];
new SplitDiv[40][V_AMOUNT];
new filestring[225];
new File: file = fopen("vehicles.txt", io_read);
if (file)
{
for(new vehicleid = 1;vehicleid<V_AMOUNT;vehicleid++)
{
fread(file, filestring);
split(filestring, SplitDiv, ',');
VehicleInfo[vehicleid][model] = strval(SplitDiv[0]);
VehicleInfo[vehicleid][x_spawn] = floatstr(SplitDiv[1]);
VehicleInfo[vehicleid][y_spawn] = floatstr(SplitDiv[2]);
VehicleInfo[vehicleid][z_spawn] = floatstr(SplitDiv[3]);
VehicleInfo[vehicleid][za_spawn] = floatstr(SplitDiv[4]);
VehicleInfo[vehicleid][color_1] = strval(SplitDiv[5]);
VehicleInfo[vehicleid][color_2] = strval(SplitDiv[6]);
VehicleInfo[vehicleid][vehiclecost] = strval(SplitDiv[7]);
VehicleInfo[vehicleid][bought] = strval(SplitDiv[8]);
VehicleInfo[vehicleid][mod1] = strval(SplitDiv[9]);
VehicleInfo[vehicleid][mod2] = strval(SplitDiv[10]);
VehicleInfo[vehicleid][mod3] = strval(SplitDiv[11]);
VehicleInfo[vehicleid][mod4] = strval(SplitDiv[12]);
VehicleInfo[vehicleid][mod5] = strval(SplitDiv[13]);
VehicleInfo[vehicleid][mod6] = strval(SplitDiv[14]);
VehicleInfo[vehicleid][mod7] = strval(SplitDiv[15]);
VehicleInfo[vehicleid][mod8] = strval(SplitDiv[16]);
VehicleInfo[vehicleid][mod9] = strval(SplitDiv[17]);
VehicleInfo[vehicleid][mod10] = strval(SplitDiv[18]);
VehicleInfo[vehicleid][mod11] = strval(SplitDiv[19]);
VehicleInfo[vehicleid][mod12] = strval(SplitDiv[20]);
VehicleInfo[vehicleid][mod13] = strval(SplitDiv[21]);
VehicleInfo[vehicleid][mod14] = strval(SplitDiv[22]);
VehicleInfo[vehicleid][mod15] = strval(SplitDiv[23]);
VehicleInfo[vehicleid][mod16] = strval(SplitDiv[24]);
VehicleInfo[vehicleid][mod17] = strval(SplitDiv[25]);
VehicleInfo[vehicleid][boot] = strval(SplitDiv[26]);
VehicleInfo[vehicleid][locks] = strval(SplitDiv[27]);
VehicleInfo[vehicleid][bonnet] = strval(SplitDiv[28]);
VehicleInfo[vehicleid][engine] = strval(SplitDiv[29]);
strmid(VehicleInfo[vehicleid][owner], SplitDiv[30], 0, strlen(SplitDiv[30]), 255);
strmid(VehicleInfo[vehicleid][name2], SplitDiv[31], 0, strlen(SplitDiv[31]), 255);
strmid(VehicleInfo[vehicleid][plate], SplitDiv[32], 0, strlen(SplitDiv[32]), 255);
AddStaticVehicleEx(VehicleInfo[vehicleid][model], VehicleInfo[vehicleid][x_spawn], VehicleInfo[vehicleid][y_spawn], VehicleInfo[vehicleid][z_spawn], VehicleInfo[vehicleid][za_spawn], VehicleInfo[vehicleid][color_1], VehicleInfo[vehicleid][color_2],20000000*5);
if (strcmp(VehicleInfo[vehicleid][owner],"server",false) == 0)
{
if (VehicleInfo[vehicleid][bought] == 0)
{
format(string, sizeof(string), "%s - %iЂ", VehicleInfo[vehicleid][name2], VehicleInfo[vehicleid][vehiclecost]);
VehicleInfo[vehicleid][carlabel] = CreateDynamic3DTextLabel(string, 0xFFFFDD, VehicleInfo[vehicleid][x_spawn], VehicleInfo[vehicleid][y_spawn], VehicleInfo[vehicleid][z_spawn], DRAW_DISRANCE_3DTEXT,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,TEST_LOS,-1,-1,-1,100.0);
}
}
onsys[vehicleid] = 1;
VehicleInfo[vehicleid][paintjob] = strval(SplitDiv[33]);
VehicleInfo[vehicleid][gasse] = strval(SplitDiv[34]);
VehicleInfo[vehicleid][alarm2] = strval(SplitDiv[35]);
if(VehicleInfo[vehicleid][engine] == 1)
{
SetVehicleParamsEx(vehicleid, 1, 1, 0, VehicleInfo[vehicleid][locks], VehicleInfo[vehicleid][bonnet], VehicleInfo[vehicleid][boot], 0);
}
if(VehicleInfo[vehicleid][engine] == 0)
{
SetVehicleParamsEx(vehicleid, 0, 0, 0, VehicleInfo[vehicleid][locks], VehicleInfo[vehicleid][bonnet], VehicleInfo[vehicleid][boot], 0);
}
for(new d=0; d<26; d++)
{
if(VehicleInfo[vehicleid][model] == noplate[d])
{
//
}
else
{
SetVehicleNumberPlate(vehicleid, VehicleInfo[vehicleid][plate]);
}
}
if(VehicleInfo[vehicleid][gasse] > 100)
{
VehicleInfo[vehicleid][gasse] = 100;
}
printf("Loaded vehicle id: %i Name: %s Owner: %s", vehicleid, VehicleInfo[vehicleid][name2], VehicleInfo[vehicleid][owner]);
}
}
fclose(file);
}
}
Because 40*1919=76760 cells of stack memory is a bit too much. 32 should be fine