Dialogs
#1

Ok, i'm using this tutorial for creating dialogs but it is only set for 1 button, How would i go about setting it for both buttons, Like button 1 will be buy and button 2 would be to exit the interior.

I'm a lil confused

https://sampwiki.blast.hk/wiki/How_to_Create_a_Dialog

If you need my code i will be more in happy to post it.

Reply
#2

Yes sorry for the bump, but no one has got anything? If not i can rewrite my dialogs with a new tutorial.
Reply
#3

post your scipt here!!
Reply
#4

is basically the same thing that's on that link but, has my code it it.
Reply
#5

OnDialogResponse

Warning: This callback was added in SA-MP version 0.3. It is not available in previous versions.

This callback is called when a player presses any of the buttons on the dialog created using ShowPlayerDialog.

Parameters:
(playerid, dialogid, response, listitem, inputtext[])
playerid The ID of the player who responded to the dialog box.
dialogid The ID of the dialog the player responded to, assigned in ShowPlayerDialog.

response 1 for first button and 0 for second button

listitem The ID of the list item selected by the player.
inputtext[] The text entered into the input box by the player or the selected list item text.


See the response..
If response == 1 its first button and if response == 0 it is for the second button.
Hope it helps.

Reply
#6

When i un comment the stuff after giveplayer weapon i get errors, This is the new way i'm trying it
pawn Код:
if (dialogid == 3) //checking dialogid
  {
    if (response == 1) //warp has been pressed
    {
      switch (listitem) //a switch, not going to explain it here
      {
        case 0:GivePlayerWeapon(playerid, 24, 50);//AntiHack(playerid, -800);ShowPlayerDialog(playerid, 3, DIALOG_STYLE_LIST, "Gun Menu", "Desert Eagle $800 \nShotgun $350 \nCountry Rifle $350 \nBrass Knuckles $50", "Buy", "Exit");
        case 1:GivePlayerWeapon(playerid, 25, 10);//AntiHack(playerid, -350);ShowPlayerDialog(playerid, 3, DIALOG_STYLE_LIST, "Gun Menu", "Desert Eagle $800 \nShotgun $350 \nCountry Rifle $350 \nBrass Knuckles $50", "Buy", "Exit");
        case 2:GivePlayerWeapon(playerid, 33, 50);//AntiHack(playerid, -350);ShowPlayerDialog(playerid, 3, DIALOG_STYLE_LIST, "Gun Menu", "Desert Eagle $800 \nShotgun $350 \nCountry Rifle $350 \nBrass Knuckles $50", "Buy","Exit");
        case 3:GivePlayerWeapon(playerid, 1, 1);//AntiHack(playerid, -50);ShowPlayerDialog(playerid, 3,DIALOG_STYLE_LIST, "Gun Menu", "Desert Eagle $800 \nShotgun $350 \nCountry Rifle $350 \nBrass Knuckles $50", "Buy","Exit");
      }
      SendClientMessage(playerid, 0xFFFFFFFF, "Gun Purchased"); //a message to confirm the warp
    }
    else //pressed cancel
    {
    TogglePlayerControllable(playerid, 1);
    SetPlayerPos(playerid, 1366.3450,-1278.8975,13.5469);
    SetPlayerInterior(playerid,0);
    }
    return 1; //returns 1, it has been handled
  }
  return 0;
}
Код:
C:\Desktop\sa-mp server\gamemodes\penls.pwn(20708) : error 002: only a single statement (or expression) can follow each "case"
C:\Desktop\sa-mp server\gamemodes\penls.pwn(20708) : warning 215: expression has no effect
C:\Desktop\sa-mp server\gamemodes\penls.pwn(20709) : error 014: invalid statement; not in switch
C:\Desktop\sa-mp server\gamemodes\penls.pwn(20709) : warning 215: expression has no effect
C:\Desktop\sa-mp server\gamemodes\penls.pwn(20709) : error 001: expected token: ";", but found ":"
C:\Desktop\sa-mp server\gamemodes\penls.pwn(20709) : error 029: invalid expression, assumed zero
C:\Desktop\sa-mp server\gamemodes\penls.pwn(20709) : fatal error 107: too many error messages on one line
should i add && to those or how would i go about making so there is more then one thing in a case, Those error is when i un comment the case 0:
Reply
#7

