AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Adding, removing, checking bitsums (https://forums.alliedmods.net/showthread.php?t=55691)

Cheap_Suit 05-27-2007 18:09

Adding, removing, checking bitsums
 
I was just wondering if I did this the correct way.

PHP Code:

#define FLAG_A (1<<0)
#define FLAG_B (1<<1)
#define FLAG_C (1<<2)
 
stock get_player_flags(idflags)
 return (
g_user_flags[id] & flags)
 
stock set_player_flags(idflags)
 return 
g_user_flags[id] |= flags
 
// add
set_player_flags(idFLAG_A)
 
// remove
set_player_flags(id, ~FLAG_B)
 
// check
if(!get_player_flags(idFLAG_C))
  return 


regalis 05-27-2007 21:28

Re: Adding, removing, checking bitsums
 
Quote:

Originally Posted by Cheap_Suit (Post 482635)
I was just wondering if I did this the correct way.

PHP Code:

#define FLAG_A (1<<0)
#define FLAG_B (1<<1)
#define FLAG_B (1<<2)
 
stock get_player_flags(idflags)
 return (
g_user_flags[id] & flags)
 
stock set_player_flags(idflags)
 return 
g_user_flags[id] |= flags
 
// add
set_player_flags(idFLAG_A)
 
// remove
set_player_flags(id, ~FLAG_B)
 
// check
if(!get_player_flags(idFLAG_C))
  return 


Sorry i don't know anything about bitsum stuff the only flaw is a typo because you define 2 times FLAG_B :wink:
But it looks correct..0o

greetz regalis

teame06 05-27-2007 23:58

Re: Adding, removing, checking bitsums
 
Everything else is right except for removing.

Code:
var &= ~FLAG_C

Cheap_Suit 05-28-2007 00:27

Re: Adding, removing, checking bitsums
 
Ah thanks


All times are GMT -4. The time now is 10:41.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.