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


Messages In This Thread
Y_INI loop while loading - by dusk - 02.11.2013, 09:37
Re: Y_INI loop while loading - by ]Rafaellos[ - 02.11.2013, 10:06
Re: Y_INI loop while loading - by dusk - 02.11.2013, 11:44
Re: Y_INI loop while loading - by Kimossab - 20.12.2013, 18:29
Re: Y_INI loop while loading - by blackeagle1122 - 30.03.2014, 12:23

Forum Jump:


Users browsing this thread: 1 Guest(s)