I don't see a benefit in using bit-sums here, unless I am missing something. The only exception would be is if you did not need to associate an item with it's string name; in this case bitsums can save you a bit of coding. The below will be much easier to understand if you are just starting.
PHP Code:
#include <amxmodx>
enum Options
{
Option1,
Option2,
Option3
}
new const OptionNames[ Options ][] =
{
"Option 1",
"Option 2",
"Option 3"
};
new bool:g_bPlayerOptions[ MAX_PLAYERS ][ Options ];
public plugin_init()
{
register_clcmd( "say addopt1" , "AddOpt1" );
register_clcmd( "say addopt2" , "AddOpt2" );
register_clcmd( "say addopt3" , "AddOpt3" );
register_clcmd( "say delopt1" , "DelOpt1" );
register_clcmd( "say delopt2" , "DelOpt2" );
register_clcmd( "say delopt3" , "DelOpt3" );
register_clcmd( "say options" , "ShowPlayerOptions" );
}
//The below 3 function's code can be inserted into your code directly, having functions for 1 line of code is overkill. These
//can also be accomplished using macros.
public AddOption( id , Options:oOption )
{
g_bPlayerOptions[ id ][ oOption ] = true;
}
public RemoveOption( id , Options:oOption )
{
g_bPlayerOptions[ id ][ oOption ] = false;
}
public bool:PlayerHasOption( id , Options:oOption )
{
return g_bPlayerOptions[ id ][ oOption ];
}
public ShowPlayerOptions( id )
{
new szOptions[ 48 ] , iPos;
for ( new Options:oOpt = Option1 ; oOpt < Options ; oOpt++ )
{
if ( PlayerHasOption( id , oOpt ) == true )
{
iPos += formatex( szOptions[ iPos ] , charsmax( szOptions ) - iPos , "%s, " , OptionNames[ oOpt ] );
}
}
if ( iPos == 0 )
copy( szOptions , charsmax( szOptions ) , "(none)" );
else
szOptions[ iPos - 2 ] = EOS;
client_print( id , print_chat , "You have options: %s" , szOptions );
}
public AddOpt1(id) AddOption( id , Option1 );
public AddOpt2(id) AddOption( id , Option2 );
public AddOpt3(id) AddOption( id , Option3 );
public DelOpt1(id) RemoveOption( id , Option1 );
public DelOpt2(id) RemoveOption( id , Option2 );
public DelOpt3(id) RemoveOption( id , Option3 );
__________________