07.03.2013, 15:30
I recently realized that bit-flags are actually used in SA-MP itself: Player keys.
There are 19 keys defined in a_samp.inc, and they are set to powers of 2 (1, 2, 4, 8, 16, 32, 64).
If you put this simple code within OnPlayerKeyStateChange:
Then you\'ll notice how this looks exactly like the use of bit-flags in this topic. For those who don\'t know, this is also why you should always check keys with & instead of ==.
@Slice: Is this where you got the inspiration for bit-flags?
There are 19 keys defined in a_samp.inc, and they are set to powers of 2 (1, 2, 4, 8, 16, 32, 64).
If you put this simple code within OnPlayerKeyStateChange:
pawn Code:
printf( "%019b", newkeys );
Then you\'ll notice how this looks exactly like the use of bit-flags in this topic. For those who don\'t know, this is also why you should always check keys with & instead of ==.
@Slice: Is this where you got the inspiration for bit-flags?