SA-MP Forums Archive
Dialog not working - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Dialog not working (/showthread.php?tid=370817)



Dialog not working - martin149 - 21.08.2012

When i use the following code, a dialog will show up but no action is being taken. It probably is a minor glitch.

pawn Код:
#include <a_samp>

#define DIALOG_HOME 1
#define FILTERSCRIPT




public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/menu", cmdtext, true) == 0)
    {
        ShowPlayerDialog(playerid, DIALOG_HOME, DIALOG_STYLE_LIST, "Home Menu", "Kill\nHeal\nWeapons\nCars\nTeleport", "Ok", "Cancel");
        return 1;
    }
    return 0;
}


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_HOME)
    {
        switch(listitem)
        {
            case 0:{SetPlayerHealth(playerid, 0.0);}
            case 1:{SetPlayerHealth(playerid, 100.0); SetPlayerArmour(playerid, 100.0);}
            case 2:{SetPlayerHealth(playerid, 0.0);}
            case 3:{SetPlayerHealth(playerid, 0.0);}
            case 4:{SetPlayerHealth(playerid, 0.0);}

        }
    }
    return 1;
}



Re: Dialog not working - clarencecuzz - 21.08.2012

Try:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_HOME)
    {
        if(response)
        {
            switch(listitem)
            {
                case 0:{SetPlayerHealth(playerid, 0.0);}
                case 1:{SetPlayerHealth(playerid, 100.0); SetPlayerArmour(playerid, 100.0);}
                case 2:{SetPlayerHealth(playerid, 0.0);}
                case 3:{SetPlayerHealth(playerid, 0.0);}
                case 4:{SetPlayerHealth(playerid, 0.0);}
            }
        }
    }
    return 1;
}



Re: Dialog not working - martin149 - 21.08.2012

Nope sorry, still no response


Re: Dialog not working - clarencecuzz - 21.08.2012

I've experienced this recently, I still have no idea what causes it to not respond, but it could be outdated plugins... if that's possibly affecting it, I'm not sure. Also, make sure your dialog ID's are not conflicting in another filterscript/gamemode. If you have two scripts that both use the same dialog ID, 2 for example, most likely one will respond to the opposite dialog, giving you a completely random, unexpected or no response at all.


Re: Dialog not working - martin149 - 21.08.2012

Thank you, excluding all other filtersctipts worked, now i am going to try to find the problem


Re : Dialog not working - ricardo178 - 21.08.2012

Try this...

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_HOME)
    {
        if(!response) return 1;
        switch(listitem)
        {
            case 0:
            {
                SetPlayerHealth(playerid, 0.0);
                return 1;
            }
            case 1:
            {
                SetPlayerHealth(playerid, 100.0);
                SetPlayerArmour(playerid, 100.0);
                return 1;
            }
            case 2:
            {
                SetPlayerHealth(playerid, 0.0);
                return 1;
            }
            case 3:
            {
                SetPlayerHealth(playerid, 0.0);
                return 1;
            }
            case 4:
            {
                SetPlayerHealth(playerid, 0.0);
                return 1;
            }
        }
    }
    return 1;
}



Re: Dialog not working - Zaila - 21.08.2012

If you are using OnDialogResponse in several loaded filterscripts, change 'return 1;' to 'return 0;' in the very end of the callback in every filterscript.

By using 'return 1' in the very end of OnDialogResponse, it will stop checking other filterscripts except of the first loaded with OnDialogResponse, even if the target dialog ID is not inthat script.


Re: Dialog not working - clarencecuzz - 21.08.2012

Quote:
Originally Posted by Zaila
Посмотреть сообщение
If you are using OnDialogResponse in several loaded filterscripts, change 'return 1;' to 'return 0;' in the very end of the callback in every filterscript.

By using 'return 1' in the very end of OnDialogResponse, it will stop checking other filterscripts except of the first loaded with OnDialogResponse, even if the target dialog ID is not inthat script.
Oh lol, I didn't even realise that. Nice spotting. SA-MP wiki and many other scripters would also recommend that you return 0 when using OnDialogResponse.

http://www.wiki.sa-mp.com/wiki/OnDialogResponse