Y_INI Loading Help
#1

I'm having trouble getting my Biz.ini to load properly. First, here is the code.
pawn Code:
//Called under OnGamemodeInit:
INI_ParseFile(BizFile, "ini_load_biz", .bPassTag = true);

// Loading Function:
forward ini_load_biz(bid, tag[], name[], value[]);
public ini_load_biz(bid, tag[], name[], value[])
{
    new idx = strval(tag);
    INI_String("Owner", BizInfo[idx][Owner], 24);
    INI_String("Name", BizInfo[idx][bName], 32);
    INI_Int("Price", BizInfo[idx][Price]);
    INI_Int("Bank", BizInfo[idx][Bank]);
    INI_Int("Locked", BizInfo[idx][Bank]);
    INI_Int("Interior", BizInfo[idx][Interior]);
    INI_Int("World", BizInfo[idx][World]);
    INI_Float("IntX", BizInfo[idx][IntX]);
    INI_Float("IntY", BizInfo[idx][IntY]);
    INI_Float("IntZ", BizInfo[idx][IntZ]);
    INI_Float("ExtX", BizInfo[idx][ExtX]);
    INI_Float("ExtY", BizInfo[idx][ExtY]);
    INI_Float("ExtZ", BizInfo[idx][ExtZ]);
    printf("%i", BizInfo[idx][Price]);
    return 1;
}
The print displays 13 lines of 0's, which is the wrong value and there is only 1 entry in the file.
I've tried different combinations of loops and strval(tag), etc and can't get any successful loads. Thanks in advance.
Reply
#2

you are saving the file again you need to do something like
pawn Code:
stock LoadPlayer(playerid){
    new name[MAX_PLAYER_NAME],file[128];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file),USER_BASE, name);
    INI_ParseFile(file, "LoginAcc", false, true, playerid, true, false);
   
}

forward LoginAcc(playerid, name[ ], value[ ]);
public LoginAcc(playerid, name[ ], value[ ])
{
    if(!strcmp(name, "Password", false))    SetPVarString(playerid, "Password",     value);
    if(!strcmp(name, "TimesLogged", false)) SetPVarInt(playerid,    "TimesLogged"strval(value)+1);
    if(!strcmp(name, "FailedLog", false))   SetPVarInt(playerid,    "FailedLog",    strval(value));
    return 1;
}
Reply
#3

No, INI_Int for example loads an integer, not saves. INI_WriteInt would write it.
Reply
#4

Is it me or can an INI_ParseFile only be called once during a whole server session?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)