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); }
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); }
Tienes que debugear la funciуn loadCarSale a ver si imprime algo del archivo que lee.
|
Con printf es una buena opciуn, saldrб en la consola. Simplemente muestra la linea que lee el ciclo iterativo que tienes.
|
Mmm, raro. Prueba con AddStaticVehicle, a ver que sucede (vamos a debugear hasta que ande, y de ahi partimos a hacer algo distinto).
|
loadCarSale()
{
new text_info[68],szFileStr[1024],iIndex;
new File:iFileHandle = fopen("carsale.cfg", io_read);
if(!fexist("carsale.cfg"))
return 1;
while(iIndex < sizeof(varCarSale) && fread(iFileHandle, szFileStr))
{
printf("[DEBUG] %s\n", 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);
}
Entonces no hiciste el respectivo debug que te indiquй mбs arriba.
Intentarй ser mбs especifico, prueba esto: PHP код:
|