if statement problem with enum value
#1

OK, for some reason I'm getting a tag missmatch on this:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/admin") && pInMenu[playerid][inAdmin] == false) /////// warning 213: tag mismatch
    {
        print("Cool");
    }
    return 1;
}


heres the enum code

pawn Код:
enum pMenu
{
    inVip = false,
    inAdmin = false
}
new pInMenu[MAX_PLAYERS][pMenu];
I feel stupid that I don't know whats wrong
Reply
#2

Only booleans can be 'true' or 'false.

Try this
pawn Код:
enum pMenu
{
    bool:inVip = false,
    bool:inAdmin = false
}
new pInMenu[MAX_PLAYERS][pMenu];
Reply
#3

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
Only booleans can be 'true' or 'false.

Try this
pawn Код:
enum pMenu
{
    bool:inVip = false,
    bool:inAdmin = false
}
new pInMenu[MAX_PLAYERS][pMenu];
oh forgot to define them lol.

Sorry Im still in the process of getting used to this language.

Rep+
Reply
#4

Using booleans restricts your enum value to either a true or false statement, meaning you cannot define things like admin levels.
Reply
#5

Quote:
Originally Posted by warcodes_
Посмотреть сообщение
Using booleans restricts your enum value to either a true or false statement, meaning you cannot define things like admin levels.
Don't worry, this has nothing to do with admin lvls.
Its just a check to see if the player is already in a menu, so It doesn't open another menu. Im using text draws to display commands, so I dont want them displaying over eachother.
Reply
#6

Quote:
Originally Posted by LeetModz
Посмотреть сообщение
Don't worry, this has nothing to do with admin lvls.
Its just a check to see if the player is already in a menu, so It doesn't open another menu. Im using text draws to display commands, so I dont want them displaying over eachother.
Ah, i can see what you are trying to do now, other then using text draw/s to show list/s of command/s, that is a very efficient way to do so.

But i do suggest rBits for this process, as it will double the efficiency in that structure.
Reply
#7

Quote:
Originally Posted by warcodes_
Посмотреть сообщение
Ah, i can see what you are trying to do now, other then using text draw/s to show list/s of command/s, that is a very efficient way to do so.

But i do suggest rBits for this process, as it will double the efficiency in that structure.
Could you give me an example of how to use it? looks pretty confusing.

Thanks for your input
Reply
#8

Quote:
Originally Posted by LeetModz
Посмотреть сообщение
Could you give me an example of how to use it? looks pretty confusing.

Thanks for your input
https://sampforum.blast.hk/showthread.php?tid=275142&page=10 <--- Everything is explained in the thread.
Reply
#9

Quote:
Originally Posted by ******
Посмотреть сообщение
That's not how enums work! You can't define default values like that at the enum level because they don't do what you think. Enums define array slots, so that code will create a 1-cell array with two names for slot 0 (i.e. put all your data in the same place).

You could do:

pawn Код:
enum pMenu (<<= 1)
{
    inVip = 1,
    inAdmin
}
new pMenu:pInMenu[MAX_PLAYERS];
To compress the data. Or, as warcodes_ said there's rBits, or YSI has a bit system (y_bit).
I am not quite understanding what you mean about "You can't define default values", isnt inVip = 1, defining a default value?
lol so confused.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)