SA-MP Forums Archive
Problem with code - 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: Problem with code (/showthread.php?tid=419882)



Problem with code - Heater - 02.03.2013

Код:
stock GetInvNameByID( playerid )
{
	

	new
	    name[ 65 ];
	new id;
	switch ( id )
	{
	    case PlayerInfo[playerid][Food_Meat] : name = "MEAT";

	    default            : name = "Empty";
	}

	return name;
}
I'm getting error:
Код:
error 008: must be a constant expression; assumed zero
Line: case PlayerInfo[playerid][Food_Meat] : name = "MEAT";


Re: Problem with code - KeenanRitchie - 02.03.2013

Maybe Tying case 1: PlayerInfo[playerid][Food_Meat] : name = "MEAT";


Re: Problem with code - Heater - 02.03.2013

I'm getting more errors


Re: Problem with code - KeenanRitchie - 02.03.2013

show errors?


Re: Problem with code - Heater - 02.03.2013

warning 215: expression has no effect
error 001: expected token: ";", but found ":"
error 014: invalid statement; not in switch
error 029: invalid expression, assumed zero
error 010: invalid function or declaration
error 033: array must be indexed (variable "name")


Re: Problem with code - KeenanRitchie - 02.03.2013

Try That
case 0: format(PlayerInfo[playerid][Food_Meat] : name = "MEAT");


Re: Problem with code - Heater - 02.03.2013

Wtf format?


Re: Problem with code - Catalyst- - 02.03.2013

You can't use variables as a switch case, you must use a static value.