Dialogbox[BUTTONS] REP ++ -
NviDa - 16.04.2015
Hi!
I know how to make dialogs,with response etc.
But I don't know how to make the buttons work.Right now I need to make the button "close" work.
I want the dialog box to close when I press that button.
Is it by using:
If so,I have no idea what to do next after that line.
Help me out please! Thanks !
Re: Dialogbox[BUTTONS] REP ++ -
RoboN1X - 16.04.2015
The dialog automatically closes when the player clicked on any button in the dialog, so don't have to use that conditional line.
Re: Dialogbox[BUTTONS] REP ++ -
ATGOggy - 16.04.2015
If you just want to close the dialog box after pressing that button or pressing Esc, then don't write anything for that dialog in OnDialogResponse.
PHP код:
native ShowPlayerDialog(playerid, dialogid, style, caption[], info[], button1[], button2[]);
https://sampwiki.blast.hk/wiki/ShowPlayerDialog
If you leave the button2 parameter as "", there will be only one button. So, you can write the button1 as "Close" and there will be only one button called "Close" will be shown.
Here's an example:
PHP код:
ShowPlayerDialog(playerid, 123, DIALOG_STYLE_LIST, "Hello", "Hi,\nHow are you?", "Close", "");
Re: Dialogbox[BUTTONS] REP ++ -
NviDa - 16.04.2015
I know ,but when I press the "Close" button nothing happens.
Here what the command does.
/Cmds>Dialog box opens "General Commands" "Player Commands">If I press General >Shows another dialog box >It says "rules" etc
Re: Dialogbox[BUTTONS] REP ++ -
ATGOggy - 16.04.2015
Oh..you mean the listitem?
If the dialog is a list type, the value of 'listitem' in OnDialogResponse is the item's position in dialog - 1 .
The items in the list starts from 0.
Example:
PHP код:
CMD:cmds(playerid, params[]) return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Commands", "General Commands\nPlayer Commands", "Select", "Close");
public OnDialogReponse(playerid, dialogid, response, listitem)
{
if(listitem==0) //show the dialog of general commands
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_MSGBOX, "General commands", "These are the general commands", "Back", "Close");
}
if(listitem==1) // show the dialog of player commands
{
ShowPlayerDialog(playerid, 3, DIALOG_STYLE_MSGBOX, "Player commands", "These are the player commands", "Back", "Close");
}
return 1;
}
The value of 'listitem' is determined by the item which the player has selected.
Re: Dialogbox[BUTTONS] REP ++ -
NviDa - 16.04.2015
No man and I know listitem thing is.My script is exactly like that.
I just want to know how to make the "Close" button to work.
When I press the "Close" button nothing happens.
Re: Dialogbox[BUTTONS] REP ++ -
SickAttack - 16.04.2015
pawn Код:
if(response)
{
// Didn't press close (second button). Put your code here. Player decided to proceed.
}
Re: Dialogbox[BUTTONS] REP ++ -
NoDi522 - 16.04.2015
I mean "close" button is used for it? lol. If i understood you,you want something to happen after pressing close?
Here is an example:
PHP код:
if(!response) return SendClientMessage(playerid,-1,"You closed dialog");
Re: Dialogbox[BUTTONS] REP ++ -
NviDa - 16.04.2015
Quote:
Originally Posted by NoDi522
I mean "close" button is used for it? lol. If i understood you,you want something to happen after pressing close?
Here is an example:
PHP код:
if(!response) return SendClientMessage(playerid,-1,"You closed dialog");
|
Yeah you get what I'm trying to say here :P
But where should I add your code? Where ever or how ever I add it ,I get errors.
Код:
if(dialogid==101)
{
if(response)
{
if(listitem==0)
{
ShowPlayerDialog(playerid,101,DIALOG_STYLE_LIST,"Commands","/info\n/darules","Close","");
return 1;
}
}
}
return 1;
}
Re: Dialogbox[BUTTONS] REP ++ -
ATGOggy - 16.04.2015
If not close, then what else do you want to do when the player clicks the close button?