HOuse saving(Y_INI)
#1

Hey,

Sorry to bother you guys but I am having trouble with the saving of my houses

I save them as such..

pawn Код:
#define HOUSE_PATH "/Houses/%s.ini"

stock HousePath()
{
    new string[128], houseid = HouseCount;
    format(string,sizeof(string),HOUSE_PATH, houseid);
    return string;
}

forward SaveHouses();
public SaveHouses()
{
    for(new i=0;i<MAX_HOUSES;i++)
    {
        new INI:File = INI_Open(HousePath());
        INI_SetTag(File, "Main");
        INI_WriteInt(File, "Price", HouseInfo[i][hPrice]);
        INI_WriteString(File, "Owner", HouseInfo[i][hOwner]);
        INI_WriteFloat(File, "EnterX", HouseInfo[i][hEnterX]);
        INI_WriteFloat(File, "EnterY", HouseInfo[i][hEnterY]);
        INI_WriteFloat(File, "EnterZ", HouseInfo[i][hEnterZ]);
        INI_WriteFloat(File, "ExitX", HouseInfo[i][hExitX]);
        INI_WriteFloat(File, "ExitY", HouseInfo[i][hExitY]);
        INI_WriteFloat(File, "ExitZ", HouseInfo[i][hExitZ]);
        INI_WriteInt(File, "Interior", HouseInfo[i][hInt]);
        INI_Close(File);
     }
}
I have the folder I save the houses and I goto the folder and nothing...
Thanks Snowman
Reply
#2

Sorry for early bump but the problem still occurs
Reply
#3

isnt house count an int? so it should be %d...

and it saves the last house all the time
Reply
#4

Yeah, I dont fully understand how I can mke it work with Y_INI though?
Reply
#5

Can anyone give me and Example?
Reply
#6

pawn Код:
#define HOUSE_PATH "/Houses/%d.ini"

stock HousePath(houseid)
{
    new string[128];
    format(string,sizeof(string),HOUSE_PATH, houseid);
    return string;
}

forward SaveHouses();
public SaveHouses()
{
    for(new i=0;i<MAX_HOUSES;i++)
    {
        new INI:File = INI_Open(HousePath(i));
        INI_SetTag(File, "Main");
        INI_WriteInt(File, "Price", HouseInfo[i][hPrice]);
        INI_WriteString(File, "Owner", HouseInfo[i][hOwner]);
        INI_WriteFloat(File, "EnterX", HouseInfo[i][hEnterX]);
        INI_WriteFloat(File, "EnterY", HouseInfo[i][hEnterY]);
        INI_WriteFloat(File, "EnterZ", HouseInfo[i][hEnterZ]);
        INI_WriteFloat(File, "ExitX", HouseInfo[i][hExitX]);
        INI_WriteFloat(File, "ExitY", HouseInfo[i][hExitY]);
        INI_WriteFloat(File, "ExitZ", HouseInfo[i][hExitZ]);
        INI_WriteInt(File, "Interior", HouseInfo[i][hInt]);
        INI_Close(File);
     }
}
a few fixes
Reply
#7

Just edited and tryed the system out with your edits and the houses still dont save.

The function is called under OnGameModeExit()

However there is no files in the folder

I get a error in the log..


[20:29:24] *** YSI Error: INI_Open could not find or create file /Houses/.ini
Reply
#8

pawn Код:
#define HOUSE_PATH "/Houses/%d.ini"

stock HousePath(houseid)
{
    new string[128];
    format(string,sizeof(string),HOUSE_PATH, houseid);
    return string;
}

forward SaveHouses();
public SaveHouses()
{
    for(new i=0;i<MAX_HOUSES;i++)
    {
        new INI:File = INI_Open(HousePath(i));
        if(File == INI_NO_FILE)
        {
            dini_Create(HousePath(i));
            INI:File=INI_Open(HousePath(i));
        }
        INI_SetTag(File, "Main");
        INI_WriteInt(File, "Price", HouseInfo[i][hPrice]);
        INI_WriteString(File, "Owner", HouseInfo[i][hOwner]);
        INI_WriteFloat(File, "EnterX", HouseInfo[i][hEnterX]);
        INI_WriteFloat(File, "EnterY", HouseInfo[i][hEnterY]);
        INI_WriteFloat(File, "EnterZ", HouseInfo[i][hEnterZ]);
        INI_WriteFloat(File, "ExitX", HouseInfo[i][hExitX]);
        INI_WriteFloat(File, "ExitY", HouseInfo[i][hExitY]);
        INI_WriteFloat(File, "ExitZ", HouseInfo[i][hExitZ]);
        INI_WriteInt(File, "Interior", HouseInfo[i][hInt]);
        INI_Close(File);
     }
}
You need dini this time ;o
Reply
#9

Just remove your first forward slash!

pawn Код:
#define HOUSE_PATH "Houses/%d.ini"
It's not going to save anywhere else but inside the scriptfiles folder! Make sure you have a folder called "Houses" inside your scriptfiles directory.
Reply
#10

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
Just remove your first forward slash!

pawn Код:
#define HOUSE_PATH "Houses/%d.ini"
It's not going to save anywhere else but inside the scriptfiles folder! Make sure you have a folder called "Houses" inside your scriptfiles directory.
dont think it normally matters o.0
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)