OnDialogResponse
#1

Sup' guys.

So, i've been makin' dialogs and now, when i'm tryin' to make one for job selection.So here's the problem.
If i press the "Cancel" button it kicks the player but, as I've learned it should just close the menu.

Can ya find any problem in the code?

Код:
 // We SHOULD use switch(dialogid) with cases, but we're only going to use one dialog in this tutorial.
  if(dialogid == 1 && response) // If the dialogid is 1 (our dialog) and they pressed 'Purchase'
  {
    // We'll use the switch/cases now because we're going to process a few results, not just one. Remember, the first item in the list has id 0.
    switch(listitem)
    {
      case 0:
      {
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Sa oled peatselt saamas bussijuhiks ning sa saad 5 tunnise lepingu.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Enne lepingu lхppu sa ei saa kuidagi oma tццst loobuda.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Kui sa oled kindel, et soovid saada bussijuhiks siis kirjuta /nхustu tцц");
      }
      case 1:
      {
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Sa oled peatselt saamas tдnavapьhkijaks ning sa saad 5 tunnise lepingu.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Enne lepingu lхppu sa ei saa kuidagi oma tццst loobuda.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Kui sa oled kindel, et soovid saada tдnavapьhkijaks siis kirjuta /nхustu tцц");
      }
      case 2:
      {
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Sa oled peatselt saamas detektiiviks ning sa saad 5 tunnise lepingu.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Enne lepingu lхppu sa ei saa kuidagi oma tццst loobuda.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Kui sa oled kindel, et soovid saada detektiiviks siis kirjuta /nхustu tцц");
      }
      case 3:
      {
      	SendClientMessage(playerid, COLOR_LIGHTBLUE, "Sa oled peatselt saamas advokaadiks ning sa saad 5 tunnise lepingu.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Enne lepingu lхppu sa ei saa kuidagi oma tццst loobuda.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Kui sa oled kindel, et soovid saada advokaadiks siis kirjuta /nхustu tцц");
			}
			case 4:
			{
  				SendClientMessage(playerid, COLOR_LIGHTBLUE, "Sa oled peatselt saamas mehaanikuks ning sa saad 5 tunnise lepingu.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Enne lepingu lхppu sa ei saa kuidagi oma tццst loobuda.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Kui sa oled kindel, et soovid saada mehaanikuks siis kirjuta /nхustu tцц");
			}
			case 5:
			{
			  SendClientMessage(playerid, COLOR_LIGHTBLUE, "Sa oled peatselt saamas ihukaitsjaks ning sa saad 5 tunnise lepingu.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Enne lepingu lхppu sa ei saa kuidagi oma tццst loobuda.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Kui sa oled kindel, et soovid saada ihukaitsjaks siis kirjuta /nхustu tцц");
			}
			case 6:
			{
  				SendClientMessage(playerid, COLOR_LIGHTBLUE, "Sa oled peatselt saamas pitsapoisiks ning sa saad 5 tunnise lepingu.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Enne lepingu lхppu sa ei saa kuidagi oma tццst loobuda.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Kui sa oled kindel, et soovid saada pitsapoisiks siis kirjuta /nхustu tцц");
			}
    }
  }
	else
	{
		SendClientMessage(playerid, COLOR_WHITE, "* Sa katkestasid tццkoha valimise!");
	}
  return 1;
}
pawn Код:
// We SHOULD use switch(dialogid) with cases, but we're only going to use one dialog in this tutorial.
  if(dialogid == 1 && response) // If the dialogid is 1 (our dialog) and they pressed 'Purchase'
  {
    // We'll use the switch/cases now because we're going to process a few results, not just one. Remember, the first item in the list has id 0.
    switch(listitem)
    {
      case 0:
      {
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Sa oled peatselt saamas bussijuhiks ning sa saad 5 tunnise lepingu.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Enne lepingu lхppu sa ei saa kuidagi oma tццst loobuda.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Kui sa oled kindel, et soovid saada bussijuhiks siis kirjuta /nхustu tцц");
      }
      case 1:
      {
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Sa oled peatselt saamas tдnavapьhkijaks ning sa saad 5 tunnise lepingu.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Enne lepingu lхppu sa ei saa kuidagi oma tццst loobuda.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Kui sa oled kindel, et soovid saada tдnavapьhkijaks siis kirjuta /nхustu tцц");
      }
      case 2:
      {
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Sa oled peatselt saamas detektiiviks ning sa saad 5 tunnise lepingu.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Enne lepingu lхppu sa ei saa kuidagi oma tццst loobuda.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Kui sa oled kindel, et soovid saada detektiiviks siis kirjuta /nхustu tцц");
      }
      case 3:
      {
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Sa oled peatselt saamas advokaadiks ning sa saad 5 tunnise lepingu.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Enne lepingu lхppu sa ei saa kuidagi oma tццst loobuda.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Kui sa oled kindel, et soovid saada advokaadiks siis kirjuta /nхustu tцц");
            }
            case 4:
            {
                SendClientMessage(playerid, COLOR_LIGHTBLUE, "Sa oled peatselt saamas mehaanikuks ning sa saad 5 tunnise lepingu.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Enne lepingu lхppu sa ei saa kuidagi oma tццst loobuda.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Kui sa oled kindel, et soovid saada mehaanikuks siis kirjuta /nхustu tцц");
            }
            case 5:
            {
              SendClientMessage(playerid, COLOR_LIGHTBLUE, "Sa oled peatselt saamas ihukaitsjaks ning sa saad 5 tunnise lepingu.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Enne lepingu lхppu sa ei saa kuidagi oma tццst loobuda.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Kui sa oled kindel, et soovid saada ihukaitsjaks siis kirjuta /nхustu tцц");
            }
            case 6:
            {
                SendClientMessage(playerid, COLOR_LIGHTBLUE, "Sa oled peatselt saamas pitsapoisiks ning sa saad 5 tunnise lepingu.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Enne lepingu lхppu sa ei saa kuidagi oma tццst loobuda.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Kui sa oled kindel, et soovid saada pitsapoisiks siis kirjuta /nхustu tцц");
            }
    }
  }
    else
    {
        SendClientMessage(playerid, COLOR_WHITE, "* Sa katkestasid tццkoha valimise!");
    }
  return 1;
}
Reply
#2

