[DealerShip] Problem with loading cars.
#1

I move one delearship from FilteScript to Gamemode, everything works fine but i have only this problem when i create an DealerShip then add cars to that dealership and go quit and then shutdown the server and run again there no cars there no dealership i check the "scriptfiles" there files from the cars and dealership also i check the "server_log.txt" and there is log "1 DealerShip Loaded / 2 Vehicles Loaded /" but there no cars and dealership.


Vehicles:
pawn Код:
LoadVehicles()
{
    new string[64];
    new File:handle, count;
    new filename[64], line[256], s, key[64];
    for(new i=1; i < MAX_DVEHICLES; i++)
    {
        format(filename, sizeof(filename), VEHICLE_FILE_PATH "v%d.ini", i);
        if(!fexist(filename)) continue;
        handle = fopen(filename, io_read);
        while(fread(handle, line))
        {
            StripNL(line);
            s = strfind(line, "=");
            if(!line[0] || s < 1) continue;
            strmid(key, line, 0, s++);
            if(strcmp(key, "Created") == 0) VehicleCreated[i] = strval(line[s]);
            else if(strcmp(key, "Model") == 0) VehicleModel[i] = strval(line[s]);
            else if(strcmp(key, "Pos") == 0) sscanf(line[s], "p,ffff", VehiclePos[i][0], VehiclePos[i][1],
                VehiclePos[i][2], VehiclePos[i][3]);
            else if(strcmp(key, "Colors") == 0) sscanf(line[s], "p,dd", VehicleColor[i][0], VehicleColor[i][1]);
            else if(strcmp(key, "Interior") == 0) VehicleInterior[i] = strval(line[s]);
            else if(strcmp(key, "VirtualWorld") == 0) VehicleWorld[i] = strval(line[s]);
            else if(strcmp(key, "Owner") == 0) strmid(VehicleOwner[i], line, s, sizeof(line));
            else if(strcmp(key, "NumberPlate") == 0) strmid(VehicleNumberPlate[i], line, s, sizeof(line));
            else if(strcmp(key, "Value") == 0) VehicleValue[i] = strval(line[s]);
            else if(strcmp(key, "Lock") == 0) VehicleLock[i] = strval(line[s]);
            else if(strcmp(key, "Alarm") == 0) VehicleAlarm[i] = strval(line[s]);
            else if(strcmp(key, "Paintjob") == 0) VehiclePaintjob[i] = strval(line[s]);
            else
            {
                for(new t=0; t < sizeof(VehicleTrunk[]); t++)
                {
                    format(string, sizeof(string), "Trunk%d", t+1);
                    if(strcmp(key, string) == 0) sscanf(line[s], "p,dd", VehicleTrunk[i][t][0], VehicleTrunk[i][t][1]);
                }
                for(new m=0; m < sizeof(VehicleMods[]); m++)
                {
                    format(string, sizeof(string), "Mod%d", m);
                    if(strcmp(key, string) == 0) VehicleMods[i][m] = strval(line[s]);
                }
            }
        }
        fclose(handle);
        if(VehicleCreated[i]) count++;
    }
    printf("  Loaded %d vehicles", count);
}

SaveVehicle(vehicleid)
{
    new filename[64], line[256];
    format(filename, sizeof(filename), VEHICLE_FILE_PATH "v%d.ini", vehicleid);
    new File:handle = fopen(filename, io_write);
    format(line, sizeof(line), "Created=%d\r\n", VehicleCreated[vehicleid]); fwrite(handle, line);
    format(line, sizeof(line), "Model=%d\r\n", VehicleModel[vehicleid]); fwrite(handle, line);
    format(line, sizeof(line), "Pos=%.3f,%.3f,%.3f,%.3f\r\n", VehiclePos[vehicleid][0], VehiclePos[vehicleid][1],
        VehiclePos[vehicleid][2], VehiclePos[vehicleid][3]);
    fwrite(handle, line);
    format(line, sizeof(line), "Colors=%d,%d\r\n", VehicleColor[vehicleid][0], VehicleColor[vehicleid][1]); fwrite(handle, line);
    format(line, sizeof(line), "Interior=%d\r\n", VehicleInterior[vehicleid]); fwrite(handle, line);
    format(line, sizeof(line), "VirtualWorld=%d\r\n", VehicleWorld[vehicleid]); fwrite(handle, line);
    format(line, sizeof(line), "Owner=%s\r\n", VehicleOwner[vehicleid]); fwrite(handle, line);
    format(line, sizeof(line), "NumberPlate=%s\r\n", VehicleNumberPlate[vehicleid]); fwrite(handle, line);
    format(line, sizeof(line), "Value=%d\r\n", VehicleValue[vehicleid]); fwrite(handle, line);
    format(line, sizeof(line), "Lock=%d\r\n", VehicleLock[vehicleid]); fwrite(handle, line);
    format(line, sizeof(line), "Alarm=%d\r\n", VehicleAlarm[vehicleid]); fwrite(handle, line);
    format(line, sizeof(line), "Paintjob=%d\r\n", VehiclePaintjob[vehicleid]); fwrite(handle, line);
    for(new t=0; t < sizeof(VehicleTrunk[]); t++)
    {
        format(line, sizeof(line), "Trunk%d=%d,%d\r\n", t+1, VehicleTrunk[vehicleid][t][0], VehicleTrunk[vehicleid][t][1]);
        fwrite(handle, line);
    }
    for(new m=0; m < sizeof(VehicleMods[]); m++)
    {
        format(line, sizeof(line), "Mod%d=%d\r\n", m, VehicleMods[vehicleid][m]);
        fwrite(handle, line);
    }
    fclose(handle);
}

