Dialogs issues
#1

DELETED AND CREATED A NEW THREAD
Reply
#2

Well the answer might be very easy.
When you connect you are automatically going to the "request classes", no matter if you're opening a dialog or if you're checking a file (account exists).

You shouldn't use the ShowPlayerDialog() in OnPlayerRequestClass, let it pop up after a player is successfully registered or logged in
Reply
#3

Quote:
Originally Posted by Kwarde
Посмотреть сообщение
Well the answer might be very easy.
When you connect you are automatically going to the "request classes", no matter if you're opening a dialog or if you're checking a file (account exists).

You shouldn't use the ShowPlayerDialog() in OnPlayerRequestClass, let it pop up after a player is successfully registered or logged in
If he is already registered or logged in why would he need to show it in OPRC?



You can just show the register dialog in OnPlayerConnect if the player isnt registered (if(!fexist(USERPATH))
If (if(!fexist(USERPATH)) isnt true, show the player the login dialog OnPlayerConnect... Im on my phone, sorry to not be detailed!
Reply
#4

Quote:
Originally Posted by Crayder
Посмотреть сообщение
If he is already registered or logged in why would he need to show it in OPRC?
Let me reconsider my answer. I am kinda confused at the moment (mixed some things up)
Reply
#5

Quote:
Originally Posted by Kwarde
Посмотреть сообщение
Let me reconsider my answer. I am kinda confused at the moment (mixed some things up)
That's ok, I should have included my OnPlayerConnect script, because that may also be the issue, but I haven't looked into it very hard. Added it now.
Reply
#6

Quote:
Originally Posted by Aerotactics
Посмотреть сообщение
That's ok, I should have included my OnPlayerConnect script, because that may also be the issue, but I haven't looked into it very hard. Added it now.
Well I checked over it again, you have the things I was talking about before... SO, after they successfully registered (OnDialogResponse dialogid == DIALOG_REGISTER) Show the login dialog, with a message like "Thanks for registering, now please login!"
Reply
#7

Quote:
Originally Posted by Crayder
Посмотреть сообщение
Well I checked over it again, you have the things I was talking about before... SO, after they successfully registered (OnDialogResponse dialogid == DIALOG_REGISTER) Show the login dialog, with a message like "Thanks for registering, now please login!"
Changed all dialog ids to DIALOG_LOGIN or DIALOG_REGISTER accordingly, tried changing dialog ids without any luck.
Reply
#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
#9

Quote:
Originally Posted by Crayder
Посмотреть сообщение
Try this, replace the currents with these...

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)
I already did that (not the INIs to 0, but changing all the ids to DIALOG_LOGIN or REGISTER), did you read my last post?
Reply
#10

Bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)