replace the
if(dialogid == 1 && response) // If the dialogid is 1 (our dialog) and they pressed 'Purchase'
with:

if(dialogid == 1)

and then do

if(response)
switch(listitem)
...

at the end replace else with:
if(!response)

i guess this should work.
Reply
#3

Quote:
Originally Posted by 0ne
replace the
if(dialogid == 1 && response) // If the dialogid is 1 (our dialog) and they pressed 'Purchase'
with:

if(dialogid == 1)

and then do

if(response)
switch(listitem)
...

at the end replace else with:
if(!response)

i guess this should work.
No, it doesn't
Reply
#4

maybe conflicting with other dialog?
Reply
#5

Quote:
Originally Posted by Etch ❽ H
maybe conflicting with other dialog?
Maybe, here's the full function
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new sendername[MAX_PLAYER_NAME];
    new string[128];
    if(response)
    {
        if(dialogid == 12346 || dialogid == 12347)
        {
          if(strlen(inputtext))
          {
                new tmppass[64];
                strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
                //Encrypt(tmppass);
                OnPlayerLogin(playerid,tmppass);
            }
            else
            {
                new loginstring[128];
                new loginname[64];
                GetPlayerName(playerid,loginname,sizeof(loginname));
                format(loginstring,sizeof(loginstring),"WRONG PASSWORD\nPlease enter the correct password:",loginname);
                ShowPlayerDialog(playerid,12347,DIALOG_STYLE_INPUT,"Login",loginstring,"Login","Exit");
                gPlayerLogTries[playerid] += 1;
                if(gPlayerLogTries[playerid] == 5) { Ban(playerid); }
            }
        }
        if(dialogid == 12345)
        {
          if(strlen(inputtext))
          {
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s.ini", sendername);
                new File: hFile = fopen(string, io_read);
                if (hFile)
                {
                    SendClientMessage(playerid, COLOR_YELLOW, "That Username is already taken, please choose a different one.");
                    fclose(hFile);
                    return 1;
                }
                new tmppass[64];
                strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
                //Encrypt(tmppass);
                OnPlayerRegister(playerid,tmppass);
            }
            else
            {
                new regstring[128];
                new regname[64];
                GetPlayerName(playerid,regname,sizeof(regname));
                format(regstring,sizeof(regstring),"Tere tulemast, %s\nSee nimi on veel vaba.\nPalun registreeri:",regname);
                ShowPlayerDialog(playerid,12345,DIALOG_STYLE_INPUT,"Tere tulemast, Palun registreeri!",regstring,"Registreeri","Lahku");
            }
        }
    }
    else
    {
        Kick(playerid);
    }
 // We SHOULD use switch(dialogid) with cases, but we're only going to use one dialog in this tutorial.
    if(dialogid == 1) // If the dialogid is 1 (our dialog) and they pressed 'Purchase'
  {
    // We'll use the switch/cases now because we're going to process a few results, not just one. Remember, the first item in the list has id 0.
    switch(listitem)
    {
      case 0:
      {
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Sa oled peatselt saamas bussijuhiks ning sa saad 5 tunnise lepingu.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Enne lepingu lхppu sa ei saa kuidagi oma tццst loobuda.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Kui sa oled kindel, et soovid saada bussijuhiks siis kirjuta /nхustu tцц");
      }
      case 1:
      {
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Sa oled peatselt saamas tдnavapьhkijaks ning sa saad 5 tunnise lepingu.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Enne lepingu lхppu sa ei saa kuidagi oma tццst loobuda.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Kui sa oled kindel, et soovid saada tдnavapьhkijaks siis kirjuta /nхustu tцц");
      }
      case 2:
      {
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Sa oled peatselt saamas detektiiviks ning sa saad 5 tunnise lepingu.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Enne lepingu lхppu sa ei saa kuidagi oma tццst loobuda.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Kui sa oled kindel, et soovid saada detektiiviks siis kirjuta /nхustu tцц");
      }
      case 3:
      {
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Sa oled peatselt saamas advokaadiks ning sa saad 5 tunnise lepingu.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Enne lepingu lхppu sa ei saa kuidagi oma tццst loobuda.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Kui sa oled kindel, et soovid saada advokaadiks siis kirjuta /nхustu tцц");
            }
            case 4:
            {
                SendClientMessage(playerid, COLOR_LIGHTBLUE, "Sa oled peatselt saamas mehaanikuks ning sa saad 5 tunnise lepingu.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Enne lepingu lхppu sa ei saa kuidagi oma tццst loobuda.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Kui sa oled kindel, et soovid saada mehaanikuks siis kirjuta /nхustu tцц");
            }
            case 5:
            {
              SendClientMessage(playerid, COLOR_LIGHTBLUE, "Sa oled peatselt saamas ihukaitsjaks ning sa saad 5 tunnise lepingu.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Enne lepingu lхppu sa ei saa kuidagi oma tццst loobuda.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Kui sa oled kindel, et soovid saada ihukaitsjaks siis kirjuta /nхustu tцц");
            }
            case 6:
            {
                SendClientMessage(playerid, COLOR_LIGHTBLUE, "Sa oled peatselt saamas pitsapoisiks ning sa saad 5 tunnise lepingu.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Enne lepingu lхppu sa ei saa kuidagi oma tццst loobuda.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Kui sa oled kindel, et soovid saada pitsapoisiks siis kirjuta /nхustu tцц");
            }
    }
  }
    if(!response)
    {
        SendClientMessage(playerid, COLOR_WHITE, "* Sa katkestasid tццkoha valimise!");
    }
  return 1;
}
Reply
#6

maybe, make your dialog id really random?
or do you have other FS (incase you are using one)
that has dialogs in it?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)