SA-MP Forums Archive
(22169) : error 002: only a single statement (or expression) can follow each "case" - 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: (22169) : error 002: only a single statement (or expression) can follow each "case" (/showthread.php?tid=369288)



(22169) : error 002: only a single statement (or expression) can follow each "case" - Adam_Hardy - 16.08.2012

(22169) : error 002: only a single statement (or expression) can follow each "case"



Line 22169:

Code:
		case 29: // ARMY Armory
		{
		    ShowPlayerDialog(playerid, 29, DIALOG_STYLE_LIST, "Army Lockers", "Nightstick ($50)\nMace ($100)\nDesert Eagle ($200)\nShotgun ($100)\nMP5 ($600)\nM4 ($1000)\nCombat Shotgun ($1500)\nSniper Rifle ($2500)\nPainkiller ($100)\nVest ($200)", "Choose", "Cancel");
        }
	return 1;
}



Re: (22169) : error 002: only a single statement (or expression) can follow each "case" - Ranama - 16.08.2012

You'll have to end the switch statement before setting return 1, like this
Code:
case 29: // ARMY Armory
		{
		    ShowPlayerDialog(playerid, 29, DIALOG_STYLE_LIST, "Army Lockers", "Nightstick ($50)\nMace ($100)\nDesert Eagle ($200)\nShotgun ($100)\nMP5 ($600)\nM4 ($1000)\nCombat Shotgun ($1500)\nSniper Rifle ($2500)\nPainkiller ($100)\nVest ($200)", "Choose", "Cancel");
               }
       }
	return 1;
}
Hope it helped


Re: (22169) : error 002: only a single statement (or expression) can follow each "case" - ddnbb - 16.08.2012

Looks like you are missing a bracket there? '}'

EDIT: Ranama was few seconds faster than me.


Re: (22169) : error 002: only a single statement (or expression) can follow each "case" - RanSEE - 16.08.2012

Code:
Lets make it easier

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_MAIN)
    {
        if(!response) return SendClientMessage(playerid, -1, "Lucky to have this code in my pc already");

        switch(listitem)
        {
            case 27:
            {
                ShowPlayerDialog(playerid, 29, DIALOG_STYLE_LIST, "Army Lockers", "Nightstick ($50)\nMace ($100)\nDesert Eagle ($200)\nShotgun ($100)\nMP5 ($600)\nM4 ($1000)\nCombat Shotgun ($1500)\nSniper Rifle ($2500)\nPainkiller ($100)\nVest ($200)", "Choose", "Cancel");
            }
       
            }
        } //this was missing
        if(dialogid == DIALOG_SHOP)
        {
        
            switch(listitem)
            {
                case 0:
                {
                    SetPlayerPos(playerid, add-whatever you wish);
                }