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
#2

You can only use integers (although the pickup ID should return a value).
Reply
#3

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


Forum Jump:


Users browsing this thread: 2 Guest(s)