After blocking any command from the list it should display a message on the console player.
Ex: Forbidden command on the server.
PHP Code:
#define USING_CSTRIKE
#include <amxmodx>
#include <amxmisc>
#if defined USING_CSTRIKE
#include <cstrike>
new Trie:g_tCommands;
new g_iCount;
#endif
new g_szConfigFileName[ ] = { "commands_blocker.ini" };
public plugin_init( )
{
register_plugin( "Commands Blocker", "0.1.1", "DruX" );
#if defined USING_CSTRIKE
g_tCommands = TrieCreate( );
#endif
ReadFileData( );
}
#if defined USING_CSTRIKE
public plugin_end( )
{
TrieDestroy( g_tCommands );
}
public CS_InternalCommand( id, const szCommand[ ] )
{
if ( TrieKeyExists( g_tCommands, szCommand ) )
{
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
#endif
public BlockCommand( id )
{
return PLUGIN_HANDLED;
}
ReadFileData( )
{
new szConfigsDir[ 64 ];
get_localinfo( "amxx_configsdir", szConfigsDir, charsmax( szConfigsDir ) );
new szFilePath[ 64 ];
formatex( szFilePath, charsmax( szFilePath ), "%s/%s", szConfigsDir, g_szConfigFileName );
if ( !file_exists( szFilePath ) )
{
set_fail_state( "Customization file needed." );
}
new szData[ 191 ];
new fFile = fopen( szFilePath, "rt" );
while ( !feof( fFile ) )
{
fgets( fFile, szData, charsmax( szData ) );
trim( szData );
if ( !szData[ 0 ] || szData[ 0 ] == ';' || szData[ 0 ] == '/' && szData[ 1 ] == '/' )
{
continue;
}
strtolower( szData );
#if defined USING_CSTRIKE
TrieSetCell( g_tCommands, szData, g_iCount );
g_iCount++;
#endif
register_clcmd( szData, "BlockCommand" );
}
fclose( fFile );
}