Dialog login doesn't work
#3

Current Progress

pawn Код:
case DIALOG_LOGIN: {
            if ( !response ) return Kick ( playerid );
            if( response ) {
                //if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                //if(strlen(PInfo[playerid][Password])) {
                new file[64], password2[23], PlayerName[24];
                INI_Open(file);//Opening the file with SII include
                INI_ReadString(password2,"Password");
                if(strlen(password2)) {
                    GetPlayerName(playerid,PlayerName,sizeof PlayerName);
                    format(file,sizeof file,"Admin/%s.ini",PlayerName);
                    PInfo[playerid][Registered] = INI_ReadInt("Registered");
                    PInfo[playerid][Level] = INI_ReadInt("Level");//Setting the admin level variable, to the one thats in his file.
                    PInfo[playerid][Score] = INI_ReadInt("Score"); // Setting the score of player
                    PInfo[playerid][Money] = INI_ReadInt("Money"); // Setting the money of player
                    PInfo[playerid][Operator] = INI_ReadInt("Operator");
                    INI_Close();//"Closing the file", that means that we're not using it anymore :P
                    SendClientMessage(playerid,-1,"You have been successfully logged in!");
                    PInfo[playerid][Logged] = 1;//Setting the logged in variable to 1
                    SetPlayerScore(playerid, PInfo[playerid][Score]);
                    GivePlayerMoney(playerid, PInfo[playerid][Money]);
                } else {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
I managed to get this working now, but now i got the next problem
When you login 3 times like this:

First == register
Second time == Login
Third time == It shows me the register dialog again

pawn Код:
public OnPlayerConnect(playerid)
{
    SendClientMessage(playerid,-1,"Welcome to United Kingdom TDM! Dont forget to check /updates ! ");
    new name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "** %s has joined United Kingdom TDM", name);
    IsOnAdminDuty[playerid] = false;
    SendClientMessageToAll(-1, string);
    PMEnabled[playerid] = 1;

    new file[64],PlayerName[25];//Creating a variable where we can store the file path, and the variable to store the player's name.
    GetPlayerName(playerid,PlayerName,sizeof PlayerName);//Storing the players name in the PlayerName variable.
    format(file,sizeof file,"Admin/%s.ini",PlayerName);//Storing the file path with the players name.
    if(PInfo[playerid][Registered] == 1) {
        format(file,sizeof file,"Admin/%s.ini",PlayerName);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login Below", "Enter Your Password To Login!", "Login", "Quit");
        //ShowPlayerDialog(playerid, 999, DIALOG_STYLE_LIST, "{6EF83C}Choose A Class:", "Soldier Class\nSniper Class\nEngineer Class\nJet-Trooper Class\nPilot Class\nSpy Class", "Choose","");
    } else {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register Below", "Enter A Password To Register And Play!", "Register", "Quit");
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    if(PInfo[playerid][Logged] == 1)
    {
        PInfo[playerid][Logged] = 0;
        new name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME], file[64];
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "** %s has left United Kingdom TDM", name);
        IsOnAdminDuty[playerid] = false;
        SendClientMessageToAll(-1, string);
        format(file, sizeof file, "Admin/%s.ini", name);
        new scores = GetPlayerScore(playerid), //Created extra var to check it.
        money = GetPlayerMoney(playerid);
        INI_Open(file);
        INI_WriteInt("Registered", PInfo[playerid][Registered]);
        INI_WriteInt("Level", PInfo[playerid][Level]);
        INI_WriteInt("Operator", PInfo[playerid][Operator]);
        INI_WriteInt("Score", scores);
        INI_WriteInt("Money", money);
        INI_Save();
        INI_Close();
    }
    return 1;
}
pawn Код:
case DIALOG_REGISTER: {
            if (!response) return Kick(playerid);
            if(response) {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register Below","Wrong Password!\nEnter Password To Play!","Register","Quit");
                    new file[64], PlayerName[24];
                    GetPlayerName(playerid,PlayerName,sizeof PlayerName);
                    format(file,sizeof file,"Admin/%s.ini",PlayerName);
                    INI_Open(file);
                    INI_WriteString("Password", inputtext);
                    INI_WriteInt("Registered",1);
                    INI_WriteInt("Level",0);
                    INI_WriteInt("Operator",0);
                    INI_WriteInt("Score",0);
                    INI_WriteInt("Money",15000);
                    INI_Save();
                    INI_Close();
                    SendClientMessage(playerid,-1,"You have successfully registered!");
                    GivePlayerMoney(playerid, 15000); //WHEN YOU LOG OUT IT WILL GET SAVED
                    PInfo[playerid][Logged] = 1;
                    PInfo[playerid][Registered] = 1;
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,"Success!","Your Account Is Now In Our Database! Thanks For Registering","Ok","");
            }
        }
Reply


Messages In This Thread
Dialog login doesn't work - by Biess - 21.12.2012, 17:45
Re: Dialog login doesn't work - by Djole1337 - 21.12.2012, 17:56
Re: Dialog login doesn't work - by Biess - 21.12.2012, 20:41
Re: Dialog login doesn't work - by [HK]Ryder[AN] - 22.12.2012, 06:47
Re: Dialog login doesn't work - by Biess - 22.12.2012, 06:50

Forum Jump:


Users browsing this thread: 1 Guest(s)