Login Password Check
#8

Try This
pawn Код:
enum pInfo
{
    pPassword,
    pLevel,
    pMoney,
    pArmour,
    pHealth,
    pSkin
}
new gPlayerInfo[MAX_PLAYERS][pInfo];

public OnPlayerRequestClass(playerid, classid)
{
    TogglePlayerSpectating(playerid, 1);
    SpawnPlayer(playerid);
    return 1;
}

public OnPlayerConnect(playerid)
{
    new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), "%s.ini", name);
    if(fexist(file))
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Player Login", "Please Type In Your Password Below:", "Login", "Cancle");
    }
    else
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Player Registration", "Please Type In Your Desired Password Below:", "Register", "Cancle");
    }
    return 1;
}

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));
        INI_WriteFloat(Accfile, "Health", gPlayerInfo[playerid][pHealth]);
        new Float:Armor; GetPlayerArmour(playerid, Armor);
        INI_WriteFloat(Accfile, "Armour",Armor);
        INI_WriteInt(Accfile, "Skin", gPlayerInfo[playerid][pSkin]);
        INI_Close(Accfile);
    }
    return 1;
}

public OnPlayerSpawn(playerid)
{
    TogglePlayerSpectating(playerid, 0);
    SetPlayerPos(playerid,-187.3777,1204.4523,19.6859);
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    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(Acc,"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;
            }
        }
    }
    if(dialogid == 2) //Login
    {
        if(response)
        {
            new name[MAX_PLAYER_NAME], file[256];
            GetPlayerName(playerid, name, sizeof(name));
            INI_ParseFile(file, "LoadUser_%s", .bExtra = true, .extra = playerid);
            format(file, sizeof(file), "%s.ini", name);
            new tmp;
            tmp = gPlayerInfo[playerid][pPassword];
            if(strlen(inputtext) != tmp)
            {
                SendClientMessage(playerid, COLOR_LIGHTRED, "[SYSTEM]: Error Incorrect Password!");
                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]);
            }
        }
    }
    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;
}
Reply


Messages In This Thread
Login Password Check - by Tommy_Mandaz - 18.04.2011, 18:15
Re: Login Password Check - by park4bmx - 18.04.2011, 18:17
Re: Login Password Check - by Tommy_Mandaz - 18.04.2011, 18:21
Re: Login Password Check - by park4bmx - 18.04.2011, 18:23
Re: Login Password Check - by xir - 18.04.2011, 18:25
Re: Login Password Check - by Tommy_Mandaz - 18.04.2011, 18:26
Re: Login Password Check - by Tommy_Mandaz - 18.04.2011, 18:30
Re: Login Password Check - by park4bmx - 18.04.2011, 18:36
Re: Login Password Check - by (SF)Noobanatior - 18.04.2011, 19:16
Re: Login Password Check - by Tommy_Mandaz - 18.04.2011, 19:37

Forum Jump:


Users browsing this thread: 1 Guest(s)