UpdateVehicle(vehicleid, removeold)
{
    if(VehicleCreated[vehicleid])
    {
        if(removeold)
        {
            new Float:health;
            GetVehicleHealth(VehicleID[vehicleid], health);
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(VehicleID[vehicleid], engine, lights, alarm, doors, bonnet, boot, objective);
            //new panels, doorsd, lightsd, tires;
            //GetVehicleDamageStatus(VehicleID[vehicleid], panels, doorsd, lightsd, tires);
            DestroyVehicle(VehicleID[vehicleid]);
            VehicleID[vehicleid] = CreateVehicle(VehicleModel[vehicleid], VehiclePos[vehicleid][0], VehiclePos[vehicleid][1],
                VehiclePos[vehicleid][2], VehiclePos[vehicleid][3], VehicleColor[vehicleid][0], VehicleColor[vehicleid][1], 3600);
            SetVehicleHealth(VehicleID[vehicleid], health);
            SetVehicleParamsEx(VehicleID[vehicleid], engine, lights, alarm, doors, bonnet, boot, objective);
            //UpdateVehicleDamageStatus(VehicleID[vehicleid], panels, doorsd, lightsd, tires);
        }
        else
        {
            VehicleID[vehicleid] = CreateVehicle(VehicleModel[vehicleid], VehiclePos[vehicleid][0], VehiclePos[vehicleid][1],
                VehiclePos[vehicleid][2], VehiclePos[vehicleid][3], VehicleColor[vehicleid][0], VehicleColor[vehicleid][1], 3600);
        }
        LinkVehicleToInterior(VehicleID[vehicleid], VehicleInterior[vehicleid]);
        SetVehicleVirtualWorld(VehicleID[vehicleid], VehicleWorld[vehicleid]);
        SetVehicleNumberPlate(VehicleID[vehicleid], VehicleNumberPlate[vehicleid]);
        for(new i=0; i < sizeof(VehicleMods[]); i++)
        {
            AddVehicleComponent(VehicleID[vehicleid], VehicleMods[vehicleid][i]);
        }
        ChangeVehiclePaintjob(VehicleID[vehicleid], VehiclePaintjob[vehicleid]);
        if(VehicleLock[vehicleid]) ToggleDoors(VehicleID[vehicleid], VEHICLE_PARAMS_ON);
        if(VehicleAlarm[vehicleid]) VehicleSecurity[VehicleID[vehicleid]] = 1;
        UpdateVehicleLabel(vehicleid, removeold);
    }
}

UpdateVehicleLabel(vehicleid, removeold)
{
    if(VehicleCreated[vehicleid] == VEHICLE_DEALERSHIP)
    {
        if(removeold)
        {
            Delete3DTextLabel(VehicleLabel[vehicleid]);
        }
        new labeltext[128];
        format(labeltext, sizeof(labeltext), "%s\nID: %d\nDealership: %s\nPrice: $%d", VehicleNames[VehicleModel[vehicleid]-400],
            vehicleid, VehicleOwner[vehicleid], VehicleValue[vehicleid]);
        VehicleLabel[vehicleid] = Create3DTextLabel(labeltext, 0xBB7700DD, 0, 0, 0, 10.0, 0);
        Attach3DTextLabelToVehicle(VehicleLabel[vehicleid], VehicleID[vehicleid], 0, 0, 0);
    }
}

IsValidVehicle(vehicleid)
{
    if(vehicleid < 1 || vehicleid >= MAX_DVEHICLES) return 0;
    if(VehicleCreated[vehicleid]) return 1;
    return 0;
}

DealerShips:

