Problem with Y_INI saving and loading
#1

Loading code:
pawn Код:
LoadDealerships() {

    if(!fexist("Dealerships.cfg")) return 1;

    new
        szFileStr[1024],
        File: iFileHandle = fopen("Dealerships.cfg", io_read),
        iIndex;

    while(iIndex < MAX_CARDEALERSHIPS && fread(iFileHandle, szFileStr)) {
        if(!sscanf(szFileStr, "p<|>ds[32]dfffd",
            CarDealer[iIndex][pOwned],
            CarDealer[iIndex][pOwner],
            CarDealer[iIndex][pPrice],
            CarDealer[iIndex][pVehicleSpawnX],
            CarDealer[iIndex][pVehicleSpawnY],
            CarDealer[iIndex][pVehicleSpawnZ],
            CarDealer[iIndex][pLocked])) {

            if(!isnull(CarDealer[iIndex][pOwner])) format(szFileStr, sizeof(szFileStr), "{4BB325}Vehicle Dealership\n{C4C920}[Owner: %s]\n[Price: $%d]\n\n[ID: %d]",  CarDealer[iIndex][pOwner], CarDealer[iIndex][pPrice], iIndex);
            else format(szFileStr, sizeof(szFileStr), "{4BB325}Vehicle Dealership\n{C4C920}[Owner: None(/buydealer)]\n[Price: $%d]\n\n[ID: %d]", CarDealer[iIndex][pPrice], iIndex);

            CarDealer[iIndex][pPickUp] = CreateDynamicPickup(1272, 23, CarDealer[iIndex][pVehicleSpawnX], CarDealer[iIndex][pVehicleSpawnY], CarDealer[iIndex][pVehicleSpawnZ], .worldid = 0, .interiorid = 0);
            CarDealer[iIndex][pLabel] = Create3DTextLabel(szFileStr, COLOR_WHITE, CarDealer[iIndex][pVehicleSpawnX], CarDealer[iIndex][pVehicleSpawnY], CarDealer[iIndex][pVehicleSpawnZ] + 0.5, 10.0, 0,0);
            ++iIndex;
        }
    }
    return fclose(iFileHandle);
}
Saving code:
pawn Код:
SaveDealerships() {

    new
        szFileStr[1024],
        File: fHandle = fopen("Dealerships.cfg", io_write);

    for(new iIndex; iIndex < MAX_CARDEALERSHIPS; iIndex++) {
        format(szFileStr, sizeof(szFileStr),"%d|%s|$%d|%f.2|%f.2|%f.2|%d\r\n",
            CarDealer[iIndex][pOwned],
            CarDealer[iIndex][pOwner],
            CarDealer[iIndex][pPrice],
            CarDealer[iIndex][pVehicleSpawnX],
            CarDealer[iIndex][pVehicleSpawnY],
            CarDealer[iIndex][pVehicleSpawnZ],
            CarDealer[iIndex][pLocked]
        );
        fwrite(fHandle, szFileStr);
    }
    fclose(fHandle);
    return 1;
}
Whenever I buy a dealership and what not, it will save and show my name and the co-ordinates, but after I restart the server and go to the place I made it, its gone and when I place another dealership after the restart it resets the other one
Reply
#2

pawn Код:
%f, not %f.2
Reply
#3

Didn't fix it ;/
Reply
#4

pawn Код:
"%d|%s|%d|%f|%f|%f|%d\r\n",
Reply
#5

Quote:
Originally Posted by Glad2BeHere
Посмотреть сообщение
pawn Код:
"%d|%s|%d|%f|%f|%f|%d\r\n",
Didn't make a difference
Reply
#6

post enum,save,load in 1 plz
Reply
#7

Quote:

enum eCarDealer
{
pOwned,
pOwner[MAX_PLAYER_NAME],
Text3D: pLabel,
pPrice,
Float: pVehicleSpawn[4],
pLocked,
pPickUp
};

