17.09.2014, 12:36
Hello there. I have some questions while loading the variable from player data.
How can i load the variable that have more than one value stored? I mean suppose i have something like this
And while saving the file
It will save the Var1 as Var1 = 5, now my question is, while loading this variable, its only loading 1 not all the values, how can i do that inside INI_ParseFile function? I have tried every possible ways for example:
Same method worked fine for default samp file saving system but with y_ini it don't work for some reason. I have tried looping through MAX_VALUE and set the variable index inside the function while loading but still it either loads nothing or just loads only 1 value, Am i doing some mistake while loading them? If so, can someone explain me how can i do this? Sorry if i couldn't explain my problem very well.
How can i load the variable that have more than one value stored? I mean suppose i have something like this
pawn Code:
#define MAX_VALUE 5
enum E_Enum
{
gVar1[MAX_VALUE],
gVar2
}
new
info[MAX_PLAYERS][E_Enum];
pawn Code:
Save_Var(playerid)
{
new INI:file = INI_Open(filename);
INI_SetTag(file, "data");
for(new i; i < MAX_VALUE; i++)
{
if(info[playerid][gVar1][i] != 0)
INI_WriteInt(file, "Var1", info[playerid][gVar][i]);
}
INI_WriteInt(file, "Var2", info[playerid][gVar2]);
}
pawn Code:
INI_ParseFile("Example.ini", "Load_%s", .bExtra = true, .extra = playerid);
forward Load_data(playerid, name[], value[]);
public Load_data(playerid, name[], value[])
{
new i;
INI_Int("Var1", info[playerid][gVar1][i]);
if(i != 0)
i++;
INI_Int("Var2", info[playerid][gVar2]);
return 1;
}