Raised This Month: $ Target: $400
 0% 

Array/String


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-30-2015 , 12:51   Re: Array/String
Reply With Quote #2

Not sure if I'm missing something here, but why not use a bitsum to store flags?

Untested:
PHP Code:
new Vip_flags

public _create_vip_flag(pluginargc)  // native
{
    new 
vflag[2] , sString[32]
    
    
get_stringvflag charsmaxvflag ) )
    
    if( 
_flags_are_existedvflag ) )
    {
        
log_error(AMX_ERR_PARAMS"Error couldn't create a vip flag ^"%s^", it's already created!"sString)
        return -
1
    
}
    
    
Vip_flags |= read_flagsvflag] )
    
    return 
FlagCount();
}

public 
bool:_flags_are_existed( const flags[] ) // native
{
    if( !
Vip_flags )
    {
        return 
false;
    }
    
    new 
iFlagsToCheck read_flagsflags );
    
    return 
bool:!!( ( iFlagsToCheck Vip_flags ) == iFlagsToCheck )
}

public 
FlagCount()
{
    new 
Vip_flags;

    
- ((>> 1) & 0x55555555);
    
= (0x33333333) + ((>> 2) & 0x33333333);
    return (((
+ (>> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;

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


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