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 SetVarStatus( bool: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 bitsum( Client )
{
if(!CheckPlayerBit( BitSumTest, Client )) // if is false
{
SetPlayerBit(BitSumTest, Client);
client_print( Client, print_chat, "BitSum Status: %d", CheckPlayerBit( BitSumTest, Client )); // setting to true
}
else // if is true
{
ClearPlayerBit(BitSumTest, Client);
client_print( Client, print_chat, "BitSum Status: %d", CheckPlayerBit( BitSumTest, Client )); // setting to false
}
return 1;
}