Using switch for variables of an Enum - 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: Using switch for variables of an Enum (
/showthread.php?tid=305258)
Using switch for variables of an Enum -
Giovanni - 21.12.2011
I am kind of stuck right now. I got an enum which handles all the variables for a map, and some of those variables are in charge of some dynamic pickups.
In my case, I am using Incognito's Streamer Plugin and this is how the code looks like, which is not working:
pawn Код:
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
switch(pickupid)
{
case MapInfo[currentMap][mGoal]:
{
//Something happens here
}
}
return 1;
}
Error:
Код:
error 008: must be a constant expression; assumed zero
(Sorry, but I can't really interpret this error message)
This kind of confuses me, since this code does work:
pawn Код:
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
if(pickupid == MapInfo[currentMap][mGoal])
{
}
return 1;
}
That's how the variable looks like inside the enum:
pawn Код:
enum MY_ENUM
{
...
mGoal,
...
};
Shouldn't switch behave the same with integers like
if?
Re: Using switch for variables of an Enum -
Tee - 21.12.2011
You can only use integers (although the pickup ID should return a value).
AW: Re: Using switch for variables of an Enum -
Giovanni - 21.12.2011
Quote:
Originally Posted by Tee
You can only use integers (although the pickup ID should return a value).
|
Thought so. Thanks for the fast reply though.