[Help] - Login Dialog 'Leave' Button
#9

Use a variable to set their login state, and check for their login state when they disconnect.

Example:

pawn Код:
new bool: logged[MAX_PLAYERS]; // var


if(dialogid == dlogin) //If dialog id is a login dialog
    {//then
        if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
        if(response) //if they clicked the first button "Register"
        {//then
            new hashpass[129]; //Will create a new variable to hash his/her password
            WP_Hash(hashpass,sizeof(hashpass),inputtext); //Will hash inputted password
            if(!strcmp(hashpass, pInfo[playerid][Pass], false)) //If they have insert their correct password
            {//then
                INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);//We will load his account's data from user's path
                SetPlayerScore(playerid,pInfo[playerid][Scores]);//We will get their score inside of his user's account and we will set it here
                GivePlayerMoney(playerid,pInfo[playerid][Money]);//As explained above
                SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in");//Tell them that they've successfully logged in
                logged[playerid] = true; // set it here
            }
            else //If they've entered an incorrect password
            {//then
                ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account.\nIncorrect password!","Login","Quit");//We will tell to them that they've entered an incorrect password
                return 1;
            }
        }
    }

public OnPlayerDisconnect(playerid,reason)
{
    if(logged[playerid])
    {
        pInfo[playerid][pRStatus] = 0;
        pInfo[playerid][pRDonator] = 0;
        pInfo[playerid][pRCash] = 0;
        pInfo[playerid][pRScores] = 0;
        pInfo[playerid][pRKills] = 0;
        pInfo[playerid][pRDeaths] = 0;
       //... codes
    }
    return 1;
}
Reply


Messages In This Thread
[Help] - Login Dialog 'Leave' Button - by SAMProductions - 03.06.2014, 05:59
Re: [Help] - Login Dialog 'Leave' Button - by SyntaxQ - 03.06.2014, 06:03
Re: [Help] - Login Dialog 'Leave' Button - by Rittik - 03.06.2014, 06:06
Re: [Help] - Login Dialog 'Leave' Button - by SAMProductions - 03.06.2014, 06:16
Re: [Help] - Login Dialog 'Leave' Button - by Rittik - 03.06.2014, 06:19
Re: [Help] - Login Dialog 'Leave' Button - by BroZeus - 03.06.2014, 06:19
Re: [Help] - Login Dialog 'Leave' Button - by SAMProductions - 03.06.2014, 07:44
Re: [Help] - Login Dialog 'Leave' Button - by Mriss - 03.06.2014, 07:50
Re: [Help] - Login Dialog 'Leave' Button - by Dignity - 03.06.2014, 07:56
Re: [Help] - Login Dialog 'Leave' Button - by SyntaxQ - 03.06.2014, 07:56

Forum Jump:


Users browsing this thread: 3 Guest(s)