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_flags[ MAXFLAGS ] , access_flags
public _create_vip_flag(plugin, argc) // native
{
new vflag[ 32 ], sString[ 32 ]
get_string( 1 , vflag , charsmax( vflag ) )
if( _flags_are_existed( vflag , sString , charsmax( sString ) ) )
{
log_error(AMX_ERR_PARAMS, "Error couldn't create a vip flag ^"%s^", it's already created!", sString)
return -1
}
Vip_flags[ access_flags ] = vflag[ 0 ]
return access_flags++
}
public bool:_flags_are_existed( const vflags[] , sflags[] , len ) // native
{
if( !strlen( Vip_flags ) )
{
copy( sflags , len , vflags );
return false;
}
new iCurrentFlags = read_flags( Vip_flags );
new iFlagsToCheck = read_flags( vflags );
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_flags( iResultFlags , sflags , len );
return bRetVal;
}
__________________