OnDialogResponse does nothing
#1

Hello, i'm trying to make a dialog, but when I press "Ok", nothing happens...

I did return 0 at the end of OnDialogResponse

There is my dialog code:
Код:
 if(dialogid == DIALOG_SHOP)
	{
		switch(listitem)
         {
            case 0:
            {
                ShowPlayerDialog(playerid, DIALOG_SHOPSTUFF,DIALOG_STYLE_LIST, "Game Shop" , "{FFFFFF}Game Money\nstuff2add", "Select", "Close");
            }
}
}
Код:
if(dialogid == DIALOG_SHOPSTUFF)
	{
		switch(listitem)
         {
            case 6:
            {
          		ShowPlayerDialog(playerid, DIALOG_MONEY, DIALOG_STYLE_MSGBOX, "Game Shop" ,"{FFFFFF}Do you want to buy this item?\nItem: {FF0080}24 millions" , "Ok", "Close");
            }
            }
}
Код:
if(dialogid == DIALOG_MONEY)
    {
        if(response) 
        {
		GivePlayerMoney(playerid, 24000000);
		ShowPlayerDialog(playerid, DIALOG_SUCCESS, DIALOG_STYLE_MSGBOX, "Success!", "{24FB00}You successfully got some cash", "Thanks!", "Close");
	}
    }
However, when I paste all the above in a single command, everything works...
Код:
CMD:moneytest(playerid, params[])
{
	GivePlayerMoney(playerid, 24000000);
	ShowPlayerDialog(playerid, DIALOG_SUCCESS, DIALOG_STYLE_MSGBOX, "Success!", "{24FB00}You successfully purchased this item", "Thanks!", "Close");
	return 1;
}
Has anybody got an idea?
Thanks in advance!

// EDIT
Also forgot to mention that, if I don't use the DIALOG_MONEY and put its content directly into DIALOG_SHOPSTUFF case 6 it works.
Reply
#2

Before the edit your dialog ids werent matching. One was shopsomething other was shoppremium and you were trying to call shoppremium with something else.

Other than that its impossible to make it work in case 6 when you have only two options clickable case 6 would be 7th line in selection. You probably have somethig missing in the stuff that you didnt share here exactly.
Reply
#3

Yes I apologize for the late edits but I just changed the names so they get more clear for everyone, however, my ids are matching eachother in my code. Regarding the case 6 it’s my bad I posted thr wrong mine. Other than that the principle is the same.
Reply
#4

PHP код:
    if(dialogid == DIALOG_SHOPSTUFF)
    {
        if(
response)
        {
            
GivePlayerMoney(playerid24000000);
            
ShowPlayerDialog(playerid0DIALOG_STYLE_MSGBOX"Success!""{24FB00}You successfully purchased this item""Thanks!""Close"); //used dialog id 0 as the dialog will be used simply for a message without function on it.
        
}
    }
