Код:
loadCarSale()
{
if(!fexist("carsale.cfg")) return 1;
new text_info[68],szFileStr[1024],File: iFileHandle = fopen("carsale.cfg", io_read),iIndex;
while(iIndex < sizeof(varCarSale) && fread(iFileHandle, szFileStr))
{
sscanf(szFileStr, "p<|>ffffffffii",
varCarSale[iIndex][CSVehSpawn][0],
varCarSale[iIndex][CSVehSpawn][1],
varCarSale[iIndex][CSVehSpawn][2],
varCarSale[iIndex][CSVehSpawn][3],
varCarSale[iIndex][VehSpawn][0],
varCarSale[iIndex][VehSpawn][1],
varCarSale[iIndex][VehSpawn][2],
varCarSale[iIndex][VehSpawn][3],
varCarSale[iIndex][CSVehCost],
varCarSale[iIndex][CSVehModel]);
if(varCarSale[iIndex][CSVehModel] > 410)
{
new carcreated = CreateVehicle(varCarSale[iIndex][CSVehModel], varCarSale[iIndex][CSVehSpawn][0], varCarSale[iIndex][CSVehSpawn][1], varCarSale[iIndex][CSVehSpawn][2], varCarSale[iIndex][CSVehSpawn][3], 0, 0, 6);
format(text_info, sizeof(text_info), "(%d) %s en Venta | Precio: %d", iIndex,GetVehicleName(carcreated), varCarSale[iIndex][CSVehCost]);
varCarSale[iIndex][CSVehicleLabel] = CreateDynamic3DTextLabel(text_info,COLOR_GENERAL,0.0, 0.0, 0.0,8.0,INVALID_PLAYER_ID,carcreated);
varCarSale[iIndex][CSVehId] = carcreated;
}
++iIndex;
}
print("[script] Sale Cars Loaded Successfully . . .");
return fclose(iFileHandle);
}
Y saveCarSale por las dudas
Код:
saveCarSale()
{
new szFileStr[512],File: fHandle = fopen("carsale.cfg", io_write);
for(new iIndex; iIndex < MAX_CARSALE; iIndex++)
{
format(szFileStr, sizeof(szFileStr), "%f|%f|%f|%f|%f|%f|%f|%f|%d|%d\r\n",
varCarSale[iIndex][CSVehSpawn][0],
varCarSale[iIndex][CSVehSpawn][1],
varCarSale[iIndex][CSVehSpawn][2],
varCarSale[iIndex][CSVehSpawn][3],
varCarSale[iIndex][VehSpawn][0],
varCarSale[iIndex][VehSpawn][1],
varCarSale[iIndex][VehSpawn][2],
varCarSale[iIndex][VehSpawn][3],
varCarSale[iIndex][CSVehCost],
varCarSale[iIndex][CSVehModel]);
fwrite(fHandle, szFileStr);
}
//print("[script] Car Sale Saved Successfully . . .");
return fclose(fHandle);
}
Gracias _Zume