SA-MP Forums Archive
Need some help to get this 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Need some help to get this working... (/showthread.php?tid=233504)



Need some help to get this working... - cloudysky - 01.03.2011

I am trying to get this Dialog working.

pawn Code:
command(help, playerid, params[])
{
    {
        ShowPlayerDialog( playerid, 100, DIALOG_STYLE_LIST, "Help Menu", "Commands\nRules\n", "Select", "Cancel" );
    }
    return 1;
}

And this bit was from SAMP Wiki.

pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(100)
    {
        case 1:
        {
            if(!response)
            {
                SendClientMessage(playerid, YELLOW, "You cancelled.");
                return 1;
            }

            switch(listitem)
            {
                case 0:
                {
                    SendClientMessage(playerid, YELLOW, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" );
                    SendClientMessage(playerid, WHITE, "commands go here" );
                    SendClientMessage(playerid, YELLOW, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" );
                }
                case 1:
                {
                    SendClientMessage(playerid, YELLOW, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" );
                    SendClientMessage(playerid, WHITE, "rules go here" );
                    SendClientMessage(playerid, YELLOW, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" );
                }
            }
        }
    }
    return 1;
}
I get no errors but when i go in game it doesn't work. Anyone know the problem?


Re: Need some help to get this working... - JaTochNietDan - 01.03.2011

Your usage of the switch statement is wrong, you need to perform it on the dialogid and then check if the case is 100, which means the dialogid was 100! Like so:

pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case 100:
        {
            if(!response)
            {
                SendClientMessage(playerid, YELLOW, "You cancelled.");
                return 1;
            }

            switch(listitem)
            {
                case 0:
                {
                    SendClientMessage(playerid, YELLOW, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" );
                    SendClientMessage(playerid, WHITE, "commands go here" );
                    SendClientMessage(playerid, YELLOW, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" );
                }
                case 1:
                {
                    SendClientMessage(playerid, YELLOW, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" );
                    SendClientMessage(playerid, WHITE, "rules go here" );
                    SendClientMessage(playerid, YELLOW, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" );
                }
            }
        }
    }
    return 1;
}
I hope this makes sense and helps.