Dialogs
#1

i didn't understand anything with all those tutorials and examples, how do i use/create it? it is confusing me
Reply
#2

Well this is an example of a 2 button message box.

To show it:
pawn Код:
ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Dialog title","This is a new feature!\nCool, isn't it?","Yes","No");
Under the OnDialogResponse callback:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
  if(dialogid == 1) // The dialog ID we assigned the message box to
  {
    if(response) SendClientMessage(playerid, 0xFFFFFFFF, "Yes? Me too!"); // If they clicked Yes
    else SendClientMessage(playerid, 0xFFFFFFFF, "No? Well I think it's cool."); // If they cliked no
  }
  return 1;
}
If you need help with lists or input boxes, just ask.
Reply
#3

cool, i can't test it because i don't have gtasa (i'm installing it! ) so can i do something like this:

Quote:

public OnPlayerConnect(playerid)
{
if(playerid == 0)
{
ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"D ialog title","Error! you are connected to the wrong server you want!","ok","exit","Retry");
}
else if(playerid == 1)
{
ShowPlayerDialog(playerid,2,DIALOG_STYLE_MSGBOX,"D ialog title","Error! your id is not 0!!!","ok","exit","Retry");
}
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1) // The dialog ID we assigned the message box to
{
if(response == 0)
{
SendClientMessage(playerid, 0xFFFFFFFF, "okay!"); // If they clicked "ok"
}
else if(response == 1)
{
SendClientMessage(playerid, 0xFFFFFFFF, "okay!"); // If they clicked "exit"
}
else if(response == 2)
{
SendClientMessage(playerid, 0xFFFFFFFF, "retrying!"); // If they clicked "retry"
}
if(dialogid == 2)
{
if(response == 0)
{
SendClientMessage(playerid, 0xFFFFFFFF, "okay!"); // If they clicked "ok"
}
else if(response == 1)
{
SendClientMessage(playerid, 0xFFFFFFFF, "okay!"); // If they clicked "exit"
}
else if(response == 2)
{
SendClientMessage(playerid, 0xFFFFFFFF, "retrying!"); // If they clicked "retry"
}
}
return 1;
}

btw, sorry for not reading the wiki! i forgot about it

Quote:
Originally Posted by Mikep.
If you need help with lists or input boxes, just ask.
please?
Reply
#4

You can only have 2 buttons, sorry.

Prehaps you can have 1 or 3 in the future, because I think "Welcome to my server! OK Cancel" is a strange button to have, but what else could it be..

Anyway, for lists, you basically do something like this.

pawn Код:
ShowPlayerDialog(playerid,2,DIALOG_STYLE_LIST,"Fighting Styles:","Normal\nBoxing\nKung Fu\nKneehead","Use","Cancel");
Also, if you aren't going to do any code when they press Cancel, we can make the codein here shorter:
pawn Код:
if(dialogid == 2 && response)
{
  switch(listitem)
  {
    case 0: SetPlayerFightingStyle(playerid, 4);
    case 1: SetPlayerFightingStyle(playerid, 5);
    case 2: SetPlayerFightingStyle(playerid, 6);
    case 3: SetPlayerFightingStyle(playerid, 7);
  }
}
listitem - The ID of the item they selected (first is 0)
inputtext - The name of the item

Now for the input box.

pawn Код:
ShowPlayerDialog(playerid,3,DIALOG_STYLE_INPUT,"Send a message","Send a message to everyone!\n\nblablabla text here!\n\nEnter your message below:","Submit","Cancel");
pawn Код:
if(dialogid == 3 && response)
{
  GameTextForAll(inputtext, 5, 5000);
}
Reply
#5

can i change the dialog position?
Reply
#6

Not yet.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)