27.03.2013, 12:47
I work for Save System Co. vehicles. The purchase of the vehicle, I put that stores vehicles (Public SaveVehicles ()
. When the server saves vehicle codes Mix, and the fit'' scan'' script, as if I put return 1;. I do not know where the mistake is.
Before saving:
After saving
Save and Load Vehicles Public
Tnx
. When the server saves vehicle codes Mix, and the fit'' scan'' script, as if I put return 1;. I do not know where the mistake is.Before saving:
Код:
1946.4203,-2114.0017,13.2699,89.3531,0,0,No-one,411,6,6,0,1000,0,0,0,131838,0,0,0,0,0,0,0,0,50,158
Код:
0.000000,NaN,0.000000,0.000000,0,1,Hondo_Harrelson,411,6,6,0,1000,0,0,0,131838,0,0,0,0,0,0,0,0,50,158
Код:
LoadVehicles()
{
new arrCoords[26][64],
strFromFile2[256],
File: file = fopen("/Nekretnine/cocar.cfg", io_read);
if (file)
{
new idx;
while (idx < sizeof(VehicleInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, ',');
VehicleInfo[idx][vLocationX] = strvalEx(arrCoords[0]);
VehicleInfo[idx][vLocationY] = strvalEx(arrCoords[1]);
VehicleInfo[idx][vLocationZ] = strvalEx(arrCoords[2]);
VehicleInfo[idx][vLocationRX] = strvalEx(arrCoords[3]);
VehicleInfo[idx][vArmour] = strvalEx(arrCoords[4]);
VehicleInfo[idx][vOwned] = strvalEx(arrCoords[5]);
strmid(VehicleInfo[idx][vOwner], arrCoords[6], 0, strlen(arrCoords[6]), 255);
VehicleInfo[idx][vModel] = strvalEx(arrCoords[7]);
VehicleInfo[idx][vColor1] = strvalEx(arrCoords[8]);
VehicleInfo[idx][vColor2] = strvalEx(arrCoords[9]);
VehicleInfo[idx][vLock] = strvalEx(arrCoords[10]);
VehicleInfo[idx][vBuyPrice] = strvalEx(arrCoords[11]);
VehicleInfo[idx][vENCOwned] = strvalEx(arrCoords[12]);
VehicleInfo[idx][vENCMoney] = strvalEx(arrCoords[13]);
VehicleInfo[idx][vCarRegisterOwned] = strvalEx(arrCoords[14]);
VehicleInfo[idx][vCarRegisterNum] = strvalEx(arrCoords[15]);
VehicleInfo[idx][vMats] = strvalEx(arrCoords[16]);
VehicleInfo[idx][vDrugs] = strvalEx(arrCoords[17]);
VehicleInfo[idx][vGun1] = strvalEx(arrCoords[18]);
VehicleInfo[idx][vGunAmmo1] = strvalEx(arrCoords[19]);
VehicleInfo[idx][vGun2] = strvalEx(arrCoords[20]);
VehicleInfo[idx][vGunAmmo2] = strvalEx(arrCoords[21]);
VehicleInfo[idx][vGun3] = strvalEx(arrCoords[22]);
VehicleInfo[idx][vGunAmmo3] = strvalEx(arrCoords[23]);
VehicleInfo[idx][vBenzin] = strvalEx(arrCoords[24]);
VehicleInfo[idx][vID] = strvalEx(arrCoords[25]);
printf("Co vozilo %d je uspjesno ucitano.\n",idx);
idx++;
}
fclose(file);
}
return 1;
}
Код:
SaveVehicles()
{
new idx,
File: file2;
while (idx < sizeof(VehicleInfo))
{
new coordsstring[312];
format(coordsstring, sizeof(coordsstring), "%f,%f,%f,%f,%d,%d,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
VehicleInfo[idx][vLocationX],
VehicleInfo[idx][vLocationY],
VehicleInfo[idx][vLocationZ],
VehicleInfo[idx][vLocationRX],
VehicleInfo[idx][vArmour],
VehicleInfo[idx][vOwned],
VehicleInfo[idx][vOwner],
VehicleInfo[idx][vModel],
VehicleInfo[idx][vColor1],
VehicleInfo[idx][vColor2],
VehicleInfo[idx][vLock],
VehicleInfo[idx][vBuyPrice],
VehicleInfo[idx][vENCOwned],
VehicleInfo[idx][vENCMoney],
VehicleInfo[idx][vCarRegisterOwned],
VehicleInfo[idx][vCarRegisterNum],
VehicleInfo[idx][vMats],
VehicleInfo[idx][vDrugs],
VehicleInfo[idx][vGun1],
VehicleInfo[idx][vGunAmmo1],
VehicleInfo[idx][vGun2],
VehicleInfo[idx][vGunAmmo2],
VehicleInfo[idx][vGun3],
VehicleInfo[idx][vGunAmmo3],
VehicleInfo[idx][vBenzin],
VehicleInfo[idx][vID]);
if(idx == 0)
{
file2 = fopen("/Nekretnine/cocar.cfg", io_write);
}
else
{
file2 = fopen("/Nekretnine/cocar.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
idx = 0;
return 1;
}

