Raised This Month: $ Target: $400
 0% 

Bit use in pcvar


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mauricio Frb
Member
Join Date: Jul 2013
Old 08-10-2013 , 17:50   Bit use in pcvar
Reply With Quote #1

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

For who didn't understand:
Quote:
Originally Posted by ConnorMcLeod View Post
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)
Mauricio Frb is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-10-2013 , 18:22   Re: Bit use in pcvar
Reply With Quote #2

Use &.
__________________
Arkshine is offline
Mauricio Frb
Member
Join Date: Jul 2013
Old 08-10-2013 , 19:22   Re: Bit use in pcvar
Reply With Quote #3

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
Mauricio Frb is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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