Dialog problem
#1

Well, I'm not sure really, but it seems I got problems with dialog

pawn Код:
#define password1 "gsaforever"

public OnPlayerSpawn(playerid)
{
if (gTeam[playerid] == 0)
        {
            ShowPlayerDialog( playerid, 104, DIALOG_STYLE_INPUT, "Authentication", "Code number please as Security Agent in trainee, given by Hamza, or any GSA high rank", "Spawn", "Cancel" );
        }
}

public bla bla bla
if(dialogid == 104)
         {
         if(!response) return SendClientMessage(playerid, 0xFFFFFFFF, "You didn't write anything!");
         if (response == 1)
            {
                  if (!strcmp(inputtext, password1)) //checking if it is the players password
                  {
                IsLogged[playerid] = 1;
                TogglePlayerControllable(playerid, 1);
                    }
                    else //incorrect password
                  {
                ShowPlayerDialog(playerid, 104, DIALOG_STYLE_INPUT, "Invalid Password", "Invalid Password, try again", "Login", "Cancel");
                     }
            }
         else
            {
                  SendClientMessage(playerid, 0xFFFFFFFF, "You canceled.");
                  Kick( playerid );
            }
        return 1; //returns 1, it has been handled
          }
The problem here, that whenever I click on login with empty password I just log in .. and if wrong password, I get kicked, and if right password, I log in too.

HELP would be appreciated
Reply
#2

This should fix your problem, tell me if it works or not...

pawn Код:
public bla bla bla
if(dialogid == 104)
{
    if(!response)
    {
        SendClientMessage(playerid, COLOR_RED, "You selected exit, therefore you were kicked.");
        Kick(playerid);
    }
        if(!strcmp(inputtext, password1)) //checking if it is the players password
        {
            IsLogged[playerid] = 1;
            TogglePlayerControllable(playerid, 1);
        }
        else //incorrect password
        {
            ShowPlayerDialog(playerid, 104, DIALOG_STYLE_INPUT, "Invalid Password", "Invalid Password, try again", "Login", "Cancel");
        }
    }
    return 1; //returns 1, it has been handled
}
Reply
#3

Tried it, and no, When I leave the input dialog empty and click on "login" it just log me in.. instead of kicking me out
Reply
#4

Quote:
Originally Posted by Hamza'
Посмотреть сообщение
Tried it, and no, When I leave the input dialog empty and click on "login" it just log me in.. instead of kicking me out
Your script is confusing me. Why do you have two different dialogs, when they're both supposed to be for logging in? You may have the wrong section of "public OnPlayerDialogResponse(...)".
Reply
#5

That's what I already got..

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
if(dialogid == 104)
         {
         if(!response) return SendClientMessage(playerid, 0xFFFFFFFF, "You didn't write anything!");
         if (response == 1)
            {
                  if (!strcmp(inputtext, password1)) //checking if it is the players password
                  {
                IsLogged[playerid] = 1;
                TogglePlayerControllable(playerid, 1);
                    }
                    else //incorrect password
                  {
                ShowPlayerDialog(playerid, 104, DIALOG_STYLE_INPUT, "Invalid Password", "Invalid Password, try again", "Login", "Cancel");
                     }
            }
         else
            {
                  SendClientMessage(playerid, 0xFFFFFFFF, "You canceled.");
                  Kick( playerid );
            }
        return 1; //returns 1, it has been handled
          }
Reply
#6

Quote:
Originally Posted by Hamza'
Посмотреть сообщение
That's what I already got..

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
if(dialogid == 104)
         {
         if(!response) return SendClientMessage(playerid, 0xFFFFFFFF, "You didn't write anything!");
         if (response == 1)
            {
                  if (!strcmp(inputtext, password1)) //checking if it is the players password
                  {
                IsLogged[playerid] = 1;
                TogglePlayerControllable(playerid, 1);
                    }
                    else //incorrect password
                  {
                ShowPlayerDialog(playerid, 104, DIALOG_STYLE_INPUT, "Invalid Password", "Invalid Password, try again", "Login", "Cancel");
                     }
            }
         else
            {
                  SendClientMessage(playerid, 0xFFFFFFFF, "You canceled.");
                  Kick( playerid );
            }
        return 1; //returns 1, it has been handled
          }
Again, it's confusing. Send me a PM, with a download link to your script. I will see if it's all correct.
Reply
#7

Wrong!
Reply
#8

I think there's a better way to do it, but anyways...good luck!
Reply
#9

Tell me then that better way ? :<
Reply
#10

I would try this, even though it's the same amount of lines. It may be a little bit more efficient.

pawn Код:
if(strlen(inputtext) <= 0)
{
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)