AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Bit use in pcvar (https://forums.alliedmods.net/showthread.php?t=223192)

Mauricio Frb 08-10-2013 17:50

Bit use in pcvar
 
Ham, I want to know how can I use bit to check a cvar.

For who didn't understand:
Quote:

Originally Posted by ConnorMcLeod (Post 2006614)
Since 3 is 1 | 2, or 1<<0 | 1<<1, same, use bit check instead of :

if(get_pcvar_num(g_mode) == 1 || get_pcvar_num(g_mode) == 3)

and

if(get_pcvar_num(g_mode) == 2 || get_pcvar_num(g_mode) == 3)


Arkshine 08-10-2013 18:22

Re: Bit use in pcvar
 
Use &.

Mauricio Frb 08-10-2013 19:22

Re: Bit use in pcvar
 
Thx.

For those that have doubts.

Code:

#define GIVEBPAMMO_BUYWEAPON        (1<<0)
#define GIVEBPAMMO_NEWROUND        (1<<1)

if(get_pcvar_num(g_mode) & GIVEBPAMMO_BUYWEAPON)

if(get_pcvar_num(g_mode) & GIVEBPAMMO_NEWROUND)

Plugin link: https://forums.alliedmods.net/showthread.php?t=221900


All times are GMT -4. The time now is 15:56.

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