Код:
f (dialogid == 3) //checking dialogid
  {
    if (response == 1) //warp has been pressed
    {
      switch (listitem) //a switch, not going to explain it here
      {
        case 0: {
         GivePlayerWeapon(playerid, 24, 50);//AntiHack(playerid, -800);ShowPlayerDialog(playerid, 3, DIALOG_STYLE_LIST, "Gun Menu", "Desert Eagle $800 \nShotgun $350 \nCountry Rifle $350 \nBrass Knuckles $50", "Buy", "Exit"); 
         }
        case 1: {
         GivePlayerWeapon(playerid, 25, 10);//AntiHack(playerid, -350);ShowPlayerDialog(playerid, 3, DIALOG_STYLE_LIST, "Gun Menu", "Desert Eagle $800 \nShotgun $350 \nCountry Rifle $350 \nBrass Knuckles $50", "Buy", "Exit");
         }
        case 2: {
        GivePlayerWeapon(playerid, 33, 50);//AntiHack(playerid, -350);ShowPlayerDialog(playerid, 3, DIALOG_STYLE_LIST, "Gun Menu", "Desert Eagle $800 \nShotgun $350 \nCountry Rifle $350 \nBrass Knuckles $50", "Buy","Exit"); 
         }
        case 3: {
         GivePlayerWeapon(playerid, 1, 1);//AntiHack(playerid, -50);ShowPlayerDialog(playerid, 3,DIALOG_STYLE_LIST, "Gun Menu", "Desert Eagle $800 \nShotgun $350 \nCountry Rifle $350 \nBrass Knuckles $50", "Buy","Exit");
         }
      }
      SendClientMessage(playerid, 0xFFFFFFFF, "Gun Purchased"); //a message to confirm the warp
    }
    if(response == 0)
    {
    TogglePlayerControllable(playerid, 1);
    SetPlayerPos(playerid, 1366.3450,-1278.8975,13.5469);
    SetPlayerInterior(playerid,0);
    }
    return 1; //returns 1, it has been handled
  }
  return 0;
}
Try this. You have got those errors cause you havent added brakets at cases.
I think you will get warning because of loose indentation only.
Reply
#8

Quote:
Originally Posted by deather
Код:
f (dialogid == 3) //checking dialogid
  {
    if (response == 1) //warp has been pressed
    {
      switch (listitem) //a switch, not going to explain it here
      {
        case 0: {
        GivePlayerWeapon(playerid, 24, 50);//AntiHack(playerid, -800);ShowPlayerDialog(playerid, 3, DIALOG_STYLE_LIST, "Gun Menu", "Desert Eagle $800 \nShotgun $350 \nCountry Rifle $350 \nBrass Knuckles $50", "Buy", "Exit"); 
         }
        case 1: {
        GivePlayerWeapon(playerid, 25, 10);//AntiHack(playerid, -350);ShowPlayerDialog(playerid, 3, DIALOG_STYLE_LIST, "Gun Menu", "Desert Eagle $800 \nShotgun $350 \nCountry Rifle $350 \nBrass Knuckles $50", "Buy", "Exit");
         }
        case 2: {
        GivePlayerWeapon(playerid, 33, 50);//AntiHack(playerid, -350);ShowPlayerDialog(playerid, 3, DIALOG_STYLE_LIST, "Gun Menu", "Desert Eagle $800 \nShotgun $350 \nCountry Rifle $350 \nBrass Knuckles $50", "Buy","Exit"); 
         }
        case 3: {
        GivePlayerWeapon(playerid, 1, 1);//AntiHack(playerid, -50);ShowPlayerDialog(playerid, 3,DIALOG_STYLE_LIST, "Gun Menu", "Desert Eagle $800 \nShotgun $350 \nCountry Rifle $350 \nBrass Knuckles $50", "Buy","Exit");
         }
      }
      SendClientMessage(playerid, 0xFFFFFFFF, "Gun Purchased"); //a message to confirm the warp
    }
    if(response == 0)
    {
    TogglePlayerControllable(playerid, 1);
    SetPlayerPos(playerid, 1366.3450,-1278.8975,13.5469);
    SetPlayerInterior(playerid,0);
    }
    return 1; //returns 1, it has been handled
  }
  return 0;
}
Try this. You have got those errors cause you havent added brakets at cases.
I think you will get warning because of loose indentation only.
I looked at another scirpt and did it the way you said, I had no problems. Thank you for replying.
Reply
#9

Quote:
Originally Posted by ihatetn931
I looked at another scirpt and did it the way you said, I had no problems. Thank you for replying.
NP Always happy to help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)