Raised This Month: $ Target: $400
 0% 

get_pcvar_num returning different number?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-27-2011 , 08:21   Re: get_pcvar_num returning different number?
Reply With Quote #2

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 = (<< CSW_KNIFE) | (<< CSW_C4) | (<< CSW_FLASHBANG) | (<< CSW_SMOKEGRENADE) | (<< CSW_HEGRENADE)

public 
plugin_init() 
{
    new 
bitsum16 ] , cvarSkipWeapons;
    
    
num_to_str(DEFAULT_SKIPWEAPONSbitsumcharsmax(bitsum));
    
cvarSkipWeapons register_cvar("jb_rebel_skipweapons"bitsum);
    
    new 
szCVar16 ];
    
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_numcvarSkipWeapons ) );
    
get_pcvar_stringcvarSkipWeapons szCVar charsmaxszCVar ) );
    
server_print"get_pcvar_string()=%s"szCVar );
    
server_print"getcvarbits()=%d"GetCVarBitscvarSkipWeapons ) );
}

GetCVarBitspCVar )
{
    new 
szCVar16 ];
    
get_pcvar_stringpCVar szCVar charsmaxszCVar ) );
    return 
str_to_numszCVar );

__________________

Last edited by Bugsy; 10-27-2011 at 09:08.
Bugsy is offline
 



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 14:22.


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