Y_INI Help please!
#1

Hi. I'm having a problem,
when Y_INI writes to files (Saving) he creates another TAG sometimes on one of the files. Which is looks like this:
pawn Код:
[FactionData]
Rank1 = Cadet
[FactionData]
Rank1 = Cadet
Here is the problems:
1.Sometime Y_INI writes to file it creates another same tag, shouldn't it recognize the first tag and rewrite to it?
2.In other files he even erases the loaded data and rewrites empty data. example:

I wrote the above code to the file and expect the Y_INI to load it. and it works well.
Before Saving(writing existed values to files):
pawn Код:
[FactionData]
Rank1 = Cadet
Afterwards Y_INI trying to save the loaded stuff, instead it erases the loaded strings.
After Saving:
pawn Код:
[FactionData]
Rank1 =
When Y_INI empty the data in Rank1 he doesn't create another TAG.
When Loading the file, it loads perfectly.
But saving doesn't going too well.
Loading - OnGameModeInit, Saving - OnGameModeExit.

This is the code of the Saving & Loading. Please look at the problem.

pawn Код:
#define F1PATH "/Factions/LSPD.ini"

enum facInfo
{
    fRank1[32]
}
new FacInfo[MAX_FACTIONS][facInfo];

forward SaveF1();
public SaveF1()
{
    new INI:File = INI_Open(F1PATH);
    INI_SetTag(File,"FactionData");
    INI_WriteString(File, "Rank1", FacInfo[1][fRank1]);
    INI_Close(File);
}

forward LoadLSPD_data(playerid,name[],value[]);
public LoadLSPD_data(playerid,name[],value[])
{
    INI_String("Rank1",FacInfo[1][fRank1],32);
}

stock SaveFactions()
{
    SaveF1();
}

stock LoadFactions()
{
    INI_ParseFile("/Factions/LSPD.ini", "LoadLSPD_data");
}
Reply
#2

Show OnPlayerDisconnect ,and dialog of registration if you have one.
Reply
#3

Quote:
Originally Posted by Galletziz
Посмотреть сообщение
Show OnPlayerDisconnect ,and dialog of registration if you have one.
This isn't user registration / loading problem. The problem is that it doesn't save properly the rank names from FacInfo value to file.
User saving & loading works well. and doesn't related to my problem..
Reply
#4

You have tryd to put a loop on yours stocks functions ?
Anyway you don't open no one INI:file in your stock function.. try to declare, the function INI_Open();
Reply
#5

Quote:
Originally Posted by Galletziz
Посмотреть сообщение
You have tryd to put a loop on yours stocks functions ?
Anyway you don't open no one INI:file in your stock function.. try to declare, the function INI_Open();
Oh right forgot to tell.
I'm using INI_Open and INI_Close I'll add it to the Thread for others to note.

pawn Код:
#define F1PATH "/Factions/LSPD.ini"

forward SaveF1();
public SaveF1()
{
    new INI:File = INI_Open(F1PATH);
    INI_WriteString(File, "Rank1", FacInfo[1][fRank1]);
    INI_Close(File);
}
No, I'm not looping the factions as there only 1 time loading instead of couple of loadings, like houses.
Plus, the loading isn't the problem, i mention it in the thread incase it causes the saving to make problems.
Reply
#6

That's because you never set a tag.
Use INI_SetTag(File, Tag[]).

And for the empty saving problem, it's surely because "FacInfo[1][fRank1]" is empty.
Reply
#7

Quote:
Originally Posted by gtakillerIV
Посмотреть сообщение
That's because you never set a tag.
Use INI_SetTag(File, Tag[]).

And for the empty saving problem, it's surely because "FacInfo[1][fRank1]" is empty.
Ohh Right. Forgot to mention I have set a tag either.. updated the thread.

FacInfo[1][fRank1] is empty. but Its loaded from file under OnGameModeInit. And the saving is working only OnGameModeExit.. Why the saving system doesn't take the loaded value from file and just rewritte it?
Reply
#8

Never mind. Fixed the problem. so stupid to make it saved by public instead on adjustrankname command. plus if i want it to load, then why saving it back instead making it save dynamically in the command itself (alike make-leader).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)