That is very weird, I thought at first it was a problem with your code but I tested it myself and you're correct. get_pcvar_num() is not returning just that one bit yet the cvar is holding the correct value including the bit. I put together a small function for you which basically reads the cvar as a string then converts to a number. It's silly to have to do it that way but get_pcvar_num() isn't working properly so it'll have to do. I don't have time now but I will look into this further and report any findings.
Output:
Code:
DEFAULT_SKIPWEAPONS=570425936
bitsum=570425936
get_cvar_num()=570425920
get_pcvar_num()=570425920
get_pcvar_string()=570425936
getcvarbits()=570425936
PHP Code:
#include <amxmodx>
const DEFAULT_SKIPWEAPONS = (1 << CSW_KNIFE) | (1 << CSW_C4) | (1 << CSW_FLASHBANG) | (1 << CSW_SMOKEGRENADE) | (1 << CSW_HEGRENADE)
public plugin_init()
{
new bitsum[ 16 ] , cvarSkipWeapons;
num_to_str(DEFAULT_SKIPWEAPONS, bitsum, charsmax(bitsum));
cvarSkipWeapons = register_cvar("jb_rebel_skipweapons", bitsum);
new szCVar[ 16 ];
server_print( "DEFAULT_SKIPWEAPONS=%d" , DEFAULT_SKIPWEAPONS );
server_print( "bitsum=%s" , bitsum );
server_print( "get_cvar_num()=%d" , get_cvar_num( "jb_rebel_skipweapons" ) );
server_print( "get_pcvar_num()=%d" , get_pcvar_num( cvarSkipWeapons ) );
get_pcvar_string( cvarSkipWeapons , szCVar , charsmax( szCVar ) );
server_print( "get_pcvar_string()=%s", szCVar );
server_print( "getcvarbits()=%d", GetCVarBits( cvarSkipWeapons ) );
}
GetCVarBits( pCVar )
{
new szCVar[ 16 ];
get_pcvar_string( pCVar , szCVar , charsmax( szCVar ) );
return str_to_num( szCVar );
}
__________________