Y_INI loop while loading - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Y_INI loop while loading (
/showthread.php?tid=473278)
Y_INI loop while loading -
dusk - 02.11.2013
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).
Re: Y_INI loop while loading -
]Rafaellos[ - 02.11.2013
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.
Re: Y_INI loop while loading -
dusk - 02.11.2013
Well I considered that. But I'm working on an inventory include and YINI seems to be the best option...
Re: Y_INI loop while loading -
Kimossab - 20.12.2013
Bump...
I also have the same problem, would be great if someone could explain me how to fix...
Re: Y_INI loop while loading -
blackeagle1122 - 30.03.2014
Bump..
I have the same problem...