SA-MP Forums Archive
Dialog problems - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Dialog problems (/showthread.php?tid=271120)



Dialog problems - Skylar Paul - 23.07.2011

Well, i'm having a problem figuring out how to compare the text from inputtext (dialogs) to a file - It should work, but yet, it doesn't.

pawn Код:
case LOGIN_DIALOG:
        {
            if(response)
            {
                if(strlen(inputtext) <= 32)
                {
                    if(strcmp(SInfo[playerid][Password], inputtext, true)) //This is the problem.
                    {
                        OnPlayerLogin(playerid, inputtext);
                    }
                    else return ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_INPUT, "Welcome back!", "You appear to have an account on this server!\nPlease login by typing in your password below:", "Submit", "Quit");
                }
                else
                {
                    ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_INPUT, "Welcome back!", "You appear to have an account on this server!\nPlease login by typing in your password below:", "Submit", "Quit");
                }
            }
            else return Kick(playerid);
        }
Any idea what's wrong here?


Re: Dialog problems - =WoR=Varth - 23.07.2011

pawn Код:
if(!strcmp(SInfo[playerid][Password], inputtext, true)) return OnPlayerLogin(playerid, inputtext);
That will check if the string is same it will return "OnPlayerLogin"


Re: Dialog problems - Skylar Paul - 23.07.2011

Quote:
Originally Posted by varthshenon
Посмотреть сообщение
pawn Код:
if(!strcmp(SInfo[playerid][Password], inputtext, true)) return OnPlayerLogin(playerid, inputtext);
That will check if the string is same it will return "OnPlayerLogin"
Still not working.

Quote:

[22:34:07]
Entered Password: sd
Actual Password: lolol1

And then I get the message, "You have been logged into Sky's Local Fun Zone."

Here's the code:

pawn Код:
case LOGIN_DIALOG:
        {
            if(response)
            {
                if(strlen(inputtext) <= 32)
                {
                    if(!strcmp(SInfo[playerid][Password], inputtext, true))
                        return OnPlayerLogin(playerid, inputtext);

                    else return ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_INPUT, "Welcome back!", "You appear to have an account on this server!\nPlease login by typing in your password below:", "Submit", "Quit");
                }
                else
                {
                    ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_INPUT, "Welcome back!", "You appear to have an account on this server!\nPlease login by typing in your password below:", "Submit", "Quit");
                }
            }
            else return Kick(playerid);
        }



Re: Dialog problems - =WoR=Varth - 23.07.2011

pawn Код:
case LOGIN_DIALOG:
{
    if(response)////This line will called if player press button number 0
    {
        if(!strcmp(SInfo[playerid][Password], inputtext, true)) return OnPlayerLogin(playerid, inputtext);
        else return //This line will called if player put the wrong apssword
    }
    else //This line will called if player press button number 1
    return 0;
}



Re: Dialog problems - Skylar Paul - 23.07.2011

pawn Код:
case LOGIN_DIALOG:
        {
            if(response)
            {
                if(!strcmp(SInfo[playerid][Password], inputtext, true)) return OnPlayerLogin(playerid, inputtext);
                    else return ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_INPUT, "Welcome back!", "You appear to have an account on this server!\nPlease login by typing in your password below:", "Submit", "Quit");
            }
            else Kick(playerid);
            return 0;
        }
Copy-pasted it exactly, and still, not working.. it logs me in perfectly fine.


Re: Dialog problems - =WoR=Varth - 23.07.2011

I just wonder why you put "LOGIN_DIALOG" instead the dialogid?


Re: Dialog problems - Skylar Paul - 23.07.2011

Quote:
Originally Posted by varthshenon
Посмотреть сообщение
I just wonder why you put "LOGIN_DIALOG" instead the dialogid?
I have it defined at the top of my script.

pawn Код:
#define     LOGIN_DIALOG        2
But, this has nothing to do with my problem.


EDIT: Fixed.

pawn Код:
case LOGIN_DIALOG:
        {
            if(response)
            {
                new
                    uFile[35],
                    player_Name[MAX_PLAYER_NAME];

                GetPlayerName(playerid, player_Name, sizeof(player_Name));
                format(uFile, 35, USER_DIRECTORY, player_Name);

                INI_ParseFile(uFile, "LoadUserData", .bExtra = true, .extra = playerid);
               
                if(strcmp(inputtext, SInfo[playerid][Password], true) == 0) return OnPlayerLogin(playerid, inputtext);
                    else return ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_INPUT, "Welcome back!", "You appear to have an account on this server!\nPlease login by typing in your password below:", "Submit", "Quit");
            }
            else Kick(playerid);
            return 0;
        }



Re: Dialog problems - =WoR=Varth - 23.07.2011

Well that's not a problem as long as it's not interupted by another dialog with same ID.
Check if you have a different dialog with same ID and check if your OnDialogResponse is called (I guess you already did).