Raised This Month: $ Target: $400
 0% 

Array/String


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-30-2015 , 16:13   Re: Array/String
Reply With Quote #1

Let me know if this works. I still used bitsums because it makes it easier and uses less code. If you have any questions, just ask. There are natives that convert "abc" to the respective bitsum (read_flags()) and vice versa (get_flags()).

Not thoroughly tested.
PHP Code:
#define MAXFLAGS 32

new Vip_flagsMAXFLAGS ] , access_flags

public _create_vip_flag(pluginargc)  // native
{
    new 
vflag32 ], sString32 ]
    
get_stringvflag charsmaxvflag ) )
    
    if( 
_flags_are_existedvflag sString charsmaxsString ) ) )
    {
        
log_error(AMX_ERR_PARAMS"Error couldn't create a vip flag ^"%s^", it's already created!"sString)
        return -
1
    
}
        
    
Vip_flagsaccess_flags ] = vflag]

    return 
access_flags++
}

public 
bool:_flags_are_existed( const vflags[] , sflags[] , len // native
{
    if( !
strlenVip_flags ) )
    {
        
copysflags len vflags );
        return 
false;
    }

    new 
iCurrentFlags read_flagsVip_flags );
    new 
iFlagsToCheck read_flagsvflags );
    new 
iMatchedFlags = ( iCurrentFlags iFlagsToCheck );
    new 
iResultFlags;
    new 
bool:bRetVal;
    
    if ( 
iMatchedFlags && ( iMatchedFlags == iFlagsToCheck ) )
    {
        
//All matching flags found
        
        
bRetVal true;
    }
    else if ( !
iMatchedFlags )
    {
        
//No matching flags found
        
        
iResultFlags iFlagsToCheck;
        
bRetVal false;
    }
    else if ( ~
iCurrentFlags iFlagsToCheck )
    {
        
//Some matching flags found
        
        
iResultFlags = ~iCurrentFlags iFlagsToCheck;
        
bRetVal false;
    }

    if ( !
bRetVal )
        
get_flagsiResultFlags sflags len );
        
    return 
bRetVal;

__________________
Bugsy is offline
Reply



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