Dialogbox[BUTTONS] REP ++
#1

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(!response)
If so,I have no idea what to do next after that line.

Help me out please! Thanks !
Reply
#2

The dialog automatically closes when the player clicked on any button in the dialog, so don't have to use that conditional line.
Reply
#3

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(playeriddialogidstylecaption[], 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(playerid123DIALOG_STYLE_LIST"Hello""Hi,\nHow are you?""Close"""); 
Reply
#4

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
Reply
#5

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(playeridparams[]) return ShowPlayerDialog(playerid1DIALOG_STYLE_LIST"Commands""General Commands\nPlayer Commands""Select""Close");
public 
OnDialogReponse(playeriddialogidresponselistitem)
{
    if(
listitem==0//show the dialog of general commands
    
{
         
ShowPlayerDialog(playerid2DIALOG_STYLE_MSGBOX"General commands""These are the general commands""Back""Close");
    }
    if(
listitem==1// show the dialog of player commands
    
{
         
ShowPlayerDialog(playerid3DIALOG_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.
Reply
#6

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.
Reply
#7

pawn Код:
if(response)
{
    // Didn't press close (second button). Put your code here. Player decided to proceed.
}
Reply
#8

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"); 
Reply
#9

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;
}
Reply
#10

If not close, then what else do you want to do when the player clicks the close button?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)