must be a constant expression; assumed zero
#1

Hi, I've bumped into this error:
Code:
must be a constant expression; assumed zero
On the marked lines:
Code:
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
	switch (pickupid)
	{
		case PlayerInfo[playerid][pPickup][0]:
		{
			if (PlayerInfo[playerid][pInAirport])
			{
				DestroyDynamicPickup(PlayerInfo[playerid][pPickup][0]);
				DestroyDynamicObject(PlayerInfo[playerid][pBaggageObject]);
				
				SetPlayerAttachedObject(playerid, 0, 11745, 6, 0.216000, 0.035000, 0.017999, -83.600013, -94.400039, -6.899996, 0.632999, 1.093000, 1.214999);
				PlayerPlaySound(playerid, 1149, 0.0, 0.0, 0.0);
				SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have collected your baggage, please proceed to the exit (white arrows).");

				PlayerInfo[playerid][pPickup][1] = CreateDynamicPickup(1318, 23, 1727.2003, -2368.4248, -73.3924, AIRPORT_WORLD, 0, playerid);
				PlayerInfo[playerid][pPickup][2] = CreateDynamicPickup(1318, 23, 1719.7932,-2368.6470,-73.3924, AIRPORT_WORLD, 0, playerid);
			}
		}
		case PlayerInfo[playerid][pPickup][1], PlayerInfo[playerid][pPickup][2]:
		{
			if (PlayerInfo[playerid][pInAirport])
			{
				DestroyDynamicPickup(PlayerInfo[playerid][pPickup][1]);
				DestroyDynamicPickup(PlayerInfo[playerid][pPickup][2]);
				RemovePlayerAttachedObject(playerid, 0);
				
				PlayerInfo[playerid][pInAirport] = 0;
				
				SetPlayerVirtualWorld(playerid, 0);
				SetPlayerPos(playerid, 1642.3411, -2238.3843, 13.4976);
				SetPlayerFacingAngle(playerid, 180.0);
				SetCameraBehindPlayer(playerid);
				
				ClearChat(playerid);
				
				SendClientMessage(playerid, COLOR_LIGHTBLUE, "Welcome to Los Santos Life Roleplay!");
				SendClientMessage(playerid, COLOR_LIGHTBLUE, "If you need help getting around in the server, then please type /guide.");
				SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have been given $2500 to get started.");

				GiveMoney(playerid, 2500);
			}
		}
	}
	return 1;
}
I know I can't do it like that and I can do that with an if statement, but is it the only way? I would like to use a switch for that because I'm pretty sure I will make more pickups this way.
Reply
#2

Quote:
Originally Posted by pawn-lang
Each \case clause" starts with the keyword case followed by a constant
list and one statement. The constant list is a series of expressions,
separated by comma's, that each evaluates to a constant value. The
constant list ends with a colon. To specify a \range" in the constant
list, separate the lower and upper bounds of the range with a double
period (\.."). An example of a range is: \case 1..9:".
"[...] followed by a constant list and one statement."

ye so thats how it is and there's no way of "fiddling" your way around that,
has to be a (or list of) constant value/s.
that's just how it is

but ya ik how you feel, back in the day i've also been trying all kinds of things,
wondering if it'll work differently too. Just stay curious and play around
Reply
#3

Take advantage of streamer functions Streamer_GetIntData/Streamer_SetIntData and item data E_STREAMER_EXTRA_ID.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)