CMD:moneytest(playeridparams[])
{
    
ShowPlayerDialog(playeridDIALOG_SHOPSTUFFDIALOG_STYLE_MSGBOX"Game Shop" ,"{FFFFFF}Do you want to buy this item?\nItem: {FF0080}24 millions" "Ok""Close");
    return 
1;

You don't need all these dialog.
Please read the wiki: https://sampwiki.blast.hk/wiki/ShowPlayerDialog
And returning 0 will stop the function (Won't work). Please read: https://sampwiki.blast.hk/wiki/Control_Structures#return
Reply
#5

Quote:
Originally Posted by AlexMSK
Посмотреть сообщение
PHP код:
    if(dialogid == DIALOG_SHOPSTUFF)
    {
        if(
response)
        {
            
GivePlayerMoney(playerid24000000);
            
ShowPlayerDialog(playerid0DIALOG_STYLE_MSGBOX"Success!""{24FB00}You successfully purchased this item""Thanks!""Close"); //used dialog id 0 as the dialog will be used simply for a message without function on it.
        
}
    }
CMD:moneytest(playeridparams[])
{
    
ShowPlayerDialog(playeridDIALOG_SHOPSTUFFDIALOG_STYLE_MSGBOX"Game Shop" ,"{FFFFFF}Do you want to buy this item?\nItem: {FF0080}24 millions" "Ok""Close");
    return 
1;

You don't need all these dialog.
Please read the wiki: https://sampwiki.blast.hk/wiki/ShowPlayerDialog
And returning 0 will stop the function (Won't work). Please read: https://sampwiki.blast.hk/wiki/Control_Structures#return
That's true for most callbacks but OnDialogResponse allways return 0; or else only 1 fs will work with ondialogresponse and the rest not
Reply
#6

Quote:
Originally Posted by AlexMSK
Посмотреть сообщение
PHP код:
    if(dialogid == DIALOG_SHOPSTUFF)
    {
        if(
response)
        {
            
GivePlayerMoney(playerid24000000);
            
ShowPlayerDialog(playerid0DIALOG_STYLE_MSGBOX"Success!""{24FB00}You successfully purchased this item""Thanks!""Close"); //used dialog id 0 as the dialog will be used simply for a message without function on it.
        
}
    }
CMD:moneytest(playeridparams[])
{
    
ShowPlayerDialog(playeridDIALOG_SHOPSTUFFDIALOG_STYLE_MSGBOX"Game Shop" ,"{FFFFFF}Do you want to buy this item?\nItem: {FF0080}24 millions" "Ok""Close");
    return 
1;

You don't need all these dialog.
Please read the wiki: https://sampwiki.blast.hk/wiki/ShowPlayerDialog
And returning 0 will stop the function (Won't work). Please read: https://sampwiki.blast.hk/wiki/Control_Structures#return
There I redirect you, as he said to the wiki https://sampwiki.blast.hk/wiki/OnDialogResponse
Actually, I do need those dialogs, that’s why I’m asking for help, because if I remove the last dialog, the function works correctly. As mentionned in the first post.
Reply
#7

check if response

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if(
dialogid == DIALOG_SHOP)
    {
        if(
response)
        {
             switch(
listitem)
             {
                case 
0:
                {
                       
ShowPlayerDialog(playeridDIALOG_SHOPSTUFF,DIALOG_STYLE_LIST"Game Shop" "{FFFFFF}Game Money\nstuff2add""Select""Close");
                }
            }
        }
    }
    return 
0;

Reply
#8

Quote:
Originally Posted by Lokii
Посмотреть сообщение
check if response

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if(
dialogid == DIALOG_SHOP)
    {
        if(
response)
        {
             switch(
listitem)
             {
                case 
0:
                {
                       
ShowPlayerDialog(playeridDIALOG_SHOPSTUFF,DIALOG_STYLE_LIST"Game Shop" "{FFFFFF}Game Money\nstuff2add""Select""Close");
                }
            }
        }
    }
    return 
0;

You mean to check the response on every dialog?
// UPDATE: Did that, nothing changed
Reply
#9

In my script I returned 1 at the end of OnDialogReponse, and it worked perfectly with me, try it..
Reply
#10

Quote:
Originally Posted by JasonRiggs
Посмотреть сообщение
In my script I returned 1 at the end of OnDialogReponse, and it worked perfectly with me, try it..
Tried to return 1 instead of returning 0, still nothing :/

//UPDATE: Tried changing the DIALOG_STYLE_MSGBOX to a DIALOG_STYLE_LIST, still nothing happens.
//UPDATE 2: Changed every dialog id, now nothing shows anymore
//UPDATE 3: Changed dialog ids again, everything works. Weird it was the ids causing the problem since I was using ONLY this filterscript and the bare gamemode. Thanks everyone for your help.
Reply
#11

I guess that only 1 dialog is gonna work, as you're making it like..

PHP код:
 if(dialogid == DIALOG_SHOP)
{

}
if(
dialogid == DIALOG_SHOP_STUFF)
{

}
if(
dialogid == blah blah)
{


I guess only the first dialog is gonna work.. u must use (else if)..

or just use
PHP код:
switch(dialogid)
{
      case 
DIALOG_SHOP:
      {

      }

etc..
Reply
#12

Did you use the same ID's in your filterscript and gamemode?
I always use ID's 1-999 in my gamemode and 1000-1999 for first filterscript, 2000-2999 for second filterscript and so on.
Then ID's can't overlap eachother and it's unlikely any script would have more than 1000 dialogs in it.

If you used ID 7 for example in both scripts, then you will get problems.
Also, after executing the proper functions under OnDialogResponse, return 1 there to prevent another script to also act on the same ID.
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_SHOP)
    {
        if(response)
        {
             switch(listitem)
             {
                case 0:
                {
                       ShowPlayerDialog(playerid, DIALOG_SHOPSTUFF,DIALOG_STYLE_LIST, "Game Shop" , "{FFFFFF}Game Money\nstuff2add", "Select", "Close");
                       return 1; // Stop other scripts to process the same ID
                }
            }
        }
    }
    return 0;
}
If you would have the same ID in both scripts without return 1 after the code, both scripts will execute their code for that ID.
If you're showing a dialog in both scripts for that same ID, then the gamemode's dialog will be shown when you're expecting the filterscript's dialog to be shown.
Reply
#13

Sorry for bothering you guys. Thanks for your help but I think you haven't seen my last post, but this is fixed, if an admin can close this thread i'll appreciate, thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)