pawn Код:
LoadDealerships()
{
    new File:handle, count;
    new filename[64], line[256], s, key[64];
    for(new i=1; i < MAX_DEALERSHIPS; i++)
    {
        format(filename, sizeof(filename), DEALERSHIP_FILE_PATH "d%d.ini", i);
        if(!fexist(filename)) continue;
        handle = fopen(filename, io_read);
        while(fread(handle, line))
        {
            StripNL(line);
            s = strfind(line, "=");
            if(!line[0] || s < 1) continue;
            strmid(key, line, 0, s++);
            if(strcmp(key, "Created") == 0) DealershipCreated[i] = strval(line[s]);
            else if(strcmp(key, "Pos") == 0) sscanf(line[s], "p,fff", DealershipPos[i][0],
                DealershipPos[i][1], DealershipPos[i][2]);
        }
        fclose(handle);
        if(DealershipCreated[i]) count++;
    }
    printf("  Loaded %d dealerships", count);
}

SaveDealership(dealerid)
{
    new filename[64], line[256];
    format(filename, sizeof(filename), DEALERSHIP_FILE_PATH "d%d.ini", dealerid);
    new File:handle = fopen(filename, io_write);
    format(line, sizeof(line), "Created=%d\r\n", DealershipCreated[dealerid]); fwrite(handle, line);
    format(line, sizeof(line), "Pos=%.3f,%.3f,%.3f\r\n", DealershipPos[dealerid][0],
        DealershipPos[dealerid][1], DealershipPos[dealerid][2]);
    fwrite(handle, line);
    fclose(handle);
}

UpdateDealership(dealerid, removeold)
{
    if(DealershipCreated[dealerid])
    {
        if(removeold)
        {
            Delete3DTextLabel(DealershipLabel[dealerid]);
        }
        new labeltext[32];
        format(labeltext, sizeof(labeltext), "Vehicle Dealership\nID: %d", dealerid);
        DealershipLabel[dealerid] = Create3DTextLabel(labeltext, 0x00BB00DD, DealershipPos[dealerid][0],
            DealershipPos[dealerid][1], DealershipPos[dealerid][2]+0.5, 20.0, 0);
    }
}

IsValidDealership(dealerid)
{
    if(dealerid < 1 || dealerid >= MAX_DEALERSHIPS) return 0;
    if(DealershipCreated[dealerid]) return 1;
    return 0;
}
I was thinking this is the problem, but its not.

pawn Код:
public GameModeExitFunc()
{
//  KillTimer(updateplayerpos);
//  KillTimer(djubretartimer);
    KillTimer(maintimer);
    KillTimer(speedotimer);
    KillTimer(savetimer);
        for(new i=0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            OnPlayerDisconnect(i, 1);
        }
    }
    for(new i=1; i < MAX_DVEHICLES; i++)
    {
        if(VehicleCreated[i])
        {
            DestroyVehicle(VehicleID[i]);
            if(VehicleCreated[i] == VEHICLE_DEALERSHIP)
            {
                Delete3DTextLabel(VehicleLabel[i]);
            }
        }
    }
    for(new i=1; i < MAX_DEALERSHIPS; i++)
    {
        if(DealershipCreated[i])
        {
            Delete3DTextLabel(DealershipLabel[i]);
        }
    }
    for(new i=1; i < MAX_FUEL_STATIONS; i++)
    {
        if(FuelStationCreated[i])
        {
            Delete3DTextLabel(FuelStationLabel[i]);
        }
    }
    KillTimer(synctimer);
    KillTimer(newmistimer);
    KillTimer(unjailtimer);
    KillTimer(othtimer);
    KillTimer(cartimer);
    KillTimer(accountstimer);
    KillTimer(checkgastimer);
    KillTimer(idletimer);
    KillTimer(pickuptimer);
    KillTimer(productiontimer);
    KillTimer(stoppedvehtimer);
    KillTimer(turftimer);
    KillTimer(checkcarhealthtimer);
    KillTimer(tracetimer);
    KillTimer(adtimer);
    DestroyMenu(LicensesMenu);
    DestroyMenu(Guide);
    DestroyMenu(JobLocations);
    DestroyMenu(JobLocations2);
    DestroyMenu(JobLocations3);
    TextDrawHideForAll(lbt);
    TextDrawHideForAll(lbb);
    TextDrawDestroy(lbt);
    TextDrawDestroy(lbb);
    KillTimer(CheckStatusTimer);
    TextDrawDestroy(Text:Black0);
    TextDrawDestroy(Text:Black1);
    TextDrawDestroy(Text:Black2);
    TextDrawDestroy(Text:Black3);
    TextDrawDestroy(Text:LightBlack);
    TextDrawDestroy(Text:ProgressBanke);
    foreach (Player, i)
    {
        TextDrawDestroy(Text:VHS[i]);
    }
    GameModeExit();
}
Reply


Messages In This Thread
[DealerShip] Problem with loading cars. - by GBLTeam - 16.03.2013, 08:22

Forum Jump:


Users browsing this thread: 2 Guest(s)