Raised This Month: $ Target: $400
 0% 

[Q] The & operator, right way use (1 2 4 8 16) ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-18-2011 , 11:22   [Q] The & operator, right way use (1 2 4 8 16) ?
Reply With Quote #1

Noob question, didn't found clear answer for this method.

Is this the right way use & operator ?
I want to get cvar work same way as Sourcemod
Code:
// Default: 13 (1+4+8)
sm_show_activity 13
Here example
PHP Code:
new Handle:sm_chatannouncements INVALID_HANDLE;
new 
g_chatannouncements;

public 
OnPluginStart()
{
    
sm_chatannouncements CreateConVar("sm_chatannouncements""1""0 = off\n 1 = Show 1\n 2 = Show 2\n 4 = Show 4\n 8 = Show 8\n 16 = Show 16");
    
g_chatannouncements GetConVarInt(sm_chatannouncements);
    
HookConVarChange(sm_chatannouncementsConVarChanged);
}

public 
ConVarChanged(Handle:convar, const String:oldValue[], const String:newValue[])
{
    
g_chatannouncements GetConVarInt(sm_chatannouncements);
}

public 
OnClientPostAdminCheck(client)
{

    if(
g_chatannouncements 1)
    {
        
PrintToServer("Show 1");
    }

    if(
g_chatannouncements 2)
    {
        
PrintToServer("Show 2");
    }

    if(
g_chatannouncements 4)
    {
        
PrintToServer("Show 4");
    }

    if(
g_chatannouncements 8)
    {
        
PrintToServer("Show 8");
    }

    if(
g_chatannouncements 16)
    {
        
PrintToServer("Show 16");
    }

Bacardi is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 03-18-2011 , 11:29   Re: [Q] The & operator, right way use (1 2 4 8 16) ?
Reply With Quote #2

Quote:
Originally Posted by Bacardi View Post
Is this the right way use & operator ?
looks like yea
__________________
Leonardo is offline
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 03-18-2011 , 11:31   Re: [Q] The & operator, right way use (1 2 4 8 16) ?
Reply With Quote #3

This may help: http://www.c-point.com/javascript_tu...bitwiseand.htm
Remember that a non-zero number is true when evaluated in an if statement.
Wazz is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-20-2011 , 04:09   Re: [Q] The & operator, right way use (1 2 4 8 16) ?
Reply With Quote #4

Quote:
Originally Posted by Wazz View Post
This may help: http://www.c-point.com/javascript_tu...bitwiseand.htm
Remember that a non-zero number is true when evaluated in an if statement.
Dam, that take me while understand , need drink.
http://www.tutorvista.com/math/non-zero-numbers
Now I get it, ...-3 -2 -1 | 1 2 3...
Bacardi 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 02:03.


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