Problem with Y_INI saving and loading
#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


Messages In This Thread
Problem with Y_INI saving and loading - by mSlat3r - 06.11.2012, 15:15
Re: Problem with Y_INI saving and loading - by Glad2BeHere - 06.11.2012, 16:10
Re: Problem with Y_INI saving and loading - by mSlat3r - 06.11.2012, 16:29
Re: Problem with Y_INI saving and loading - by Glad2BeHere - 06.11.2012, 16:39
Re: Problem with Y_INI saving and loading - by mSlat3r - 06.11.2012, 16:44
Re: Problem with Y_INI saving and loading - by Glad2BeHere - 06.11.2012, 16:46
Re: Problem with Y_INI saving and loading - by mSlat3r - 07.11.2012, 04:36
Re: Problem with Y_INI saving and loading - by Glad2BeHere - 07.11.2012, 05:16
Re: Problem with Y_INI saving and loading - by mSlat3r - 07.11.2012, 05:25
Re: Problem with Y_INI saving and loading - by Glad2BeHere - 07.11.2012, 05:29

Forum Jump:


Users browsing this thread: 1 Guest(s)