SA-MP Forums Archive
OnDialogResponse - 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: OnDialogResponse (/showthread.php?tid=145627)



OnDialogResponse - Antonio [G-RP] - 03.05.2010

Help! This always kicks the player for "Pressing cancle" when he/she pressed okay

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) //the callback
{
if (dialogid == 1)
{
if (response == 1) //making sure "Login" was pressed
{
if (!strcmp(inputtext, PlayerInfo[playerid][pPassword])) //checking if it is the players password
{
OnPlayerLogin(playerid,inputtext);
return 1;
}
else //incorrect password
{
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, "Invalid Password", "Invalid Password, try again", "Login", "Cancel"); //shows another dialog, with the same dialogid.
LogAttempts[playerid]++; //increments a variable to know how many time he has tried to login
if (LogAttempts[playerid] >=2) //is it greater then or equal to 2?
{
SendClientMessage(playerid, COLOR_RED, "Too many attempts, kicked");
Kick(playerid);
return 1;
}
}
else //pressed "Cancel"
{
SendClientMessage(playerid, COLOR_RED, "You must Login to play!");
Kick(playerid);
}
}
}
return 1;
}



Re: OnDialogResponse - johnnyc - 03.05.2010

Try this:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) //the callback
{
if (dialogid == 1)
{
if (response == 1) //making sure "Login" was pressed
{
if (!strcmp(inputtext, PlayerInfo[playerid][pPassword])) //checking if it is the players password
{
OnPlayerLogin(playerid,inputtext);
return 1;
}
else //incorrect password
{
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, "Invalid Password", "Invalid Password, try again", "Login", "Cancel"); //shows another dialog, with the same dialogid.
LogAttempts[playerid]++; //increments a variable to know how many time he has tried to login
if (LogAttempts[playerid] >=2) //is it greater then or equal to 2?
{
SendClientMessage(playerid, COLOR_RED, "Too many attempts, kicked");
Kick(playerid);
return 1;
}
}
else //pressed "Cancel"
{
SendClientMessage(playerid, COLOR_RED, "You must Login to play!");
}
}
}
return 1;
}



Re: OnDialogResponse - Joe Staff - 03.05.2010

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) //the callback
{
  if (dialogid == 1)
  {
    if (response == 1) //making sure "Login" was pressed
    {
      if (!strcmp(inputtext, PlayerInfo[playerid][pPassword])) //checking if it is the players password
      {
        OnPlayerLogin(playerid,inputtext);
        return 1;
      }
      else //incorrect password
      {
        ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, "Invalid Password", "Invalid Password, try again", "Login", "Cancel"); //shows another dialog, with the same dialogid.
        LogAttempts[playerid]++; //increments a variable to know how many time he has tried to login
        if (LogAttempts[playerid] >=2) //is it greater then or equal to 2?
        {
          SendClientMessage(playerid, COLOR_RED, "Too many attempts, kicked");
          Kick(playerid);
          return 1;
}
}
else //pressed "Cancel"
{
SendClientMessage(playerid, COLOR_RED, "You must Login to play!");
Kick(playerid);
}
}
}
return 1;
}



Re: OnDialogResponse - johnnyc - 03.05.2010

Код:
else //pressed "Cancel"
{
SendClientMessage(playerid, COLOR_RED, "You must Login to play!");
Kick(playerid);
}
}
}
return 1;
}
that will still kicks the player
pawn Код:
Kick(playerid);



Re: OnDialogResponse - CsMu - 27.07.2010

You wrote :

if(response == 1)
{
BLAH BLAH!
}
else
{
BLAH BLAH MESSAGE
Kick(playerid);
}

You should remove that Kick(playerid).