After switch(dialogid) I get errors.
#1

I'm working on dialogs for a script I'm doing. After switch(dialogid) I get 4 errors and a warning. Here's the code.
Код:
(line 995) public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(response)
	{
	    switch(dialogid)
	    {
			if(dialogid == electronics_shop_dialog)
 			{
  				if(listitem == 0) //Walkie Talkie
				{
  					if(PlayerInfo[playerid][pWalkie] == 0)
    		 		{
						PlayerInfo[playerid][pWalkie]++;
					}
					if(PlayerInfo[playerid][pWalkie] == 1)
					{
   						SendClientMessage(playerid, COLOR_GREY, "You already own a walkie talkie!");
					}
				}
				if(listitem == 1) //Scanner
				{
					if(PlayerInfo[playerid][pScanner] == 0)
					{
					PlayerInfo[playerid][pScanner]++;
					}
					if(PlayerInfo[playerid][pScanner] == 1)
					{
						SendClientMessage(playerid, COLOR_GREY, "You already own a scanner!");
					}
				}
    		}
			return 1;
		}
	}
	return 1;
}(line 1030)
I do have a define for the dialogid
Код:
#define electronics_shop_dialog
Here are errors/warning:
Код:
C:\Documents and Settings\GLB\My Documents\Dropbox\Scripts\Gavin\gamemodes\script.pwn(1001) : error 002: only a single statement (or expression) can follow each "case"
C:\Documents and Settings\GLB\My Documents\Dropbox\Scripts\Gavin\gamemodes\script.pwn(1001) : error 029: invalid expression, assumed zero
C:\Documents and Settings\GLB\My Documents\Dropbox\Scripts\Gavin\gamemodes\script.pwn(1001 -- 1003) : warning 215: expression has no effect
C:\Documents and Settings\GLB\My Documents\Dropbox\Scripts\Gavin\gamemodes\script.pwn(1003) : error 001: expected token: ";", but found "if"
C:\Documents and Settings\GLB\My Documents\Dropbox\Scripts\Gavin\gamemodes\script.pwn(1003) : fatal error 107: too many error messages on one line
Thank you very much in advance for any help/answers.
Reply
#2

can you show line 1001 please?
Reply
#3

You need to assign a value to your define, duh. Or use enums like explained on the wiki page. Also a switch works with cases, so replace
pawn Код:
if(dialogid == electronics_shop_dialog)
with
pawn Код:
case electronics_shop_dialog:
Reply
#4

Line 1001 is this line
if(dialogid == electronics_shop_dialog)
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
You need to assign a value to your define, duh. Or use enums like explained on the wiki page. Also a switch works with cases, so replace
pawn Код:
if(dialogid == electronics_shop_dialog)
with
pawn Код:
case electronics_shop_dialog:
Fixed! Thanks, reputation given.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)