if statement problem with enum value -
LeetModz - 30.04.2012
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
Re: if statement problem with enum value -
ReneG - 30.04.2012
Only
booleans can be 'true' or 'false.
Try this
pawn Код:
enum pMenu
{
bool:inVip = false,
bool:inAdmin = false
}
new pInMenu[MAX_PLAYERS][pMenu];
Re: if statement problem with enum value -
LeetModz - 30.04.2012
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+
Re: if statement problem with enum value -
warcodes_ - 30.04.2012
Using booleans restricts your enum value to either a true or false statement, meaning you cannot define things like admin levels.
Re: if statement problem with enum value -
LeetModz - 30.04.2012
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.
Re: if statement problem with enum value -
warcodes_ - 30.04.2012
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.
Re: if statement problem with enum value -
LeetModz - 30.04.2012
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
Re: if statement problem with enum value -
warcodes_ - 30.04.2012
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.
Re: if statement problem with enum value -
LeetModz - 30.04.2012
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.