Saving Accounts
#3

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_GREY"Registering...",""COL_GREY"You have entered an invalid {FF6347}password{B4B5B7}.\n"COL_GREY"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"VIP",0);
                INI_WriteInt(File,"Wanted",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"Jailed",0);
                INI_WriteInt(File,"Muted",0);
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Score",0);
                INI_WriteInt(File,"Banned",0);
                INI_Close(File);

            }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_LGREEN"Success",""COL_LGREEN"You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_GREY"Login",""COL_GREY"You have entered an incorrect {FF6347}password{B4B5B7}.\n"COL_GREY"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}
/******************************************************************************/
/**********************************< STOCKS >**********************************/
stock UserPath(playerid)
{
    new string[1000],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(IsBeingSpeced[playerid] == 1)
    {
        foreach(Player,i)
        {
            if(spectatorid[i] == playerid)
            {
                TogglePlayerSpectating(i, 0);
            }
        }
    }
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"VIP",PlayerInfo[playerid][pVIP]);
    INI_WriteInt(File,"Wanted",GetPlayerWantedLevel(playerid));
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Jailed",PlayerInfo[playerid][pJailed]);
    INI_WriteInt(File,"Muted",PlayerInfo[playerid][pMuted]);
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
    INI_Close(File);

    IsOnDuty[playerid] = 0;
    IsGodMode[playerid] = 0;
    //from here
    PlayerInfo[playerid][pAdmin] = 0;
    PlayerInfo[playerid][pVIP] = 0;
    //etc.
pawn Код:
public OnPlayerConnect(playerid)
{
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_LBLUE"Login",""COL_GREY"Type your password below to login.","Login","Quit");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_LRED"Registering...",""COL_GREY"Type your password below to register this account","Register","Quit");
    }
    IsOnDuty[playerid] = 0;
    IsGodMode[playerid] = 0;
    return 1;
}
Reply


Messages In This Thread
Saving Accounts - by Kudoz - 24.12.2014, 13:49
Re: Saving Accounts - by UltraScripter - 24.12.2014, 13:51
Re: Saving Accounts - by Kudoz - 24.12.2014, 14:13
Re: Saving Accounts - by UltraScripter - 24.12.2014, 14:21
Re: Saving Accounts - by Kudoz - 24.12.2014, 14:36
Re: Saving Accounts - by UltraScripter - 24.12.2014, 14:46
Re: Saving Accounts - by Arxalan - 24.12.2014, 14:54
Re: Saving Accounts - by bobsona - 24.12.2014, 16:21
Re: Saving Accounts - by Kudoz - 24.12.2014, 16:35
Re: Saving Accounts - by Kudoz - 02.01.2015, 02:08

Forum Jump:


Users browsing this thread: 1 Guest(s)