Y_INI loop while loading
#1

Hello,


I'm trying to load some items with y_ini, I'm using ParseFile to be exact:
pawn Code:
INI_ParseFile(path,"Load_%s", .bExtra = true, .extra = playerid);

pawn Code:
forward Load_Items(playerid,name[],value[]);
public Load_Items(playerid,name[],value[])
{
    new tmp;
    for(new i; i < MAX_ITEMS; i++)
    {
        if(isnull(UsableItems[i])) break;
        INI_Int(UsableItems[i],tmp);
        if(tmp) SetPVarInt(playerid,UsableItems[i],tmp);
    }
    return 1;
}
And because Y_Ini calls the function "LoadItems" on every INI_Int, the loop gets executed three times!
I was loading three items and printed out the i inside the loop, i got this:
pawn Code:
i = 0
i = 0
i = 1
i = 0
i = 1
i = 2
I know that's there's nothing wrong with y_ini but my question is how do I prevent it from loading some stuff multiple times? That's not a problem when there's three items, but what if someday I'll add three hundred?


Another problem(which is probably my error): variable "tmp" is always loaded. My key is correct(i use the same loop to save items).
Reply
#2

I had the same problem when I was trying to load my Races with Yini. I switched to SQL and I am still wondering why this thing happen.
Reply
#3

Well I considered that. But I'm working on an inventory include and YINI seems to be the best option...
Reply
#4

Bump...

I also have the same problem, would be great if someone could explain me how to fix...
Reply
#5

Bump..

I have the same problem...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)