Dialog not working
#1

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

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

Nope sorry, still no response
Reply
#4

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

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

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

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)