Using switch for variables of an Enum
#1

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?
Reply


Messages In This Thread
Using switch for variables of an Enum - by Giovanni - 21.12.2011, 20:20
Re: Using switch for variables of an Enum - by Tee - 21.12.2011, 20:24
AW: Re: Using switch for variables of an Enum - by Giovanni - 21.12.2011, 20:25

Forum Jump:


Users browsing this thread: 1 Guest(s)