Raised This Month: $12 Target: $400
 3% 

[INFO] Bitsums and Operators


Post New Thread Reply   
 
Thread Tools Display Modes
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-26-2013 , 18:17   Re: [INFO] Bitsums and Operators
Reply With Quote #71

~1 = 0xFFFFFFFE
~0 = 0xFFFFFFFF

LoL
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-08-2017 , 06:33   Re: [INFO] Bitsums and Operators
Reply With Quote #72

Quote:
Instead of
We have:
PHP Code:
if (bistum_is_alive & (1<<id))
{

Sorry for bumping but bistum ^_^
__________________
edon1337 is offline
XSlayer
Member
Join Date: Dec 2021
Old 07-26-2022 , 03:42   Re: [INFO] Bitsums and Operators
Reply With Quote #73

Great tutorial! but i have somes doubts

PHP Code:
if (bistum_is_alive & (1<<id)) // if this is checking if is user alive, how can i check is isnt alive? using this same method
{

and how can i make it more "manipulable", like

PHP Code:
 MyVar |= (1<<id// Setting to true 
         
Myvar &=  ~(1<<id)  // Setting to false 
PHP Code:
stock SetVarStatusbool:Status, Var, id )
{
    switch(
Status)
    {
        case 
true:
        {
               Var |= (
1<<id)
        }
        case 
false:
        {
               Var &=  ~(
1<<id)
        }
     }

something like this but better?

Solved:

PHP Code:
#include <amxmodx>
 
#define SetPlayerBit(%1,%2)      (%1 |= (1<<(%2&31)))
#define ClearPlayerBit(%1,%2)    (%1 &= ~(1 <<(%2&31)))
#define CheckPlayerBit(%1,%2)    (%1 & (1<<(%2&31)))

new BitSumTest;

public 
plugin_init () 

    
register_plugin"Test""1.0""XSlayer" );
    
register_clcmd"bit""bitsum" );

public 
bitsumClient )
{
       if(!
CheckPlayerBitBitSumTestClient )) // if is false
       
{
             
SetPlayerBit(BitSumTestClient);
             
client_printClientprint_chat"BitSum Status: %d"CheckPlayerBitBitSumTestClient )); // setting to true
       

       else 
// if is true
       
{
             
ClearPlayerBit(BitSumTestClient);
             
client_printClientprint_chat"BitSum Status: %d"CheckPlayerBitBitSumTestClient )); // setting to false
       
}
       return 
1;


Last edited by XSlayer; 07-26-2022 at 04:28. Reason: Solved
XSlayer is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-26-2022 , 22:33   Re: [INFO] Bitsums and Operators
Reply With Quote #74

You should provide the source for the code that you found so that 1) people can see where it came from and 2) give credit to the original author.

Source is here: https://forums.alliedmods.net/showthread.php?t=139916
__________________
fysiks is offline
Reply


Thread Tools
Display Modes

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 08:09.


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