[Y_INI] User File public is not loading
#1

Hey folks,

I've already debugged my code and recognized that my "loadaccount_user" function is not being called.

OnplayerConnect (hooked)
pawn Код:
if(fexist(Path(playerid)))
    {
        INI_ParseFile(Path(playerid), "loadaccount_%s", .bExtra = true, .extra = playerid, .bPassTag = true);
        new pName_[MAX_PLAYER_NAME],
            stringDE_[128],
            stringEN_[128];
        GetPlayerName(playerid, pName_, sizeof(pName_));
        format(stringDE_, sizeof(stringDE_), "Willkommen zurьck, "#C_LIGHT_BLUE_E"%s"#C_DIALOG_E"! Dieser Account ist registriert!\nBitte gib das Passwort fьr diesen Account ein!", pName_);
        format(stringEN_, sizeof(stringEN_), "Welcome back, "#C_LIGHT_BLUE_E"%s"#C_DIALOG_E"! This account is registered!\nPlease type in the password for this account!", pName_);
        ShowLanguageDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Login", stringDE_, stringEN_, "Einloggen", "Log in", "Abbrechen", "Cancel");
    }
    else ShowPlayerDialog(playerid, DIALOG_LANGUAGES, DIALOG_STYLE_LIST, "Sprachauswahl | Language Selection", "[GER] Deutsch | German\n[ENG] Englisch | English", "OK", "");
OnPlayerDisconnect (hooked)
pawn Код:
print("OnPlayerDisconnect executed.");
    new INI:file = INI_Open(Path(playerid));
    INI_SetTag(file, "User Data");
    INI_WriteString(file, "IP", pInfo[playerid][IP]);
    INI_WriteInt(file, "AdminLevel", pInfo[playerid][AdminLevel]);
    INI_WriteInt(file, "Money", GetPlayerMoney(playerid));
    INI_WriteInt(file, "Bank", pInfo[playerid][Bank]);
    INI_WriteInt(file, "Score", GetPlayerScore(playerid));
    INI_WriteInt(file, "Kills", pInfo[playerid][Kills]);
    INI_WriteInt(file, "Deaths", pInfo[playerid][Deaths]);
    INI_WriteInt(file, "Language", pInfo[playerid][Language]);
    INI_Close(file);
Function for loading the user file
pawn Код:
forward loadaccount_user(playerid, name[], value[]);
public loadaccount_user(playerid, name[], value[])
{
    print("loadaccount_user executed.");
    INI_String("Password", pInfo[playerid][Password], 129);
    INI_String("IP", pInfo[playerid][IP], 16);
    INI_Int("AdminLevel", pInfo[playerid][AdminLevel]);
    INI_Int("Money", pInfo[playerid][Money]);
    INI_Int("Bank", pInfo[playerid][Bank]);
    INI_Int("Score", pInfo[playerid][Score]);
    INI_Int("Kills", pInfo[playerid][Kills]);
    INI_Int("Deaths", pInfo[playerid][Deaths]);
    INI_Int("Language", pInfo[playerid][Language]);
    return 1;
}
------------------------------------------------------------------------------------------------------------------

Additionally, no data is being saved even though OnPlayerDisconnect (hooked) is being called.

pawn Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerColor(playerid, C_BLUE);

    new VirtualWorld = GetPlayerVirtualWorld(playerid);
    switch(VirtualWorld)
    {
        case 0:
        {
            if(pInfo[playerid][JustLoggedIn] == true)
            {
                print("JustLoggedIn == true");
                SetCameraBehindPlayer(playerid);
                GivePlayerMoneyEx(playerid, pInfo[playerid][Money]);
                SetPlayerScore(playerid, pInfo[playerid][Score]);
                UseTeleports[playerid] = true;
                SetSpawnProtection(playerid);
                pInfo[playerid][JustLoggedIn] = false;
                return 1;
            }
            if(pInfo[playerid][JustRegistered] == true)
            {
                print("JustRegistered == true");
                cmd_rules(playerid, "");
                pInfo[playerid][JustRegistered] = false;
                GivePlayerMoneyEx(playerid, 5000);
                return 1;
            }
            if(pInfo[playerid][JustLoggedIn] == false && pInfo[playerid][JustRegistered] == false)
            {
                print("Common spawn");
                GivePlayerMoneyEx(playerid, 5000);
                UseTeleports[playerid] = true;
                SetSpawnProtection(playerid);
                return 1;
            }
        }
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    SendDeathMessage(killerid, playerid, reason);
   
    new cash = GetPlayerMoney(playerid);
    if(killerid != INVALID_PLAYER_ID) //Killed by another player
    {
        print("killerid != INVALID_PLAYER_ID, executing code.");
        GivePlayerMoneyEx(killerid, cash);
        GivePlayerMoneyEx(playerid, -cash);
        SetPlayerScore(killerid, pInfo[killerid][Score] + 1);
        pInfo[killerid][Kills] += 1;
    }
    if(killerid == INVALID_PLAYER_ID) //Suicide
    {
        print("killerid == INVALID_PLAYER_ID, executing code.");
        GivePlayerMoneyEx(playerid, -cash);
    }
    pInfo[playerid][Deaths] += 1;
    return 1;
}
Reply
#2

You can't have spaces between texts.
In you INI_SetTag, you've left some space between 2 words.
Make it as User_Data
Reply
#3

Thanks for that piece of advise, but that doesn't change anything concerning my actual problem...
I tried to modify the userdata manually, but everytime I connect to the server, the data is being resetted.

EDIT: It might be worth mentioning that I'm using y_ini from YSI 4.0 beta. As far as I recall, the exact same code worked under the previous YSI version, so it might be a 4.0 issue?
Reply
#4

Silly me.
I must have seen ghosts. -.- Thanks a lot for helping me out, Alex!
Reply
#5

Update: I am a 100% sure that my code worked with the previous YSI version. I followed this (https://sampforum.blast.hk/showthread.php?tid=352703) tutorial here, and it worked out very well, even though the "user" did not match the tag of the file.

For some reason, if I try to edit a user file manually, everything is being resetted. The only thing that (I think) is being displayed is the number of deaths. I'm going to post some more code later!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)