Loading code:
pawn Код:
LoadDealerships() {

    if(!fexist("Dealerships.cfg")) return 1;

    new
        szFileStr[1024],
        File: iFileHandle = fopen("Dealerships.cfg", io_read),
        iIndex;

    while(iIndex < MAX_CARDEALERSHIPS && fread(iFileHandle, szFileStr)) {
        if(!sscanf(szFileStr, "p<|>ds[32]dfffd",
            CarDealer[iIndex][pOwned],
            CarDealer[iIndex][pOwner],
            CarDealer[iIndex][pPrice],
            CarDealer[iIndex][pVehicleSpawnX],
            CarDealer[iIndex][pVehicleSpawnY],
            CarDealer[iIndex][pVehicleSpawnZ],
            CarDealer[iIndex][pLocked])) {

            if(!isnull(CarDealer[iIndex][pOwner])) format(szFileStr, sizeof(szFileStr), "{4BB325}Vehicle Dealership\n{C4C920}[Owner: %s]\n[Price: $%d]\n\n[ID: %d]",  CarDealer[iIndex][pOwner], CarDealer[iIndex][pPrice], iIndex);
            else format(szFileStr, sizeof(szFileStr), "{4BB325}Vehicle Dealership\n{C4C920}[Owner: None(/buydealer)]\n[Price: $%d]\n\n[ID: %d]", CarDealer[iIndex][pPrice], iIndex);

            CarDealer[iIndex][pPickUp] = CreateDynamicPickup(1272, 23, CarDealer[iIndex][pVehicleSpawnX], CarDealer[iIndex][pVehicleSpawnY], CarDealer[iIndex][pVehicleSpawnZ], .worldid = 0, .interiorid = 0);
            CarDealer[iIndex][pLabel] = Create3DTextLabel(szFileStr, COLOR_WHITE, CarDealer[iIndex][pVehicleSpawnX], CarDealer[iIndex][pVehicleSpawnY], CarDealer[iIndex][pVehicleSpawnZ] + 0.5, 10.0, 0,0);
            ++iIndex;
        }
    }
    return fclose(iFileHandle);
}
Saving code:
pawn Код:
SaveDealerships() {

    new
        szFileStr[1024],
        File: fHandle = fopen("Dealerships.cfg", io_write);

    for(new iIndex; iIndex < MAX_CARDEALERSHIPS; iIndex++) {
        format(szFileStr, sizeof(szFileStr),"%d|%s|$%d|%f.2|%f.2|%f.2|%d\r\n",
            CarDealer[iIndex][pOwned],
            CarDealer[iIndex][pOwner],
            CarDealer[iIndex][pPrice],
            CarDealer[iIndex][pVehicleSpawnX],
            CarDealer[iIndex][pVehicleSpawnY],
            CarDealer[iIndex][pVehicleSpawnZ],
            CarDealer[iIndex][pLocked]
        );
        fwrite(fHandle, szFileStr);
    }
    fclose(fHandle);
    return 1;
}
Reply
#8

pawn Код:
enum eCarDealer
{
pOwned,
pOwner[MAX_PLAYER_NAME],
Text3D: pLabel,
pPrice,
Float: pVehicleSpawn[4],
pLocked,
pPickUp
}
new CarDealer[MAX_PLAYERS][eCarDealer];
Reply
#9

Quote:
Originally Posted by Glad2BeHere
Посмотреть сообщение
pawn Код:
enum eCarDealer
{
pOwned,
pOwner[MAX_PLAYER_NAME],
Text3D: pLabel,
pPrice,
Float: pVehicleSpawn[4],
pLocked,
pPickUp
}
new CarDealer[MAX_PLAYERS][eCarDealer];
Already got that ^

Its something to do with the loading code
Reply
#10

the whole thing is just wrong :/ srry u going to redo the whole thing from scratch = after the enum inbox for personal help k
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)