SA-MP Forums Archive
Loading Playerfile - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Loading Playerfile (/showthread.php?tid=249466)



Loading Playerfile - Tommy_Mandaz - 19.04.2011

Why isnt this loading the things I want it to?

pawn Код:
if(dialogid == 2) //Login
    {
        if(response)
        {
            new name[MAX_PLAYER_NAME], file[256];
            GetPlayerName(playerid, name, sizeof(name));
            INI_ParseFile(file, "LoadUser", .bExtra = true, .extra = playerid);
            format(file, sizeof(file), "%s.ini", name);
            if(strcmp(inputtext, gPlayerInfo[playerid][pPassword], false))
            {
                SendClientMessage(playerid, COLOR_LIGHTRED, "[SYSTEM]: Error Incorrect Password!");
                TogglePlayerSpectating(playerid, 1);
                ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Player Login", "Please Type In Your Password Below:", "Login", "Cancle");
            }
            else
            {
                SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1);
                SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 1);
                SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 1);
                SetPlayerScore(playerid, gPlayerInfo[playerid][pLevel]);
                GivePlayerMoney(playerid, gPlayerInfo[playerid][pMoney]);
                SetPlayerSkin(playerid, gPlayerInfo[playerid][pSkin]);
                SetPlayerHealth(playerid, gPlayerInfo[playerid][pHealth]);
                SetPlayerArmour(playerid, gPlayerInfo[playerid][pArmour]);
                TogglePlayerSpectating(playerid, 0);
            }
        }
    }
    return 1;
}

public LoadUser(playerid, name[], value[])
{
    INI_Int("Password", gPlayerInfo[playerid][pPassword]);
    INI_Int("Level", gPlayerInfo[playerid][pLevel]);
    INI_Int("Money", gPlayerInfo[playerid][pMoney]);
    INI_Int("Skin", gPlayerInfo[playerid][pSkin]);
    INI_Int("Health", gPlayerInfo[playerid][pHealth]);
    INI_Int("Armour", gPlayerInfo[playerid][pArmour]);
    return 1;
}



AW: Loading Playerfile - Nero_3D - 19.04.2011

Quote:
Originally Posted by Tommy_Mandaz
Посмотреть сообщение
Why isnt this loading the things I want it to?

pawn Код:
INI_Int("Password", gPlayerInfo[playerid][pPassword]);
INI_Int("Health", gPlayerInfo[playerid][pHealth]);
INI_Int("Armour", gPlayerInfo[playerid][pArmour]);
You sure that password, health and armour are normal integers ?


Re: Loading Playerfile - Tommy_Mandaz - 19.04.2011

This is how I saved them not sure:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new name[MAX_PLAYER_NAME], playerfile[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(playerfile, sizeof(playerfile), "%s.ini", name);
    {
        new INI:Accfile = INI_Open(playerfile);
        INI_WriteInt(Accfile, "Level", gPlayerInfo[playerid][pLevel]);
        INI_WriteInt(Accfile, "Money", GetPlayerMoney(playerid));
        INI_WriteInt(Accfile, "Money",GetPlayerMoney(playerid));
        new Float:Health; GetPlayerArmour(playerid, Health);
        INI_WriteFloat(Accfile, "Health", Health);
        new Float:Armor; GetPlayerArmour(playerid, Armor);
        INI_WriteFloat(Accfile, "Armour",Armor);
        INI_WriteInt(Accfile, "Skin", gPlayerInfo[playerid][pSkin]);
        INI_Close(Accfile);
    }
    return 1;
}
Here is the password save:

pawn Код:
if(dialogid == 1) //Register
    {
        if(response)
        {
            new name[MAX_PLAYER_NAME], files[256];
            GetPlayerName(playerid, name, sizeof(name));
            format(files, sizeof(files), "%s.ini", name);
            {
                new INI:file = INI_Open(files);
                INI_WriteString(file, "Password", inputtext);
                INI_WriteInt(file, "Level", 1);
                gPlayerInfo[playerid][pLevel] = 1;
                SetPlayerScore(playerid,1);
                INI_WriteInt(file, "Money", 5000);
                gPlayerInfo[playerid][pMoney] = 5000;
                GivePlayerMoney(playerid,5000);
                INI_WriteInt(file, "Health", 100);
                gPlayerInfo[playerid][pHealth] = 100;
                SetPlayerHealth(playerid,100);
                INI_WriteInt(file, "Armour", 0);
                gPlayerInfo[playerid][pArmour] = 0;
                SetPlayerArmour(playerid,0);
                INI_WriteInt(file, "Skin", 26);
                gPlayerInfo[playerid][pSkin] = 26;
                SetPlayerSkin(playerid,26);
                INI_Close(file);
                return 1;
            }
        }
    }



Re: Loading Playerfile - blackwave - 19.04.2011

pawn Код:
INI_ParseFile(file, "LoadUser", .bExtra = true, .extra = playerid);
            format(file, sizeof(file), "%s.ini", name);
By what I see you've formated the file after parsing, which wouldn't generate anything. So, wouldn't be that?

pawn Код:
format(file, sizeof(file), "%s.ini", name);
INI_ParseFile(file, "LoadUser", .bExtra = true, .extra = playerid);

And for password, it had to be a string. Try formatting file before parsing


Re: Loading Playerfile - Tommy_Mandaz - 19.04.2011

okay can you tell me what to change im new to yini thanks


Re: Loading Playerfile - blackwave - 19.04.2011

pawn Код:
if(dialogid == 2) //Login
    {
        if(response)
        {
            new name[MAX_PLAYER_NAME], file[256];
            GetPlayerName(playerid, name, sizeof(name));
            format(file, sizeof(file), "%s.ini", name);
            INI_ParseFile(file, "LoadUser", .bExtra = true, .extra = playerid);
            if(strcmp(inputtext, gPlayerInfo[playerid][pPassword], false))
            {
                SendClientMessage(playerid, COLOR_LIGHTRED, "[SYSTEM]: Error Incorrect Password!");
                TogglePlayerSpectating(playerid, 1);
                ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Player Login", "Please Type In Your Password Below:", "Login", "Cancle");
            }
            else
            {
                SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1);
                SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 1);
                SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 1);
                SetPlayerScore(playerid, gPlayerInfo[playerid][pLevel]);
                GivePlayerMoney(playerid, gPlayerInfo[playerid][pMoney]);
                SetPlayerSkin(playerid, gPlayerInfo[playerid][pSkin]);
                SetPlayerHealth(playerid, gPlayerInfo[playerid][pHealth]);
                SetPlayerArmour(playerid, gPlayerInfo[playerid][pArmour]);
                TogglePlayerSpectating(playerid, 0);
            }
        }
    }
    return 1;
}