Dialogs issues
#8

Try this, replace the currents with these...


pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_REGISTER) //register dialog
    {
        if(response)
        {
            new pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid, pName, sizeof(pName));
            new file[96];
            format(file,sizeof(file),"/User_Database/%s.ini",pName);

            new INI:handler = INI_Open(file);
            INI_WriteString(handler,"Password",inputtext);
            INI_WriteInt(handler,"Score", 0);
            INI_WriteInt(handler,"Money", 0.0);
            INI_WriteInt(handler,"Playerlevel", 0);
            INI_WriteFloat(handler, "PosX", 0);
            INI_WriteFloat(handler, "PosY", 0);
            INI_WriteFloat(handler, "PosZ", 0);
            INI_WriteInt(handler,"FirstLog", 1);
            INI_Close(handler);
           
            PlayerInfo[playerid][FirstLog] = 1;
           
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account", "Your accountname is registered! \nPlease fill in your password here:", "Login", "Quit");
        }
        else Kick(playerid);
    }
    if(dialogid == DIALOG_LOGIN) //login dialog
    {
        if(response)
        {
            new pName[MAX_PLAYER_NAME];GetPlayerName(playerid, pName, sizeof(pName));
            new file[96];format(file,sizeof file,"/User_Database/%s.ini",pName);
            INI_ParseFile(file, "GetData", .bExtra = true, .extra =playerid);
            if (strcmp(inputtext, PlayerInfo[playerid][password]))
            {
                new string[128];
                if (attempt[playerid] <3)
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account", "Your accountname is registered! \nPlease fill in your password here:", "Login", "Quit");
                    attempt[playerid]++;
                    PlayerPlaySound(playerid,1057,0,0,0);
                    printf("%s has failed to login", pName);
                    format(string,sizeof string,"Invalid password! [%i/3]",attempt[playerid]);
                    SendClientMessage(playerid, 0xFF3200FF, string);
                    attempt[playerid] = attempt[playerid]++;
                } else {
                    GetPlayerName(playerid,pName,8);
                    format(string,sizeof string,"%s(%i) Has been kicked by the server(Failed to login).",pName,playerid);
                    SendClientMessageToAll(COLOR_GRAY,string);
                    Kick(playerid);
                }
            }
            else if (!strcmp(inputtext, PlayerInfo[playerid][password]))
            {
                if (PlayerInfo[playerid][FirstLog] == 0)
                {
                    SpawnPlayer(playerid);
                    SendClientMessage(playerid, COLOR_GREEN,"You have succesfully logged in!");
                    return 1;
                }
                if (PlayerInfo[playerid][FirstLog] == 1)
                {
                    ForceClassSelection(playerid);
                    return 1;
                }
            }
        }
        else Kick(playerid);
    }
    return 0;
}

public OnPlayerConnect(playerid)
{
    SetPVarInt(playerid, "ConnectTime", GetTickCount());
    new file[96],pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(file,sizeof(file),"/User_Database/%s.ini",pName);
    attempt[playerid] = 0;
    if(!fexist(file))
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Account", "A registration is required to play on this server. \nPlease fill in a password to create a free account!", "Register", "Cancel");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account", "Your accountname is registered! \nPlease fill in your password here:", "Login", "Quit");
    }
    SpamCount[playerid]=0;
    AutoRepairUsed[playerid] = 0;
    AdminDuty[playerid] = 0;
    AutoRepairTrigger[playerid] = 0;
    PlayerInfo[playerid][FirstLog] = 0;
    TextDrawShowForPlayer(playerid,WebsiteTextdraw);
    return 1;
}







BTW, the value you currently register with, (GetPlayerMoney, GetPlayerScore) are already 0 if they had just registered, and the same for the admin level, its already 0, so just type 0 for the newly registered ini files...

(I already did it, just pointing this out)
Reply


Messages In This Thread
Dialogs issues - by Aerotactics - 26.02.2014, 20:51
Re: Dialogs issues - by Kwarde - 27.02.2014, 04:30
Re: Dialogs issues - by Crayder - 27.02.2014, 06:35
Re: Dialogs issues - by Kwarde - 27.02.2014, 07:25
Re: Dialogs issues - by Aerotactics - 27.02.2014, 17:58
Re: Dialogs issues - by Crayder - 27.02.2014, 19:15
Re: Dialogs issues - by Aerotactics - 27.02.2014, 19:24
Re: Dialogs issues - by Crayder - 27.02.2014, 19:37
Re: Dialogs issues - by Aerotactics - 27.02.2014, 19:50
Re: Dialogs issues - by Aerotactics - 27.02.2014, 22:12

Forum Jump:


Users browsing this thread: 1 Guest(s)