Something new in enums -
wups - 29.08.2011
I've been reading up the wiki, and saw something new:
pawn Код:
enum (<<= 1)
{
TEAM_NONE,
TEAM_COP = 1,
TEAM_ROBBER,
TEAM_CIV,
TEAM_CLERK,
TEAM_DRIVER,
TEAM_ADMIN
}
, as it stated, you can use a few teams in a variable like this:
pawn Код:
gPlayerTeam[playerid] |= TEAM_COP;
So, my question is, can i add unlimited items like that? Would be nice to store my whole player inventory in one variable
Re: Something new in enums -
Darnell - 29.08.2011
Probably, check it.
Re: Something new in enums -
wups - 29.08.2011
Quote:
Originally Posted by Darnell
Probably, check it.
|
Thanks for the info.. I don't want responses like that!
Re: Something new in enums -
Babul - 29.08.2011
afaik, this method is for checking a bit for true or false. if iam not wrong, its possible to store 32 teams in a single cell this way. (4 bytes == 32 bits)..
oh, iam not sure about the enumerator increasement.. the <<= is a logical shift, isnt it? so the enum would power up the values by shifting the "adressed" bit to be these values: 1, 2, 4, 8, 16, 32.. so 0b00000001=TEAM_COP, 0b00000010=TEAM_ROBBER, and 0b00000100=TEAM_CIV...
0b00000111 would be 7 (1+2+4), or the 3 teams gathered together
Re: Something new in enums -
wups - 29.08.2011
Quote:
Originally Posted by Babul
afaik, this method is for checking a bit for true or false. if iam not wrong, its possible to store 32 teams in a single cell this way. (4 bytes == 32 bits)..
oh, iam not sure about the enumerator increasement.. the <<= is a logical shift, isnt it? so the enum would power up the values by shifting the "adressed" bit to be these values: 1, 2, 4, 8, 16, 32.. so 0b00000001=TEAM_COP, 0b00000010=TEAM_ROBBER, and 0b00000100=TEAM_CIV...
0b00000111 would be 7 (1+2+4), or the 3 teams gathered together
|
Thanks! So what is the correct way for the enum increasement?
Re: Something new in enums -
Bakr - 29.08.2011
Quote:
Originally Posted by wups
Thanks! So what is the correct way for the enum increasement?
|
The way it is displayed on the Wiki (how you have it here) is perfectly fine. Also, this is not new :P
I've never read or heard of a limit on enumerations in the Pawn documentation. I would assume the maximum amount you could store would be unlimited. However, I don't see how you would store all player inventory in one variable.
Re: Something new in enums -
wups - 29.08.2011
Quote:
Originally Posted by Bakr
The way it is displayed on the Wiki (how you have it here) is perfectly fine. Also, this is not new :P
I've never read or heard of a limit on enumerations in the Pawn documentation. I would assume the maximum amount you could store would be unlimited. However, I don't see how you would store all player inventory in one variable.
|
New for me ^^
The same way, the wiki stores player teams in one variable. No, I won't store stackable items, if that's what you had in mind. By one variable i meant one variable per player..
Re: Something new in enums -
Bakr - 29.08.2011
Quote:
Originally Posted by wups
New for me ^^
The same way, the wiki stores player teams in one variable. No, I won't store stackable items, if that's what you had in mind. By one variable i meant one variable per player..
|
Edit: Yes, I completely misunderstood, sorry.