SA-MP Forums Archive
Login script bug - 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)
+--- Thread: Login script bug (/showthread.php?tid=442700)



Login script bug - VilcsiTH - 08.06.2013

So, using the help of the samp wiki, I've managed to make a login command-thingy. The problem is, when I press the login button when the "input box" is empty, it automatically refers it to me.
Here's the code:
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_LOGIN)
    {
        if(!response) // If they clicked 'Cancel' or pressed esc
        {
            SendClientMessage(playerid, 0xFF0000FF, "LOGIN FAILED.");
        }
        else // Pressed ENTER or clicked 'Login' button
        {
            if(VilcsiTHPassword(playerid, inputtext))
            {
                SendClientMessage(playerid, 0xFF0000FF, "You are now logged in as VilcsiTH!");
            }
            else
            if(SamuelPassword(playerid, inputtext))
            {
                SendClientMessage(playerid, 0xFF0000FF, "You are now logged in as Samuel!");
            }
            else
            {
                SendClientMessage(playerid, 0xFF0000FF, "LOGIN FAILED.");

                // Re-show the login dialog
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Please enter your password:", "Login", "Cancel");
            }
        }
        return 1;
    }

    return 0;
}
Thanks for helping.


Re: Login script bug - gtakillerIV - 08.06.2013

Check if "inputtext" is null by using "if(!strlen(inputtext)) return send a message here".


Re: Login script bug - VilcsiTH - 08.06.2013

Quote:
Originally Posted by gtakillerIV
Посмотреть сообщение
Check if "inputtext" is null by using "if(!strlen(inputtext)) return send a message here".
Sorry, I'm a really beginner scripter.
So, is it like this?
Код:
        if(!strlen(inputtext))
        {
            SendClientMessage(playerid, 0xFF0000FF, "Inputtext is null!");
        }
And where do I put it?

Thanks for your help.


Re: Login script bug - SilverKiller - 08.06.2013

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_LOGIN)
    {
        if(!response) // If they clicked 'Cancel' or pressed esc
        {
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Please enter your password:", "Login", "Cancel");
            SendClientMessage(playerid, 0xFF0000FF, "LOGIN FAILED.");
        }
        else // Pressed ENTER or clicked 'Login' button
        {
            if(!strlen(inputtext)) return SendClientMessage(playerid, 0xFF0000FF, "Invalid Password");
            else if(VilcsiTHPassword(playerid, inputtext))
            {
                SendClientMessage(playerid, 0xFF0000FF, "You are now logged in as VilcsiTH!");
            }
            else if(SamuelPassword(playerid, inputtext))
            {
                SendClientMessage(playerid, 0xFF0000FF, "You are now logged in as Samuel!");
            }
            else
            {
                SendClientMessage(playerid, 0xFF0000FF, "LOGIN FAILED.");

                // Re-show the login dialog
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Please enter your password:", "Login", "Cancel");
            }
        }
        return 1;
    }
    return 0;
}
Try this.


Re: Login script bug - VilcsiTH - 09.06.2013

Quote:
Originally Posted by SilverKiller
Посмотреть сообщение
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_LOGIN)
    {
        if(!response) // If they clicked 'Cancel' or pressed esc
        {
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Please enter your password:", "Login", "Cancel");
            SendClientMessage(playerid, 0xFF0000FF, "LOGIN FAILED.");
        }
        else // Pressed ENTER or clicked 'Login' button
        {
            if(!strlen(inputtext)) return SendClientMessage(playerid, 0xFF0000FF, "Invalid Password");
            else if(VilcsiTHPassword(playerid, inputtext))
            {
                SendClientMessage(playerid, 0xFF0000FF, "You are now logged in as VilcsiTH!");
            }
            else if(SamuelPassword(playerid, inputtext))
            {
                SendClientMessage(playerid, 0xFF0000FF, "You are now logged in as Samuel!");
            }
            else
            {
                SendClientMessage(playerid, 0xFF0000FF, "LOGIN FAILED.");

                // Re-show the login dialog
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Please enter your password:", "Login", "Cancel");
            }
        }
        return 1;
    }
    return 0;
}
Try this.
Thank you, this helped me a lot!
Thanks again.

EDIT: Figured out how to give rep, thank you!