Coches en venta.
#1

Hola, puse un sistema de vehнculos en venta de ZC, y que pasa, funciona todo correctamente, creo el vehнculo en venta me desconecto y sigue ahн bien, compro un vehнculo, me desconecto y tambiйn funciona, el problema es cuando reinicio el servidor desaparecen los vehнculos a la venta, el mio propio sigue estando, los de venta no mas, por lo que quiere decir que no lee el carsale.cfg, te dejo el loadCarsale y saveCarsale por las dudas. El carsale.cfg se crea correctamente y dentro de el figura el vehiculo en venta.
Gracias por comentar.

Код:
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);
}
Reply
#2

Tienes que debugear la funciуn loadCarSale a ver si imprime algo del archivo que lee.
Reply
#3

Quote:
Originally Posted by MaRcOsWeB
Посмотреть сообщение
Tienes que debugear la funciуn loadCarSale a ver si imprime algo del archivo que lee.
Y como lo hago?
Reply
#4

Con printf es una buena opciуn, saldrб en la consola. Simplemente muestra la linea que lee el ciclo iterativo que tienes.
Reply
#5

Quote:
Originally Posted by MaRcOsWeB
Посмотреть сообщение
Con printf es una buena opciуn, saldrб en la consola. Simplemente muestra la linea que lee el ciclo iterativo que tienes.
Ahah si lo hice, en la consola aparece que se cargaron con exito, pero no cargan, hay algo en el loadCarsale parece u.u
Reply
#6

Mmm, raro. Prueba con AddStaticVehicle, a ver que sucede (vamos a debugear hasta que ande, y de ahi partimos a hacer algo distinto).
Reply
#7

Quote:
Originally Posted by MaRcOsWeB
Посмотреть сообщение
Mmm, raro. Prueba con AddStaticVehicle, a ver que sucede (vamos a debugear hasta que ande, y de ahi partimos a hacer algo distinto).
Con AddStaticVehicle? Todos los vehнculos andan bien, si compro un vehнculo a la venta se guarda correctamente, ъnicamente no carga los vehнculos a la venta al reiniciar el servidor. No lee el carsale.cfg parece.
Reply
#8

Entonces no hiciste el respectivo debug que te indiquй mбs arriba.

Intentarй ser mбs especifico, prueba esto:

PHP код:
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(iFileHandleszFileStr))
    {
        
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], 006);
            
format(text_infosizeof(text_info), "(%d) %s en Venta | Precio: %d"iIndex,GetVehicleName(carcreated), varCarSale[iIndex][CSVehCost]);
            
varCarSale[iIndex][CSVehicleLabel] = CreateDynamic3DTextLabel(text_info,COLOR_GENERAL,0.00.00.0,8.0,INVALID_PLAYER_ID,carcreated);
            
varCarSale[iIndex][CSVehId] = carcreated;
        }
        ++
iIndex;
    }
    print(
"[script] Sale Cars Loaded Successfully . . .");
    return 
fclose(iFileHandle);

Luego busca en tu log la palabra [DEBUG] y fijate si leyу algo.
Reply
#9

Quote:
Originally Posted by MaRcOsWeB
Посмотреть сообщение
Entonces no hiciste el respectivo debug que te indiquй mбs arriba.

Intentarй ser mбs especifico, prueba esto:

PHP код:
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(iFileHandleszFileStr))
    {
        
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], 006);
            
format(text_infosizeof(text_info), "(%d) %s en Venta | Precio: %d"iIndex,GetVehicleName(carcreated), varCarSale[iIndex][CSVehCost]);
            
varCarSale[iIndex][CSVehicleLabel] = CreateDynamic3DTextLabel(text_info,COLOR_GENERAL,0.00.00.0,8.0,INVALID_PLAYER_ID,carcreated);
            
varCarSale[iIndex][CSVehId] = carcreated;
        }
        ++
iIndex;
    }
    print(
"[script] Sale Cars Loaded Successfully . . .");
    return 
fclose(iFileHandle);

Luego busca en tu log la palabra [DEBUG] y fijate si leyу algo.
No apareciу nada.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)