saving system
#3

Yes thats like this
pawn Код:
// -------------------------------------------------------------------------- //
enum hInfo {
    hOwned,
    hPrice,
    hOwner[128],
    hLevel,
    hLocked,
    hRentable,
    hRentPrice,
    hGun1,
    hGun2,
    hGun3,
    hMoney,
    Float:hEntranceX,
    Float:hEntranceY,
    Float:hEntranceZ,
    Float:hEntranceA,
    Float:hExitX,
    Float:hExitY,
    Float:hExitZ,
    Float:hExitA,
    hInt,
    hWorld,
    hInsideInt,
    hInsideWorld,
    hInsideIcon,
    hOutsideIcon
}
new HouseInfo[200][hInfo];

public LoadHouses()
{
    new arrCoords[23][64];
    new strFromFile2[256];
    new File: file = fopen("Houses.cfg", io_read);
    if (file)
    {
        new idx;
        while (idx < sizeof(HouseInfo))
        {
            fread(file, strFromFile2);
            split(strFromFile2, arrCoords, '|');
            HouseInfo[idx][hOwned] = strval(arrCoords[0]);
            HouseInfo[idx][hPrice] = strval(arrCoords[1]);
            strmid(HouseInfo[idx][hOwner], arrCoords[2], 0, strlen(arrCoords[2]), 255);
            HouseInfo[idx][hLevel] = strval(arrCoords[3]);
            HouseInfo[idx][hLocked] = strval(arrCoords[4]);
            HouseInfo[idx][hRentable] = strval(arrCoords[5]);
            HouseInfo[idx][hRentPrice] = strval(arrCoords[6]);
            HouseInfo[idx][hGun1] = strval(arrCoords[7]);
            HouseInfo[idx][hGun2] = strval(arrCoords[8]);
            HouseInfo[idx][hGun3] = strval(arrCoords[9]);
            HouseInfo[idx][hMoney] = strval(arrCoords[10]);
            HouseInfo[idx][hEntranceX] = floatstr(arrCoords[11]);
            HouseInfo[idx][hEntranceY] = floatstr(arrCoords[12]);
            HouseInfo[idx][hEntranceZ] = floatstr(arrCoords[13]);
            HouseInfo[idx][hEntranceA] = floatstr(arrCoords[14]);
            HouseInfo[idx][hExitX] = floatstr(arrCoords[15]);
            HouseInfo[idx][hExitY] = floatstr(arrCoords[16]);
            HouseInfo[idx][hExitZ] = floatstr(arrCoords[17]);
            HouseInfo[idx][hExitA] = floatstr(arrCoords[18]);
            HouseInfo[idx][hInt] = strval(arrCoords[19]);
            HouseInfo[idx][hWorld] = strval(arrCoords[20]);
            HouseInfo[idx][hInsideInt] = strval(arrCoords[21]);
            HouseInfo[idx][hInsideWorld] = strval(arrCoords[22]);
            if(HouseInfo[idx][hOutsideIcon]) DestroyDynamicPickup(HouseInfo[idx][hOutsideIcon]);
            if(HouseInfo[idx][hInsideIcon]) DestroyDynamicPickup(HouseInfo[idx][hInsideIcon]);
            HouseInfo[idx][hOutsideIcon] = CreateDynamicPickup(1273, 1, HouseInfo[idx][hEntranceX], HouseInfo[idx][hEntranceY], HouseInfo[idx][hEntranceZ], HouseInfo[idx][hWorld]);
            HouseInfo[idx][hInsideIcon] = CreateDynamicPickup(1273, 1, HouseInfo[idx][hExitX], HouseInfo[idx][hExitY], HouseInfo[idx][hExitZ], HouseInfo[idx][hInsideWorld]);
            idx++;
           
        }
        fclose(file);
    }
    return 1;
}

public SaveHouses()
{
    new idx;
    new File: file2;
    while (idx < sizeof(HouseInfo))
    {
        new coordsstring[512];
        format(coordsstring, sizeof(coordsstring), "%d|%d|%s|%d|%d|%d|%d|%d|%d|%d|%d|%f|%f|%f|%f|%f|%f|%f|%f|%d|%d|%d|%d\r\n",
        HouseInfo[idx][hOwned],
        HouseInfo[idx][hPrice],
        HouseInfo[idx][hOwner],
        HouseInfo[idx][hLevel],
        HouseInfo[idx][hLocked],
        HouseInfo[idx][hRentable],
        HouseInfo[idx][hRentPrice],
        HouseInfo[idx][hGun1],
        HouseInfo[idx][hGun2],
        HouseInfo[idx][hGun3],
        HouseInfo[idx][hMoney],
        HouseInfo[idx][hEntranceX],
        HouseInfo[idx][hEntranceY],
        HouseInfo[idx][hEntranceZ],
        HouseInfo[idx][hEntranceA],
        HouseInfo[idx][hExitX],
        HouseInfo[idx][hExitY],
        HouseInfo[idx][hExitZ],
        HouseInfo[idx][hExitA],
        HouseInfo[idx][hInt],
        HouseInfo[idx][hWorld],
        HouseInfo[idx][hInsideInt],
        HouseInfo[idx][hInsideWorld]);
        if(idx == 0)
        {
            file2 = fopen("Houses.cfg", io_write);
        }
        else
        {
            file2 = fopen("Houses.cfg", io_append);
        }
        fwrite(file2, coordsstring);
        idx++;
        fclose(file2);
    }
    return 1;
}
Reply


Messages In This Thread
saving system - by Dare Devil..... - 26.07.2012, 09:37
Re: saving system - by Devilxz97 - 26.07.2012, 09:47
Re: saving system - by Dare Devil..... - 26.07.2012, 10:07
Re: saving system - by Dare Devil..... - 26.07.2012, 12:06
Re: saving system - by Dare Devil..... - 26.07.2012, 20:13
Re: saving system - by Ranama - 26.07.2012, 20:20
Re: saving system - by Jeffry - 26.07.2012, 20:21
Re: saving system - by Dare Devil..... - 26.07.2012, 21:04
Re: saving system - by Dare Devil..... - 27.07.2012, 09:39

Forum Jump:


Users browsing this thread: 1 Guest(s)