Login script bug
#1

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.
Reply
#2

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

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.
Reply
#4

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.
Reply
#5

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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)