19.05.2015, 19:11
Opening, writing and closing files 2000 times. You set idx to the value "carsonserver" is so what's the point of checking all the time instead of just opening the file once.
Plus you never check for invalid file handles and that can crash the server and declaring a string 2000 times as well (keep it outside of the loop).
Plus you never check for invalid file handles and that can crash the server and declaring a string 2000 times as well (keep it outside of the loop).
PHP код:
public OnCarUpdate()
{
new coordsstring[256], File: file2 = fopen("masini.cfg", io_write);
if (!file2) return 0;
for (new idx = carsonserver; idx != sizeof (CarInfo); ++idx)
{
format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
CarInfo[idx][cModel],
CarInfo[idx][cLocationx],
CarInfo[idx][cLocationy],
CarInfo[idx][cLocationz],
CarInfo[idx][cAngle],
CarInfo[idx][cColorOne],
CarInfo[idx][cColorTwo],
CarInfo[idx][cOwner],
CarInfo[idx][cDescription],
CarInfo[idx][cValue],
CarInfo[idx][cOwned],
CarInfo[idx][mod1],
CarInfo[idx][mod2],
CarInfo[idx][mod3],
CarInfo[idx][mod4],
CarInfo[idx][mod5],
CarInfo[idx][mod6],
CarInfo[idx][mod7],
CarInfo[idx][mod8],
CarInfo[idx][mod9],
CarInfo[idx][mod10],
CarInfo[idx][mod11],
CarInfo[idx][mod12],
CarInfo[idx][mod13],
CarInfo[idx][mod14],
CarInfo[idx][mod15],
CarInfo[idx][mod16],
CarInfo[idx][mod17],
CarInfo[idx][paintjob]);
fwrite(file2, coordsstring);
}
fclose(file2);
return 1;
}

