View Single Post
XSlayer
Member
Join Date: Dec 2021
Old 07-26-2022 , 04: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 05:28. Reason: Solved
XSlayer is offline