View Single Post
Author Message
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-15-2019 , 11:07   New menu system memory leak bug
Reply With Quote #1

I get these errors, so basically I have the same issue as https://forums.alliedmods.net/showthread.php?t=207172 , hasn't this bug been fixed yet?

PHP Code:
L 08/15/2019 16:55:42Invalid menu id 13(15)
L 08/15/2019 16:55:42: [AMXXDisplaying debug trace (plugin "EliteAdminSystem_Commands.amxx")
L 08/15/2019 16:55:42: [AMXXRun time error 10native error (native "menu_destroy")
L 08/15/2019 16:55:42: [AMXX]    [0EliteAdminSystem_Commands.sma::@CommandsMenu_Handler (line 1808)
L 08/15/2019 16:55:42: [AMXX]    [1EliteAdminSystem_Commands.sma::ReOpenBanMenu (line 404)
L 08/15/2019 17:05:12Start of error session.
L 08/15/2019 17:05:12Info (map "fy_snow_orange") (file "addons/amxmodx/logs/error_20190815.log")
L 08/15/2019 17:05:12Invalid menu id 14(15)
L 08/15/2019 17:05:12: [AMXXDisplaying debug trace (plugin "EliteAdminSystem_Commands.amxx")
L 08/15/2019 17:05:12: [AMXXRun time error 10native error (native "menu_destroy")
L 08/15/2019 17:05:12: [AMXX]    [0EliteAdminSystem_Commands.sma::@CommandsMenu_Handler (line 1808)
L 08/15/2019 17:05:12: [AMXX]    [1EliteAdminSystem_Commands.sma::ReOpenBanMenu (line 404
I already placed menu_destroy in places where it was needed, to prevent memory leaks.

Line 1808:
PHP Code:
    menu_destroyiMenu ); 
Line 404:
PHP Code:
    @CommandsMenu_HandleridiMenu); 
Full code:
Code:
#include < amxmodx >
#include < amxmisc >
#include < cromchat >
#include < unixtime >
#include < hamsandwich >
#include < fakemeta >
#include < engine >
#include < fun >
#include < cstrike >
#include < eas_core >
#include < eas_ranks >

#pragma dynamic 32768

#define PLUGIN_AUTHOR "DoNii"
#define PLUGIN_NAME "Elite Admin System Commands"

#if defined client_disconnected
#define client_disconnect client_disconnected
#endif

enum
{
	TEAM_UNASSIGNED = 0,
	TEAM_T,
	TEAM_CT,
	TEAM_SPEC
}

enum _:PlayerBan
{
	Player_Name[ MAX_NAME_LENGTH ],
	Player_SteamId[ MAX_AUTHID_LENGTH ],
	Player_IP[ MAX_IP_LENGTH ],
	Player_BanExpire[ MAX_DATE_LENGTH ],
	Player_BanReason[ MAX_REASON_LENGTH ],
	Player_BannedBy[ MAX_NAME_LENGTH ]
}

enum _:PlayerGag
{
	Player_Name[ MAX_NAME_LENGTH ],
	Player_SteamId[ MAX_AUTHID_LENGTH ],
	Player_IP[ MAX_IP_LENGTH ],
	Player_GagExpire[ MAX_DATE_LENGTH ],
	Player_GagReason[ MAX_REASON_LENGTH ],
	Player_GagFlags[ 5 ]
}

enum _:PlayerData
{
	Player_ID[ MAX_AUTHID_LENGTH ],
	Player_Password[ MAX_PASSWORD_LENGTH ],
	Player_AccessFlags[ MAX_FLAGS_LENGTH ],
	Player_Prefix[ 32 ],
	Player_Model_T[ 32 ],
	Player_Model_CT[ 32 ],
	Player_Expire_Date[ MAX_DATE_LENGTH ],
	Player_Immunity[ 8 ],
	bool:Player_Suspended
}

enum ( += 12345 )
{
	TASK_KICK_MENU = 54321,
	TASK_BAN_MENU,
	TASK_UNBAN_MENU,
	TASK_UNGAG_MENU,
	TASK_GAG_CHECK,
	TASK_GAG_MENU,
	TASK_AUTHORIZED,
	TASK_TEAM_MENU
}

enum _:FileConfig
{
	BANS_FILE[ 64 ],
	GAGS_FILE[ 64 ],
	LOGS_FILE[ 64 ],
	USERS_FILE[ 64 ],
	SYSTEM_PREFIX[ 32 ],
	BANNED_CONNECT_LOG,
	RANKS_ENABLED,
	KICK_FLAG,
	BAN_FLAG,
	ADD_BAN_FLAG,
	UNBAN_FLAG,
	SLAY_FLAG,
	SLAP_FLAG,
	CVAR_FLAG,
	PLUGINS_FLAG,
	MAP_FLAG,
	NICK_FLAG,
	RCON_FLAG,
	SHOW_RCON_FLAG,
	MODULES_FLAG,
	FREEZE_FLAG,
	SCREENSHOT_FLAG,
	WARN_FLAG,
	NOCLIP_FLAG,
	GODMODE_FLAG,
	COMMANDS_MENU_FLAG,
	GAG_FLAG,
	UNGAG_FLAG,
	SAY_FLAG,
	TEAM_FLAG,
	IMMUNITY_FLAG,
	PSAY_FLAG,
	LAST_FLAG,
	WHO_FLAG,
	ADD_GAG_FLAG,
	CHAT_FLAG,
	DISCONNECT_INFO_SECONDS_EXPIRE,
	Float:FREQUENCY_CHECK_DISCONNECT_INFO,
	Float:UPDATE_BAN_FILE_FREQUENCY,
	Float:TIME_CHECK_ADMINS,
	Float:UPDATE_GAG_FILE_FREQUENCY
}

enum _:PlayerDisconnectData
{
	Player_DisconnectName[ MAX_NAME_LENGTH ],
	Player_DisconnectSteamID[ MAX_AUTHID_LENGTH ],
	Player_DisconnectIP[ MAX_IP_LENGTH ],
	Player_DisconnectFlags[ MAX_FLAGS_LENGTH ],
	Player_DisconnectRank[ 32 ],
	Player_DataExpireDate[ MAX_DATE_LENGTH ]
}

enum _:BanMsg
{
	BAN_ID,
	BAN_MINUTES,
	BAN_REASON[ MAX_REASON_LENGTH ]
}

enum _:AddBanMsg
{
	ADDBAN_ID,
	ADDBAN_NAME[ MAX_NAME_LENGTH ],
	ADDBAN_STEAMID[ MAX_AUTHID_LENGTH ],
	ADDBAN_IP[ MAX_IP_LENGTH ],
	ADDBAN_MINUTES
}

enum _:AddGagMsg
{
	ADDGAG_ID,
	ADDGAG_NAME[ MAX_NAME_LENGTH ],
	ADDGAG_STEAMID[ MAX_AUTHID_LENGTH ],
	ADDGAG_IP[ MAX_IP_LENGTH ],
	ADDGAG_SECONDS,
	ADDGAG_FLAGS[ 5 ]
}

enum _:SlayMsg
{
	SLAY_ID,
	SLAY_REASON[ MAX_REASON_LENGTH ]
}

enum _:SlapMsg
{
	SLAP_ID,
	SLAP_VALUE,
	SLAP_REASON[ MAX_REASON_LENGTH ]
}

enum _:GagMsg
{
	GAG_ID,
	GAG_SECONDS,
	GAG_FLAGS[ 5 ],
	GAG_REASON[ MAX_REASON_LENGTH ]
}

enum
{
	METHOD_CHAT = 1,
	METHOD_LOG,
	METHOD_BOTH
}

new g_iConfig[ FileConfig ];

new Array:g_aBans, Array:g_aGags, Array:g_aBanExists, Array:g_aGagExists, Array:g_aDataBase, Array:g_aMaps, Array:g_aDisconnectInfo;

new g_iKick[ MAX_PLAYERS + 1 ], g_iBan[ MAX_PLAYERS + 1 ][ BanMsg ], g_iGag[ MAX_PLAYERS + 1 ][ GagMsg ], g_iAddBan[ MAX_PLAYERS + 1 ][ AddBanMsg ], g_iAddGag[ MAX_PLAYERS + 1 ][ AddGagMsg ], 
g_iSlay[ MAX_PLAYERS + 1 ][ SlayMsg ], g_iSlap[ MAX_PLAYERS + 1 ][ SlapMsg ], g_iTeamSwitch[ MAX_PLAYERS + 1 ], g_szTeamSwitch[ MAX_PLAYERS + 1 ][ 20 ], g_szConfigsDir[ 128 ], g_szMapsFile[ 32 ];

new Float:fAngles[ MAX_PLAYERS + 1 ][ 3 ];

new bool:g_bFrozen[ MAX_PLAYERS + 1 ];

new g_pRconPassword, g_iFwThink;

public plugin_precache( )
{
	get_configsdir( g_szConfigsDir, charsmax( g_szConfigsDir ) );

	g_aGags = ArrayCreate( PlayerGag );
	g_aBans = ArrayCreate( PlayerBan );
	g_aDataBase = ArrayCreate( PlayerData );
	g_aDisconnectInfo = ArrayCreate( PlayerDisconnectData );
	g_aBanExists = ArrayCreate( 1 );
	g_aGagExists = ArrayCreate( 1 );
	g_aMaps = ArrayCreate( 32 );
	
	get_cvar_string( "mapcyclefile", g_szMapsFile, charsmax( g_szMapsFile ) );
	
	ReadConfig( );
	ReadBans( );
	ReadGags( );
	ReadUsers( );
	ReadMaps( );
}

public plugin_init( )
{
	register_plugin( PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR );
	
	register_dictionary( "elite_admin_system.txt" );
	
	set_task( g_iConfig[ UPDATE_BAN_FILE_FREQUENCY ], "UpdateBanFile", .flags="b" );
	set_task( g_iConfig[ TIME_CHECK_ADMINS ], "UpdateUsersFile", .flags="b" );
	set_task( g_iConfig[ UPDATE_GAG_FILE_FREQUENCY ], "UpdateGagFile", .flags="b" );
	set_task( g_iConfig[ FREQUENCY_CHECK_DISCONNECT_INFO ], "CheckExpiredDisconnectInfo", .flags="b" );
	
	register_cvar( "eas_version", PLUGIN_VERSION, FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED );
	
	register_clcmd( "say", "OnSay" );
	register_clcmd( "say_team", "OnSay" );
	
	g_pRconPassword = get_cvar_pointer( "rcon_password" );
	
	/////////////////// MessageMode Commands //////////////////////
	
	register_clcmd( "kickReason", "OnKickPlayer" );
	
	register_clcmd( "banPlayerMinutes", "OnBanPlayerMinutes" );
	register_clcmd( "banPlayerReason", "OnBanPlayerReason" );
	
	register_clcmd( "gagPlayerSeconds", "OnGagPlayerSeconds" );
	register_clcmd( "gagPlayerFlags", "OnGagPlayerFlags" );
	register_clcmd( "gagPlayerReason", "OnGagPlayerReason" );
	
	register_clcmd( "addbanPlayerName", "OnAddbanPlayerName" );
	register_clcmd( "addbanPlayerSteamID", "OnAddbanPlayerSteamID" );
	register_clcmd( "addbanPlayerIP", "OnAddbanPlayerIP" );
	register_clcmd( "addbanPlayerMinutes", "OnAddbanPlayerMinutes" );
	register_clcmd( "addbanPlayerReason", "OnAddbanPlayerReason" );
	
	register_clcmd( "addgagPlayerName", "OnAddGagPlayerName" );
	register_clcmd( "addgagPlayerSteamID", "OnAddGagPlayerSteamID" );
	register_clcmd( "addgagPlayerIP", "OnAddGagPlayerIP" );
	register_clcmd( "addgagPlayerSeconds", "OnAddGagPlayerSeconds" );
	register_clcmd( "addgagPlayerFlags", "OnAddGagPlayerFlags" );
	register_clcmd( "addgagPlayerReason", "OnAddGagPlayerReason" );
	
	register_clcmd( "slayPlayerReason", "OnSlayPlayerReason" );
	
	register_clcmd( "slapPlayerValue", "OnSlapPlayerValue" );
	register_clcmd( "slapPlayerReason", "OnSlapPlayerReason" );
	
	//////////////////// Console Commands ////////////////////
	
	register_concmd( "amx_kick", "@Kick" );
	register_concmd( "amx_ban", "@Ban" );
	register_concmd( "amx_addban", "@AddBan" );
	register_concmd( "amx_unban", "@Unban" );
	register_concmd( "amx_slay", "@Slay" );
	register_concmd( "amx_slap", "@Slap" );
	register_concmd( "amx_cvar", "@Cvar" );
	register_concmd( "amx_plugins", "@Plugins" );
	register_concmd( "amx_map", "@Map" );
	register_concmd( "amx_nick", "@Nick" );
	register_concmd( "amx_rcon", "@Rcon" );
	register_concmd( "amx_showrcon", "@ShowRcon" );
	register_concmd( "amx_modules", "@Modules" );
	register_concmd( "amx_freeze", "@Freeze" );
	register_concmd( "amx_ss", "@Screenshot" );
	register_concmd( "amx_help", "@Help" );
	register_concmd( "amx_noclip", "@Noclip" );
	register_concmd( "amx_godmode", "@Godmode" );
	register_concmd( "amx_warn", "@Warn" );
	register_concmd( "amx_gag", "@Gag" );
	register_concmd( "amx_ungag", "@UnGag" );
	register_concmd( "amx_say", "@AdminSay" );
	register_concmd( "amx_team", "@Team" );
	register_concmd( "amx_psay", "@Psay" );
	register_concmd( "amx_last", "@Last" );
	register_concmd( "amx_who", "@Who" );
	register_concmd( "amx_addgag", "@AddGag" );
	register_concmd( "amx_chat", "@AdminChat" );

	//////////////////////////////////////////////////////////
}

public plugin_end( )
{
	ArrayDestroy( g_aBanExists );
	ArrayDestroy( g_aBans );
	ArrayDestroy( g_aDataBase );
	ArrayDestroy( g_aDisconnectInfo );
	ArrayDestroy( g_aGagExists );
	ArrayDestroy( g_aGags );
	ArrayDestroy( g_aMaps );
}

//////////////////////////////////////////////////////////// TASKS ///////////////////////////////////////////////////////////////////////////////////////////
public UpdateUsersFile( )
{
	ReadUsers( );
}

public UpdateGagFile( )
{
	ReadGags( );
	CheckExistingGags( );
	CheckExpiredGags( );
}

public UpdateBanFile( )
{
	ReadBans( );
	CheckExistingBans( );
	CheckExpiredBans( );
}

public CheckExpiredDisconnectInfo( )
{
	new eData[ PlayerDisconnectData ];
	for( new i; i < ArraySize( g_aDisconnectInfo ); i++ )
	{
		ArrayGetArray( g_aDisconnectInfo, i, eData );
		
		if( HasDatePassed( eData[ Player_DataExpireDate ] ) )
		{
			ArrayDeleteItem( g_aDisconnectInfo, i );
		}
	}
}

public TaskCheckGagExpire( id )
{
	id -= TASK_GAG_CHECK;
	
	if( ! is_user_connected( id ) )
	{
		remove_task( id + TASK_GAG_CHECK );
		return PLUGIN_HANDLED;
	}
	
	if( get_speak( id ) == SPEAK_MUTED )
	{
		new szName[ MAX_NAME_LENGTH ], szSteamId[ MAX_AUTHID_LENGTH ], szIP[ MAX_IP_LENGTH ];
		get_user_name( id, szName, charsmax( szName ) );
		get_user_authid( id, szSteamId, charsmax( szSteamId ) );
		get_user_ip( id, szIP, charsmax( szIP ), 1 );
		
		new eData[ PlayerGag ];
		for( new i; i < ArraySize( g_aGags ); i++ )
		{
			ArrayGetArray( g_aGags, i, eData );
			
			if( equali( szName, eData[ Player_Name ] ) && equali( szSteamId, eData[ Player_SteamId ] ) && equali( szIP, eData[ Player_IP ] ) && HasDatePassed( eData[ Player_GagExpire ] ) )
			{
				set_speak( id, SPEAK_NORMAL );
				remove_task( id + TASK_GAG_CHECK );
				
				break;
			}
		}
	}
	return PLUGIN_CONTINUE;
}

public OnMapChange( const szMap[ ] )
{
	server_cmd( "changelevel %s", szMap );
}

public ReOpenKickMenu( id )
{
	id -= TASK_KICK_MENU;

	new iMenu = @CommandsMenu( id );
	@CommandsMenu_Handler( id, iMenu, 0 );
}

public ReOpenGagMenu( id )
{
	id -= TASK_GAG_MENU;

	new iMenu = @CommandsMenu( id );
	@CommandsMenu_Handler( id, iMenu, 4 );
}

public ReOpenBanMenu( id )
{
	id -= TASK_BAN_MENU;
	
	new iMenu = @CommandsMenu( id );
	@CommandsMenu_Handler( id, iMenu, 1 );
}

public ReOpenUnGagMenu( id )
{
	id -= TASK_UNGAG_MENU;

	new iMenu = @CommandsMenu( id );
	@CommandsMenu_Handler( id, iMenu, 6 );
}

public ReOpenUnbanMenu( id )
{
	id -= TASK_UNBAN_MENU;

	new iMenu = @CommandsMenu( id );
	@CommandsMenu_Handler( id, iMenu, 5 );
}

public ReOpenTeamMenu( id )
{
	id -= TASK_TEAM_MENU;

	new iMenu = @CommandsMenu( id );
	@CommandsMenu_Handler( id, iMenu, 9 );
}

////////////////////////////////////////////////////////// END OF TASKS //////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////// EVENTS ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

public client_disconnect( id )
{
	CleanVars( id );
	CacheInfo( id );
}

CacheInfo( id )
{
	new eData[ PlayerDisconnectData ];
	
	get_user_name( id, eData[ Player_DisconnectName ], charsmax( eData[ Player_DisconnectName ] ) );
	get_user_authid( id, eData[ Player_DisconnectSteamID ], charsmax( eData[ Player_DisconnectSteamID ] ) );
	get_user_ip( id, eData[ Player_DisconnectIP ], charsmax( eData[ Player_DisconnectIP ] ), 1 );
	
	get_flags( get_user_flags( id ), eData[ Player_DisconnectFlags ], charsmax( eData[ Player_DisconnectFlags ] ) );
	
	eas_get_player_rank( id, eData[ Player_DisconnectRank ], charsmax( eData[ Player_DisconnectRank ] ) );
	
	new szDate[ MAX_DATE_LENGTH ];
	get_time( "%m/%d/%Y - %H:%M:%S", szDate, charsmax( szDate ) );
	
	AddSecondsToDate( szDate, g_iConfig[ DISCONNECT_INFO_SECONDS_EXPIRE ], eData[ Player_DataExpireDate ], charsmax( eData[ Player_DataExpireDate ] ) );
	
	ArrayPushArray( g_aDisconnectInfo, eData );
}

public client_connect( id )
{
	CleanVars( id );
}

public client_putinserver( id )
{
	CheckGagged( id ); // using putinserver instead of authorized cuz its too early to call set_speak
}

public client_authorized( id )
{
	set_task( 0.3, "client_authorized_delayed", id + TASK_AUTHORIZED );
}

public client_authorized_delayed( id )
{
	id -= TASK_AUTHORIZED;

	CheckBanned( id );
}

public OnSay( id )
{
	ReadGags( );

	new eData[ PlayerGag ], szSteamId[ MAX_AUTHID_LENGTH ], szName[ MAX_NAME_LENGTH ], szIP[ MAX_IP_LENGTH ];
	get_user_authid( id, szSteamId, charsmax( szSteamId ) );
	get_user_name( id, szName, charsmax( szName ) );
	get_user_ip( id, szIP, charsmax( szIP ), 1 );

	for( new i; i < ArraySize( g_aGags ); i++ )
	{
		ArrayGetArray( g_aGags, i, eData );
		
		if( ( equali( szSteamId, eData[ Player_SteamId ] ) || equali( szName, eData[ Player_Name ] ) || equali( szIP, eData[ Player_IP ] ) ) && ( containi( eData[ Player_GagFlags ], "s" ) != -1 ) )
		{
			if( equali( eData[ Player_GagExpire ], "never" ) )
			{
				CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "GAG_EXPIRES_NEVER" );
				return PLUGIN_HANDLED;
			}
			
			else if( ! HasDatePassed( eData[ Player_GagExpire ] ) )
			{
				CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "GAG_EXPIRES_IN", ( parse_time( eData[ Player_GagExpire ], "%m/%d/%Y - %H:%M:%S" ) - get_systime( ) ) );
				return PLUGIN_HANDLED;
			}
			
			else
			{
				return PLUGIN_CONTINUE;
			}
		}
	}
	return PLUGIN_CONTINUE;
}

public fw_PlayerPreThink( id )
{
	if( is_user_alive( id ) && g_bFrozen[ id ] )
	{
		set_pev( id, pev_v_angle, fAngles[ id ] );
		set_pev( id, pev_fixangle, 1 );
	}
}

////////////////////////////////////////////////////////// END OF EVENTS ///////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////// MessageMode ///////////////////////////////////////////////////////////////////////////////////////////

public OnAddbanPlayerName( id )
{
	new szName[ MAX_NAME_LENGTH ];
	read_args( szName, charsmax( szName ) );
	
	trim( szName );
	remove_quotes( szName );
	
	if( ! szName[ 0 ] )
	{
		CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "EMPTY_STRING" );
		return PLUGIN_HANDLED;
	}
	
	new iPlayer = find_player( "al", szName );

	if( is_user_connected( iPlayer ) )
	{
		new iImmunityLevel = GetImmunityLevel( id );
		new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
		
		if( iImmunityLevel < iImmunityLevelTarget )
		{
			CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY_COLORED" );
			arrayset( g_iAddBan[ id ], 0, sizeof( g_iAddBan[ ] ) );
			
			return PLUGIN_HANDLED;
		}
	}
	
	g_iAddBan[ id ][ ADDBAN_ID ] = iPlayer;
	copy( g_iAddBan[ id ][ ADDBAN_NAME ], charsmax( g_iAddBan[ ] ), szName );
	client_cmd( id, "messagemode addbanPlayerSteamID" );
	
	return PLUGIN_HANDLED;
}

public OnAddbanPlayerSteamID( id )
{
	new szSteamId[ MAX_AUTHID_LENGTH ];
	read_args( szSteamId, charsmax( szSteamId ) );

	trim( szSteamId );
	remove_quotes( szSteamId );
	
	if( ! szSteamId[ 0 ] )
	{
		CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "EMPTY_STRING" );
		return PLUGIN_HANDLED;
	}
	
	new iPlayer = find_player( "cl", szSteamId );
	
	if( is_user_connected( iPlayer ) )
	{
		new iImmunityLevel = GetImmunityLevel( id );
		new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
		
		if( iImmunityLevel < iImmunityLevelTarget )
		{
			CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY_COLORED" );
			arrayset( g_iAddBan[ id ], 0, sizeof( g_iAddBan[ ] ) );
			
			return PLUGIN_HANDLED;
		}
	}
	
	copy( g_iAddBan[ id ][ ADDBAN_STEAMID ], charsmax( g_iAddBan[ ] ), szSteamId );
	client_cmd( id, "messagemode addbanPlayerIP" );
	
	return PLUGIN_HANDLED;
}

public OnAddbanPlayerIP( id )
{
	new szIP[ MAX_IP_LENGTH ];
	read_args( szIP, charsmax( szIP ) );
	
	trim( szIP );
	remove_quotes( szIP );
	
	if( ! szIP[ 0 ] )
	{
		CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "EMPTY_STRING" );
		return PLUGIN_HANDLED;
	}
	
	new iPlayer = find_player( "dl", szIP );
	
	if( is_user_connected( iPlayer ) )
	{
		new iImmunityLevel = GetImmunityLevel( id );
		new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
		
		if( iImmunityLevel < iImmunityLevelTarget )
		{
			CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY_COLORED" );
			arrayset( g_iAddBan[ id ], 0, sizeof( g_iAddBan[ ] ) );
			
			return PLUGIN_HANDLED;
		}
	}
	
	copy( g_iAddBan[ id ][ ADDBAN_IP ], charsmax( g_iAddBan[ ] ), szIP );
	client_cmd( id, "messagemode addbanPlayerMinutes" );
	
	return PLUGIN_HANDLED;
}

public OnAddbanPlayerMinutes( id )
{
	new szMinutes[ 8 ];
	read_args( szMinutes, charsmax( szMinutes ) );
	
	trim( szMinutes );
	remove_quotes( szMinutes );
	
	g_iAddBan[ id ][ ADDBAN_MINUTES ] = str_to_num( szMinutes );
	client_cmd( id, "messagemode addbanPlayerReason" );
	
	return PLUGIN_HANDLED;
}

public OnAddbanPlayerReason( id )
{
	new szReason[ MAX_REASON_LENGTH ];
	read_args( szReason, charsmax( szReason ) );
	
	trim( szReason );
	remove_quotes( szReason );
	
	new iPlayer = g_iAddBan[ id ][ ADDBAN_ID ];
	
	new szNameAdmin[ MAX_NAME_LENGTH ], szExpireDate[ MAX_DATE_LENGTH ], iMinutes = g_iAddBan[ id ][ ADDBAN_MINUTES ], szName[ MAX_NAME_LENGTH ], szSteamID[ MAX_AUTHID_LENGTH ], szIP[ MAX_IP_LENGTH ];
	
	copy( szName, charsmax( szName ), g_iAddBan[ id ][ ADDBAN_NAME ] );
	copy( szSteamID, charsmax( szSteamID ), g_iAddBan[ id ][ ADDBAN_STEAMID ] );
	copy( szIP, charsmax( szIP ), g_iAddBan[ id ][ ADDBAN_IP ] );

	get_user_name( id, szNameAdmin, charsmax( szNameAdmin ) );
	
	if( iMinutes == 0 )
	{
		CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "ADDED_TO_BANLIST_PERMANENT", szNameAdmin, szName, szSteamID, szIP, szReason );
		log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_ADDED_TO_BANLIST_PERMANENT", szNameAdmin, szName, szSteamID, szIP, szReason );
		
		copy( szExpireDate, charsmax( szExpireDate ), "never" );	
	}
	
	else
	{
		get_time( "%m/%d/%Y - %H:%M:%S", szExpireDate, charsmax( szExpireDate ) );
		
		AddMinutesToDate( szExpireDate, iMinutes, szExpireDate, charsmax( szExpireDate ) );
		
		CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "ADDED_TO_BANLIST", szNameAdmin, szName, szSteamID, szIP, iMinutes, szReason );
		log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_ADDED_TO_BANLIST", szNameAdmin, szName, szSteamID, szIP, iMinutes, szExpireDate, szReason );
	}

	trim( szName );
	trim( szSteamID );
	trim( szIP );
	trim( szExpireDate );
	trim( szReason );
	trim( szNameAdmin );
	
	new eData[ PlayerBan ];
	copy( eData[ Player_Name ], charsmax( eData[ Player_Name ] ), szName );
	copy( eData[ Player_SteamId ], charsmax( eData[ Player_SteamId ] ), szSteamID );
	copy( eData[ Player_IP ], charsmax( eData[ Player_IP ] ), szIP );
	copy( eData[ Player_BanExpire ], charsmax( eData[ Player_BanExpire ] ), szExpireDate );
	copy( eData[ Player_BanReason ], charsmax( eData[ Player_BanReason ] ), szReason );
	copy( eData[ Player_BannedBy ], charsmax( eData[ Player_BannedBy ] ), szNameAdmin );
	
	ArrayPushArray( g_aBans, eData );
	
	AddBan( szName, szSteamID, szIP, szExpireDate, szReason, szNameAdmin );
	
	if( is_user_connected( iPlayer ) )
	{
		KickPlayerOut( iPlayer );
	}
	
	if( is_user_connected( id ) ) // checking to see if he's still connected (maybe he banned himself)
	{
		new iMenu = @CommandsMenu( id );
		@CommandsMenu_Handler( id, iMenu, 2 );
	}
	
	arrayset( g_iAddBan[ id ], 0, sizeof( g_iAddBan[ ] ) );
	
	return PLUGIN_HANDLED;
}

public OnAddGagPlayerName( id )
{
	new szName[ MAX_NAME_LENGTH ];
	read_args( szName, charsmax( szName ) );
	
	trim( szName );
	remove_quotes( szName );
	
	if( ! szName[ 0 ] )
	{
		CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "EMPTY_STRING" );
		return PLUGIN_HANDLED;
	}
	
	new iPlayer = find_player( "al", szName );

	if( is_user_connected( iPlayer ) )
	{
		new iImmunityLevel = GetImmunityLevel( id );
		new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
		
		if( iImmunityLevel < iImmunityLevelTarget )
		{
			CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY_COLORED" );
			arrayset( g_iAddGag[ id ], 0, sizeof( g_iAddGag[ ] ) );
			
			return PLUGIN_HANDLED;
		}
	}
	
	g_iAddGag[ id ][ ADDGAG_ID ] = iPlayer;
	copy( g_iAddGag[ id ][ ADDGAG_NAME ], charsmax( g_iAddGag[ ] ), szName );
	client_cmd( id, "messagemode addgagPlayerSteamID" );
	
	return PLUGIN_HANDLED;
}

public OnAddGagPlayerSteamID( id )
{
	new szSteamId[ MAX_AUTHID_LENGTH ];
	read_args( szSteamId, charsmax( szSteamId ) );

	trim( szSteamId );
	remove_quotes( szSteamId );
	
	if( ! szSteamId[ 0 ] )
	{
		CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "EMPTY_STRING" );
		return PLUGIN_HANDLED;
	}
	
	new iPlayer = find_player( "cl", szSteamId );
	
	if( is_user_connected( iPlayer ) )
	{
		new iImmunityLevel = GetImmunityLevel( id );
		new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
		
		if( iImmunityLevel < iImmunityLevelTarget )
		{
			CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY_COLORED" );
			arrayset( g_iAddGag[ id ], 0, sizeof( g_iAddGag[ ] ) );
			
			return PLUGIN_HANDLED;
		}
	}
	
	copy( g_iAddGag[ id ][ ADDGAG_STEAMID ], charsmax( g_iAddGag[ ] ), szSteamId );
	client_cmd( id, "messagemode addgagPlayerIP" );
	
	return PLUGIN_HANDLED;
}

public OnAddGagPlayerIP( id )
{
	new szIP[ MAX_IP_LENGTH ];
	read_args( szIP, charsmax( szIP ) );
	
	trim( szIP );
	remove_quotes( szIP );
	
	if( ! szIP[ 0 ] )
	{
		CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "EMPTY_STRING" );
		return PLUGIN_HANDLED;
	}
	
	new iPlayer = find_player( "dl", szIP );
	
	if( is_user_connected( iPlayer ) )
	{
		new iImmunityLevel = GetImmunityLevel( id );
		new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
		
		if( iImmunityLevel < iImmunityLevelTarget )
		{
			CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY_COLORED" );
			arrayset( g_iAddGag[ id ], 0, sizeof( g_iAddGag[ ] ) );
			
			return PLUGIN_HANDLED;
		}
	}
	
	copy( g_iAddGag[ id ][ ADDGAG_IP ], charsmax( g_iAddGag[ ] ), szIP );
	client_cmd( id, "messagemode addgagPlayerSeconds" );
	
	return PLUGIN_HANDLED;
}

public OnAddGagPlayerSeconds( id )
{
	new szSeconds[ 8 ];
	read_args( szSeconds, charsmax( szSeconds ) );
	
	trim( szSeconds );
	remove_quotes( szSeconds );
	
	new iSeconds = str_to_num( szSeconds );
	
	if( ! is_str_num( szSeconds ) || iSeconds < 0 )
	{
		client_print( id, print_chat, "%L", id, "INVALID_VALUE" );
		arrayset( g_iAddGag[ id ], 0, sizeof( g_iAddGag[ ] ) );
		
		return PLUGIN_HANDLED;
	}
	
	g_iAddGag[ id ][ ADDGAG_SECONDS ] = str_to_num( szSeconds );
	client_cmd( id, "messagemode addgagPlayerFlags" );
	
	return PLUGIN_HANDLED;
}

public OnAddGagPlayerFlags( id )
{
	new szFlags[ 5 ];
	read_args( szFlags, charsmax( szFlags ) );
	
	trim( szFlags );
	remove_quotes( szFlags );
	
	if( equali( szFlags, "sv" ) || equali( szFlags, "vs" ) || equali( szFlags, "s" ) || equali( szFlags, "v" ) )
	{
		copy( g_iAddGag[ id ][ ADDGAG_FLAGS ], charsmax( g_iAddGag[ ] ), szFlags );
		client_cmd( id, "messagemode addgagPlayerReason" );
	}
	
	else
	{
		client_print( id, print_chat, "%L", id, "INVALID_FLAGS" );
		arrayset( g_iAddGag[ id ], 0, sizeof( g_iAddGag[ ] ) );
		
		return PLUGIN_HANDLED;
	}
	return PLUGIN_CONTINUE;
}

public OnAddGagPlayerReason( id )
{
	new szReason[ MAX_REASON_LENGTH ];
	read_args( szReason, charsmax( szReason ) );
	
	trim( szReason );
	remove_quotes( szReason );
	
	new iPlayer = g_iAddGag[ id ][ ADDGAG_ID ];
	
	new szNameAdmin[ 32 ], szExpireDate[ MAX_DATE_LENGTH ], iSeconds = g_iAddGag[ id ][ ADDGAG_SECONDS ], szName[ MAX_NAME_LENGTH ], szSteamID[ MAX_AUTHID_LENGTH ], szIP[ MAX_IP_LENGTH ], szFlags[ MAX_FLAGS_LENGTH ];
	get_user_name( id, szNameAdmin, charsmax( szNameAdmin ) );
	
	copy( szName, charsmax( szName ), g_iAddGag[ id ][ ADDGAG_NAME ] );
	copy( szSteamID, charsmax( szSteamID ), g_iAddGag[ id ][ ADDGAG_STEAMID ] );
	copy( szIP, charsmax( szIP ), g_iAddGag[ id ][ ADDGAG_IP ] );
	copy( szFlags, charsmax( szFlags ), g_iAddGag[ id ][ ADDGAG_FLAGS ] );
	
	if( iSeconds == 0 )
	{
		CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "ADDED_TO_GAGLIST_PERMANENT", szNameAdmin, szName, szSteamID, szIP, szFlags, szReason );
		log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_ADDED_TO_GAGLIST_PERMANENT", szNameAdmin, szName, szSteamID, szIP, szFlags, szReason );
		
		copy( szExpireDate, charsmax( szExpireDate ), "never" );	
	}
	
	else
	{
		get_time( "%m/%d/%Y - %H:%M:%S", szExpireDate, charsmax( szExpireDate ) );
		
		AddSecondsToDate( szExpireDate, iSeconds, szExpireDate, charsmax( szExpireDate ) );
		
		CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "ADDED_TO_GAGLIST", szNameAdmin, szName, szSteamID, szIP, iSeconds );
		log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_ADDED_TO_GAGLIST", szNameAdmin, szName, szSteamID, szIP, iSeconds, szExpireDate, szFlags, szReason );
	}

	trim( szName );
	trim( szSteamID );
	trim( szIP );
	trim( szReason );
	trim( szFlags );
	trim( szExpireDate );
	
	new eData[ PlayerGag ];
	copy( eData[ Player_Name ], charsmax( eData[ Player_Name ] ), szName );
	copy( eData[ Player_SteamId ], charsmax( eData[ Player_SteamId ] ), szSteamID);
	copy( eData[ Player_IP ], charsmax( eData[ Player_IP ] ), szIP );
	copy( eData[ Player_GagFlags ], charsmax( eData[ Player_GagFlags ] ), szFlags );
	copy( eData[ Player_GagReason ], charsmax( eData[ Player_GagReason ] ), szReason );
	copy( eData[ Player_GagExpire ], charsmax( eData[ Player_GagExpire ] ), szExpireDate );
	
	ArrayPushArray( g_aGags, eData );
	
	AddGag( szName, szSteamID, szIP, szReason, szFlags, szExpireDate );
	
	if( is_user_connected( iPlayer ) )
	{
		CheckGagged( iPlayer );
	}
	
	new iMenu = @CommandsMenu( id );
	@CommandsMenu_Handler( id, iMenu, 3 );
	
	arrayset( g_iAddGag[ id ], 0, sizeof( g_iAddGag[ ] ) );
	
	return PLUGIN_HANDLED;
}

public OnKickPlayer( id )
{
	new szReason[ MAX_REASON_LENGTH ];
	read_args( szReason, charsmax( szReason ) );
	
	trim( szReason );
	remove_quotes( szReason );
	
	new iPlayer = g_iKick[ id ];
	
	new szNameAdmin[ MAX_NAME_LENGTH ], szNameUser[ MAX_NAME_LENGTH ];
	
	get_user_name( id, szNameAdmin, charsmax( szNameAdmin ) );
	get_user_name( iPlayer, szNameUser, charsmax( szNameUser ) );
	
	server_cmd( "kick #%d  ^"%s^"", get_user_userid( iPlayer ), szReason );
	
	CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "KICKED", szNameAdmin, szNameUser, szReason );
	log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_KICKED", szNameAdmin, szNameUser, szReason );
	
	g_iKick[ id ] = 0;
	
	if( is_user_connected( id ) )
	{
		set_task( 0.1, "ReOpenKickMenu", id + TASK_KICK_MENU ); // needs a delay to update players
	}
	
	return PLUGIN_HANDLED;
}

public OnGagPlayerSeconds( id )
{
	new szSeconds[ 8 ];
	read_args( szSeconds, charsmax( szSeconds ) );
	
	trim( szSeconds );
	remove_quotes( szSeconds );
	
	new iSeconds = str_to_num( szSeconds );
	
	if( ! is_str_num( szSeconds ) || iSeconds < 0 )
	{
		client_print( id, print_chat, "%L", id, "INVALID_VALUE" );
		arrayset( g_iGag[ id ], 0, sizeof( g_iGag[ ] ) );
		
		return PLUGIN_HANDLED;
	}
	
	g_iGag[ id ][ GAG_SECONDS ] = iSeconds;
	client_cmd( id, "messagemode gagPlayerFlags" );
	
	return PLUGIN_HANDLED;
}

public OnGagPlayerFlags( id )
{
	new szFlags[ 5 ];
	read_args( szFlags, charsmax( szFlags ) );
	
	trim( szFlags );
	remove_quotes( szFlags );
	
	if( equali( szFlags, "sv" ) || equali( szFlags, "vs" ) || equali( szFlags, "s" ) || equali( szFlags, "v" ) )
	{
		copy( g_iGag[ id ][ GAG_FLAGS ], charsmax( g_iGag[ ] ), szFlags );
		client_cmd( id, "messagemode gagPlayerReason" );
	}
	
	else
	{
		client_print( id, print_chat, "%L", id, "INVALID_FLAGS" );
		arrayset( g_iGag[ id ], 0, sizeof( g_iGag[ ] ) );
		
		return PLUGIN_HANDLED;
	}
	return PLUGIN_HANDLED;
}

public OnGagPlayerReason( id )
{
	new szReason[ MAX_REASON_LENGTH ];
	read_args( szReason, charsmax( szReason ) );
	
	trim( szReason );
	remove_quotes( szReason );
	
	new iPlayer = g_iGag[ id ][ GAG_ID ];
	
	new szFlags[ 5 ];
	copy( szFlags, charsmax( szFlags ), g_iGag[ id ][ GAG_FLAGS ] );
	
	new szNameAdmin[ MAX_NAME_LENGTH ], szExpireDate[ MAX_DATE_LENGTH ], szNameUser[ MAX_NAME_LENGTH ], szSteamIdUser[ MAX_AUTHID_LENGTH ], szIpUser[ MAX_IP_LENGTH ], iSeconds = g_iGag[ iPlayer ][ GAG_SECONDS ];

	get_user_name( id, szNameAdmin, charsmax( szNameAdmin ) );
	get_user_name( iPlayer, szNameUser, charsmax( szNameUser ) );
	get_user_authid( iPlayer, szSteamIdUser, charsmax( szSteamIdUser ) );
	get_user_ip( iPlayer, szIpUser, charsmax( szIpUser ), 1 );
	
	if( iSeconds == 0 )
	{
		CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "GAGGED_PERMANENT", szNameAdmin, szNameUser, szFlags, szReason );
		log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_GAGGED_PERMANENT", szNameAdmin, szNameUser, szSteamIdUser, szIpUser, szReason, szFlags );
		
		copy( szExpireDate, charsmax( szExpireDate ), "never" );
	}
	
	else
	{
		get_time( "%m/%d/%Y - %H:%M:%S", szExpireDate, charsmax( szExpireDate ) );
		AddSecondsToDate( szExpireDate, iSeconds, szExpireDate, charsmax( szExpireDate ) );
		
		if( iSeconds == 1 )
		{
			CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "GAGGED_SINGULAR", szNameAdmin, szNameUser, szReason, szFlags );
			log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_GAGGED_SINGULAR", szNameAdmin, szNameUser, szSteamIdUser, szIpUser, szReason, szExpireDate, szFlags );
		}
		
		else
		{
			CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "GAGGED_PLURAL", szNameAdmin, szNameUser, iSeconds, szReason, szFlags );
			log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_GAGGED_PLURAL", szNameAdmin, szNameUser, szSteamIdUser, szIpUser, iSeconds, szReason, szExpireDate, szFlags );
		}
	}
	
	trim( szNameUser );
	trim( szSteamIdUser );
	trim( szIpUser );
	trim( szExpireDate );
	trim( szReason );
	trim( szNameAdmin );
	
	new eData[ PlayerGag ];	
	copy( eData[ Player_Name ], charsmax( eData[ Player_Name ] ), szNameUser );
	copy( eData[ Player_SteamId ], charsmax( eData[ Player_SteamId ] ), szSteamIdUser );
	copy( eData[ Player_IP ], charsmax( eData[ Player_IP ] ), szIpUser );
	copy( eData[ Player_GagExpire ], charsmax( eData[ Player_GagExpire ] ), szExpireDate );
	copy( eData[ Player_GagReason ], charsmax( eData[ Player_GagReason ] ), szReason );
	copy( eData[ Player_GagFlags ], charsmax( eData[ Player_GagFlags ] ), szFlags );
	
	ArrayPushArray( g_aGags, eData );
	
	if( containi( szFlags, "v" ) != -1 && is_user_connected( id ) )
	{
		set_speak( iPlayer, SPEAK_MUTED );
	}
	
	GagPlayer( szNameUser, szSteamIdUser, szIpUser, szReason, szFlags, szExpireDate );
	set_task( 1.0, "TaskCheckGagExpire", id + TASK_GAG_CHECK, .flags="b" );
	
	arrayset( g_iGag[ id ], 0, sizeof( g_iGag[ ] ) );
	
	set_task( 0.1, "ReOpenGagMenu", id + TASK_GAG_MENU );
	
	return PLUGIN_HANDLED;
}

public OnBanPlayerMinutes( id )
{
	new szMinutes[ 8 ];
	read_args( szMinutes, charsmax( szMinutes ) );
	
	trim( szMinutes );
	remove_quotes( szMinutes );
	
	new iMinutes = str_to_num( szMinutes );
	
	if( ! is_str_num( szMinutes ) || iMinutes < 0 )
	{
		client_print( id, print_chat, "%L", id, "INVALID_VALUE" );
		arrayset( g_iBan[ id ], 0, sizeof( g_iBan[ ] ) );
		
		return PLUGIN_HANDLED;
	}
	
	g_iBan[ id ][ BAN_MINUTES ] = str_to_num( szMinutes );
	client_cmd( id, "messagemode banPlayerReason" );
	
	return PLUGIN_HANDLED;
}

public OnBanPlayerReason( id )
{
	new szReason[ MAX_REASON_LENGTH ];
	read_args( szReason, charsmax( szReason ) );
	
	trim( szReason );
	remove_quotes( szReason );
	
	new iPlayer = g_iBan[ id ][ BAN_ID ];
	
	new szNameUser[ MAX_NAME_LENGTH ], szNameAdmin[ MAX_NAME_LENGTH ], szSteamIdUser[ MAX_AUTHID_LENGTH ], szIpUser[ MAX_IP_LENGTH ], szExpireDate[ MAX_DATE_LENGTH ], iMinutes = g_iBan[ id ][ BAN_MINUTES ];
	
	get_user_name( id, szNameAdmin, charsmax( szNameAdmin ) );
	get_user_name( iPlayer, szNameUser, charsmax( szNameUser ) );
	get_user_authid( iPlayer, szSteamIdUser, charsmax( szSteamIdUser ) );
	get_user_ip( iPlayer, szIpUser, charsmax( szIpUser ), 1 );
	
	if( iMinutes == 0 )
	{
		CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "BANNED_PERMANENT", szNameAdmin, szNameUser, szReason );
		log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_BANNED_PERMANENT", szNameAdmin, szNameUser, szSteamIdUser, szIpUser, szReason );
		
		copy( szExpireDate, charsmax( szExpireDate ), "never" );
	}
	
	else
	{
		get_time( "%m/%d/%Y - %H:%M:%S", szExpireDate, charsmax( szExpireDate ) );
		
		AddMinutesToDate( szExpireDate, iMinutes, szExpireDate, charsmax( szExpireDate ) );
		
		if( iMinutes == 1 )
		{
			CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "BANNED_SINGULAR", szNameAdmin, szNameUser, szReason );
			log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_BANNED_SINGULAR", szNameAdmin, szNameUser, szSteamIdUser, szIpUser, szReason, szExpireDate );
		}
		
		else
		{
			CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "BANNED_PLURAL", szNameAdmin, szNameUser, iMinutes, szReason );
			log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_BANNED_PLURAL", szNameAdmin, szNameUser, szSteamIdUser, szIpUser, iMinutes, szReason, szExpireDate );
		}
	}
	
	trim( szNameUser );
	trim( szSteamIdUser );
	trim( szIpUser );
	trim( szExpireDate );
	trim( szReason );
	trim( szNameAdmin );
	
	new eData[ PlayerBan ];	
	copy( eData[ Player_Name ], charsmax( eData[ Player_Name ] ), szNameUser );
	copy( eData[ Player_SteamId ], charsmax( eData[ Player_SteamId ] ), szSteamIdUser );
	copy( eData[ Player_IP ], charsmax( eData[ Player_IP ] ), szIpUser );
	copy( eData[ Player_BanExpire ], charsmax( eData[ Player_BanExpire ] ), szExpireDate );
	copy( eData[ Player_BanReason ], charsmax( eData[ Player_BanReason ] ), szReason );
	copy( eData[ Player_BannedBy ], charsmax( eData[ Player_BannedBy ] ), szNameAdmin );
	
	ArrayPushArray( g_aBans, eData );
	
	BanPlayer( szNameUser, szSteamIdUser, szIpUser, szExpireDate, szReason, szNameAdmin );
	
	if( is_user_connected( iPlayer ) )
	{
		KickPlayerOut( iPlayer );
	}
	
	arrayset( g_iBan[ id ], 0, sizeof( g_iBan[ ] ) );
	
	if( is_user_connected( id ) ) // checking bc of self-ban
	{
		set_task( 0.1, "ReOpenBanMenu", id + TASK_BAN_MENU );
	}
	
	return PLUGIN_HANDLED;
}

public OnSlapPlayerValue( id )
{
	new szValue[ 5 ];
	read_args( szValue, charsmax( szValue ) );
	
	trim( szValue );
	remove_quotes( szValue );
	
	new iValue = str_to_num( szValue );
	
	if( ! is_str_num( szValue ) || iValue < 0 )
	{
		client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "INVALID_VALUE" );
		return PLUGIN_HANDLED;
	}
	
	new iPlayer = g_iSlap[ id ][ SLAP_ID ];
	
	if( ! is_user_alive( iPlayer ) )
	{
		client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "SLAP_DEAD_PLAYER" );
		return PLUGIN_HANDLED;
	}
	
	g_iSlap[ id ][ SLAP_VALUE ] = iValue;
	client_cmd( id, "messagemode slapPlayerReason" );
	
	return PLUGIN_HANDLED;
}

public OnSlapPlayerReason( id )
{
	new szReason[ MAX_REASON_LENGTH ];
	read_args( szReason, charsmax( szReason ) );
	
	trim( szReason );
	remove_quotes( szReason );
	
	new iValue = g_iSlap[ id ][ SLAP_VALUE ], iPlayer = g_iSlap[ id ][ SLAP_ID ];
	
	if( ! is_user_alive( iPlayer ) )
	{
		client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "SLAP_DEAD_PLAYER" );
		return PLUGIN_HANDLED;
	}
	
	new szNameAdmin[ MAX_NAME_LENGTH ], szNameUser[ MAX_NAME_LENGTH ];
	
	get_user_name( id, szNameAdmin, charsmax( szNameAdmin ) );
	get_user_name( iPlayer, szNameUser, charsmax( szNameUser ) );
	
	user_slap( iPlayer, iValue );
	
	CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "SLAP", szNameAdmin, szNameUser, iValue, szReason );
	log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_SLAP", szNameAdmin, szNameUser, iValue, szReason );
	
	arrayset( g_iSlap[ id ], 0, sizeof( g_iSlap[ ] ) );

	new iMenu = @CommandsMenu( id );
	@CommandsMenu_Handler( id, iMenu, 8 );

	return PLUGIN_HANDLED;
}

public OnSlayPlayerReason( id )
{
	new szReason[ MAX_REASON_LENGTH ];
	read_args( szReason, charsmax( szReason ) );
	
	trim( szReason );
	remove_quotes( szReason );
	
	new iPlayer = g_iSlay[ id ][ SLAY_ID ];
	
	if( ! is_user_alive( iPlayer ) )
	{
		client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "SLAY_DEAD_PLAYER" );
		return PLUGIN_HANDLED;
	}
	
	new szNameAdmin[ MAX_NAME_LENGTH ], szNameUser[ MAX_NAME_LENGTH ];
	
	get_user_name( id, szNameAdmin, charsmax( szNameAdmin ) );
	get_user_name( iPlayer, szNameUser, charsmax( szNameUser ) );
	
	user_kill( iPlayer );
	
	CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "SLAY", szNameAdmin, szNameUser, szReason );
	log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_SLAY", szNameAdmin, szNameUser, szReason );
	
	arrayset( g_iSlay[ id ], 0, sizeof( g_iSlay[ ] ) );

	new iMenu = @CommandsMenu( id );
	@CommandsMenu_Handler( id, iMenu, 7 );

	return PLUGIN_HANDLED;
}

///////////////////////////////////////////////////////////////////// END OF MESSAGEMODE /////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////// COMMANDS MENU /////////////////////////////////////////////////////////////////////////////////////////////////////////
@CommandsMenu( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ COMMANDS_MENU_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}
	
	new szMenuTitle[ 64 ];
	formatex( szMenuTitle, charsmax( szMenuTitle ), "\rElite Admin System Menu^n\wVersion: \r%s", PLUGIN_VERSION );
	
	new iMenu = menu_create( szMenuTitle, "@CommandsMenu_Handler" );
	
	new szMenuItem[ 64 ];
	
	formatex( szMenuItem, charsmax( szMenuItem ), "%L", id, "KICK_MENU" );
	menu_additem( iMenu, szMenuItem );
	
	formatex( szMenuItem, charsmax( szMenuItem ), "%L", id, "BAN_MENU" );
	menu_additem( iMenu, szMenuItem );
	
	formatex( szMenuItem, charsmax( szMenuItem ), "%L", id, "ADDBAN_MENU" );
	menu_additem( iMenu, szMenuItem );
	
	formatex( szMenuItem, charsmax( szMenuItem ), "%L", id, "ADDGAG_MENU" );
	menu_additem( iMenu, szMenuItem );
	
	formatex( szMenuItem, charsmax( szMenuItem ), "%L", id, "GAG_MENU" );
	menu_additem( iMenu, szMenuItem );
	
	formatex( szMenuItem, charsmax( szMenuItem ), "%L", id, "UNBAN_MENU" );
	menu_additem( iMenu, szMenuItem );

	formatex( szMenuItem, charsmax( szMenuItem ), "%L", id, "UNGAG_MENU" );
	menu_additem( iMenu, szMenuItem );

	formatex( szMenuItem, charsmax( szMenuItem ), "%L", id, "SLAY_MENU" );
	menu_additem( iMenu, szMenuItem );
	
	formatex( szMenuItem, charsmax( szMenuItem ), "%L", id, "SLAP_MENU" );
	menu_additem( iMenu, szMenuItem );
	
	formatex( szMenuItem, charsmax( szMenuItem ), "%L", id, "TEAM_MENU" );
	menu_additem( iMenu, szMenuItem );
	
	formatex( szMenuItem, charsmax( szMenuItem ), "%L", id, "MAP_MENU" );
	menu_additem( iMenu, szMenuItem );
	
	formatex( szMenuItem, charsmax( szMenuItem ), "%L", id, "FREEZE_MENU" );
	menu_additem( iMenu, szMenuItem );
	
	menu_display( id, iMenu, 0 );
	
	return iMenu;
}

@CommandsMenu_Handler( id, iMenu, iItem )
{
	if( iItem == MENU_EXIT )
	{
		menu_destroy( iMenu );
		return PLUGIN_HANDLED;
	}
	
	new iMenu2, szMenuTitle[ 64 ];
	
	switch( iItem )
	{	
	case 0:
		{
			if( ~ get_user_flags( id ) & g_iConfig[ KICK_FLAG ] )
			{
				client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_MENU" );
				menu_destroy( iMenu );
				
				return PLUGIN_HANDLED;
			}
			
			formatex( szMenuTitle, charsmax( szMenuTitle ), "%L", id, "KICK_MENU" );
			iMenu2 = menu_create( szMenuTitle, "@KickMenu" );
			
			new iPlayers[ MAX_PLAYERS ], iNum, iTempId, szName[ MAX_NAME_LENGTH ], szId[ 3 ];
			get_players( iPlayers, iNum, "h" );
			
			for( new i; i < iNum; i++ )
			{	
				iTempId = iPlayers[ i ];
				
				get_user_name( iTempId, szName, charsmax( szName ) );
				num_to_str( iTempId, szId, charsmax( szId ) );
				
				menu_additem( iMenu2, szName, szId );
			}
			menu_display( id, iMenu2, 0 );
		}
		
	case 1:
		{
			if( ~ get_user_flags( id ) & g_iConfig[ BAN_FLAG ] )
			{
				client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_MENU" );
				menu_destroy( iMenu );
				
				return PLUGIN_HANDLED;
			}
			
			formatex( szMenuTitle, charsmax( szMenuTitle ), "%L", id, "BAN_MENU" );
			iMenu2 = menu_create( szMenuTitle, "@BanMenu" );
			
			new iPlayers[ MAX_PLAYERS ], iNum, iTempId, szName[ MAX_NAME_LENGTH ], szId[ 3 ];
			get_players( iPlayers, iNum, "h" );
			
			for( new i; i < iNum; i++ )
			{
				iTempId = iPlayers[ i ];
				
				get_user_name( iTempId, szName, charsmax( szName ) );
				num_to_str( iTempId, szId, charsmax( szId ) );
				
				menu_additem( iMenu2, szName, szId );
			}
			menu_display( id, iMenu2, 0 );
		}
		
	case 2:
		{
			if( ~ get_user_flags( id ) & g_iConfig[ ADD_BAN_FLAG ] )
			{
				client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_MENU" );
				menu_destroy( iMenu );
				
				return PLUGIN_HANDLED;
			}
			
			formatex( szMenuTitle, charsmax( szMenuTitle ), "%L", id, "ADDBAN_MENU" );
			iMenu2 = menu_create( szMenuTitle, "@AddBanMenu" );
			
			new szAddNewBan[ 20 ];
			formatex( szAddNewBan, charsmax( szAddNewBan ), "%L", id, "ADD_NEW_BAN" );
			
			menu_additem( iMenu2, szAddNewBan );
			
			menu_display( id, iMenu2, 0 );
		}
		
	case 3:
		{
			if( ~ get_user_flags( id ) & g_iConfig[ ADD_GAG_FLAG ] )
			{
				client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_MENU" );
				menu_destroy( iMenu );
				
				return PLUGIN_HANDLED;
			}
			
			formatex( szMenuTitle, charsmax( szMenuTitle ), "%L", id, "ADDGAG_MENU" );
			iMenu2 = menu_create( szMenuTitle, "@AddGagMenu" );
			
			new szAddNewGag[ 20 ];
			formatex( szAddNewGag, charsmax( szAddNewGag ), "%L", id, "ADD_NEW_GAG" );
			
			menu_additem( iMenu2, szAddNewGag );
			menu_display( id, iMenu2, 0 );			
		}
		
	case 4:
		{
			if( ~ get_user_flags( id ) & g_iConfig[ GAG_FLAG ] )
			{
				client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_MENU" );
				menu_destroy( iMenu );
				
				return PLUGIN_HANDLED;
			}
			
			formatex( szMenuTitle, charsmax( szMenuTitle ), "%L", id, "GAG_MENU" );
			iMenu2 = menu_create( szMenuTitle, "@GagMenu" );
			
			new iPlayers[ MAX_PLAYERS ], iNum, iTempId, szName[ MAX_NAME_LENGTH ], szId[ 3 ];
			get_players( iPlayers, iNum, "ch" );
			
			for( new i; i < iNum; i++ )
			{
				iTempId = iPlayers[ i ];
				
				get_user_name( iTempId, szName, charsmax( szName ) );
				num_to_str( iTempId, szId, charsmax( szId ) );
				
				menu_additem( iMenu2, szName, szId );
			}
			menu_display( id, iMenu2, 0 );
		}
		
	case 5:
		{
			if( ~ get_user_flags( id ) & g_iConfig[ UNBAN_FLAG ] )
			{
				client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_MENU" );
				menu_destroy( iMenu );
				
				return PLUGIN_HANDLED;
			}
			
			ReadBans( );
			CheckExistingBans( );
			
			new szItemName[ 192 ], szInfo[ 128 ];
			formatex( szMenuTitle, charsmax( szMenuTitle ), "%L", id, "UNBAN_MENU" );
			iMenu2 = menu_create( szMenuTitle, "@UnbanMenu" );
			
			menu_setprop( iMenu2, MPROP_PERPAGE, 5 );
			
			new eData[ PlayerBan ], bool:bBansFound;
			for( new i; i < ArraySize( g_aBans ); i++ )
			{			
				ArrayGetArray( g_aBans, i, eData );
				
				formatex( szItemName, charsmax( szItemName ), "\r%s \w| \y%s \w| \d%s", eData[ Player_Name ], eData[ Player_SteamId ], eData[ Player_IP ] );
				formatex( szInfo, charsmax( szInfo ), "^"%s^" ^"%s^" ^"%s^"", eData[ Player_Name ], eData[ Player_SteamId ], eData[ Player_IP ] );
				
				menu_additem( iMenu2, szItemName, szInfo );
				
				bBansFound = true;
			}
			
			if( ! bBansFound )
			{
				CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_BANS_FOUND" );
				menu_destroy( iMenu );
				
				return PLUGIN_HANDLED;
			}
			menu_display( id, iMenu2, 0 );
		}
		
	case 6:
		{
			if( ~ get_user_flags( id ) & g_iConfig[ UNGAG_FLAG ] )
			{
				client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_MENU" );
				menu_destroy( iMenu );
				
				return PLUGIN_HANDLED;
			}
			
			ReadGags( );
			CheckExistingGags( );
			
			new szItemName[ 192 ], szInfo[ 128 ];
			formatex( szMenuTitle, charsmax( szMenuTitle ), "%L", id, "UNGAG_MENU" );
			iMenu2 = menu_create( szMenuTitle, "@UnGagMenu" );
			
			new eData[ PlayerGag ], bool:bGagsFound;
			for( new i; i < ArraySize( g_aGags ); i++ )
			{			
				ArrayGetArray( g_aGags, i, eData );
				
				formatex( szItemName, charsmax( szItemName ), "\r%s \w| \y%s \w| \d%s", eData[ Player_Name ], eData[ Player_SteamId ], eData[ Player_IP ] );
				formatex( szInfo, charsmax( szInfo ), "^"%s^" ^"%s^" ^"%s^"", eData[ Player_Name ], eData[ Player_SteamId ], eData[ Player_IP ] );
				
				menu_additem( iMenu2, szItemName, szInfo );
				
				bGagsFound = true;
			}
			
			if( ! bGagsFound )
			{
				CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_GAGS_FOUND" );
				menu_destroy( iMenu );
				
				return PLUGIN_HANDLED;
			}
			menu_display( id, iMenu2, 0 );
		}	
		
	case 7:
		{
			if( ~ get_user_flags( id ) & g_iConfig[ SLAY_FLAG ] )
			{
				client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_MENU" );
				menu_destroy( iMenu );
				
				return PLUGIN_HANDLED;
			}
			
			formatex( szMenuTitle, charsmax( szMenuTitle ), "%L", id, "SLAY_MENU" );
			iMenu2 = menu_create( szMenuTitle, "@SlayMenu" );
			
			new iPlayers[ MAX_PLAYERS ], iNum, iTempId, szName[ MAX_NAME_LENGTH ], szId[ 3 ];
			get_players( iPlayers, iNum, "ah" );
			
			for( new i; i < iNum; i++ )
			{
				iTempId = iPlayers[ i ];
				
				get_user_name( iTempId, szName, charsmax( szName ) );
				
				num_to_str( iTempId, szId, charsmax( szId ) );
				menu_additem( iMenu2, szName, szId );
			}
			menu_display( id, iMenu2, 0 );
		}
		
	case 8:
		{
			if( ~ get_user_flags( id ) & g_iConfig[ SLAP_FLAG ] )
			{
				client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_MENU" );
				menu_destroy( iMenu );
				
				return PLUGIN_HANDLED;
			}
			
			formatex( szMenuTitle, charsmax( szMenuTitle ), "%L", id, "SLAP_MENU" );
			iMenu2 = menu_create( szMenuTitle, "@SlapMenu" );
			
			new iPlayers[ MAX_PLAYERS ], iNum, iTempId, szName[ MAX_NAME_LENGTH ], szId[ 3 ];
			get_players( iPlayers, iNum, "ah" );
			
			for( new i; i < iNum; i++ )
			{
				iTempId = iPlayers[ i ];
				
				get_user_name( iTempId, szName, charsmax( szName ) );
				
				num_to_str( iTempId, szId, charsmax( szId ) );
				menu_additem( iMenu2, szName, szId );
			}
			menu_display( id, iMenu2, 0 );
		}
		
	case 9:
		{
			if( ~ get_user_flags( id ) & g_iConfig[ TEAM_FLAG ] )
			{
				client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_MENU" );
				menu_destroy( iMenu );
				
				return PLUGIN_HANDLED;
			}
			
			new iPlayers[ MAX_PLAYERS ], iNum, iTempId, szName[ MAX_NAME_LENGTH*2 ], szSwitch[ 64 ], szPlayerTeam[ 20 ], szId[ 3 ], iCount, bool:bSwitchAdded;
			get_players( iPlayers, iNum, "ch" );
			
			if( g_iTeamSwitch[ id ] == TEAM_UNASSIGNED )
			{
				get_user_team( id ) == TEAM_T ? ( g_iTeamSwitch[ id ] = TEAM_CT ) : ( g_iTeamSwitch[ id ] = TEAM_T );
				GetTeamName( g_iTeamSwitch[ id ], g_szTeamSwitch[ id ], charsmax( g_szTeamSwitch[ ] ) ); // CT
			}
			
			formatex( szMenuTitle, charsmax( szMenuTitle ), "%L", id, "TEAM_MENU" );
			iMenu2 = menu_create( szMenuTitle, "@TeamMenu" );
			
			formatex( szSwitch, charsmax( szSwitch ), "%L: \r%s", id, "CURRENT_SWITCH_TEAM", g_szTeamSwitch[ id ] ); // switch CT

			if( iNum > 6 ) // more than 6 players, if we want switch to always be 7th we have to stop adding items and add the switch
			{
				for( new i; i < iNum; i++ )
				{
					iTempId = iPlayers[ i ];
					
					if( iCount == 6 && ! bSwitchAdded )
					{
						menu_additem( iMenu2, szSwitch, "switch" );
						bSwitchAdded = true;
					}
					
					get_user_name( iTempId, szName, charsmax( szName ) );
					get_user_team( iTempId, szPlayerTeam, charsmax( szPlayerTeam ) );
					
					num_to_str( iTempId, szId, charsmax( szId ) );
					
					if( ! equali( szPlayerTeam, g_szTeamSwitch[ id ] ) )
					{
						format( szName, charsmax( szName ), "%s \y[%s]", szName, szPlayerTeam );
					}
					
					else
					{
						format( szName, charsmax( szName ), "\d%s [%s]", szName, szPlayerTeam );
					}    
					menu_additem( iMenu2, szName, szId );
					iCount++;
				}
			}

			else
			{
				if( iNum == 6 ) // if theres 6 players no need to add blanks
				{
					for( new i; i < iNum; i++ )
					{
						iTempId = iPlayers[ i ];
						
						get_user_name( iTempId, szName, charsmax( szName ) );
						get_user_team( iTempId, szPlayerTeam, charsmax( szPlayerTeam ) );
						
						num_to_str( iTempId, szId, charsmax( szId ) );

						if( ! equali( szPlayerTeam, g_szTeamSwitch[ id ] ) )
						{
							format( szName, charsmax( szName ), "%s \y[%s]", szName, szPlayerTeam );
						}
						
						else
						{
							format( szName, charsmax( szName ), "\d%s [%s]", szName, szPlayerTeam );
						}    
						menu_additem( iMenu2, szName, szId );
					}
					menu_additem( iMenu2, szSwitch, "switch" );
				}
				
				else // need to add blanks
				{
					for( new i; i < iNum; i++ ) // add all players to the list
					{
						iTempId = iPlayers[ i ];
						
						get_user_name( iTempId, szName, charsmax( szName ) );
						get_user_team( iTempId, szPlayerTeam, charsmax( szPlayerTeam ) );
						
						num_to_str( iTempId, szId, charsmax( szId ) );
						
						if( ! equali( szPlayerTeam, g_szTeamSwitch[ id ] ) )
						{
							format( szName, charsmax( szName ), "%s \y[%s]", szName, szPlayerTeam );
						}
						
						else
						{
							format( szName, charsmax( szName ), "\d%s [%s]", szName, szPlayerTeam );
						}
						menu_additem( iMenu2, szName, szId );
					}
					new iCalculateBlanks = 6 - iNum; // calculate how many blanks we need
					for( new i = 1; i <= iCalculateBlanks; i++ )
					{
						menu_addblank( iMenu2, 0 ); // add the blanks
					}
					menu_additem( iMenu2, szSwitch, "switch" ); // add switch
				}
			}
			menu_display( id, iMenu2, 0 );
		}
		
	case 10:
		{
			if( ~ get_user_flags( id ) & g_iConfig[ MAP_FLAG ] )
			{
				client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_MENU" );
				menu_destroy( iMenu );
				
				return PLUGIN_HANDLED;
			}
			
			formatex( szMenuTitle, charsmax( szMenuTitle ), "%L", id, "MAP_MENU" );
			iMenu2 = menu_create( szMenuTitle, "@MapMenu" );
			
			new szMapName[ MAX_MAP_NAME_LENGTH ];
			for( new i; i < ArraySize( g_aMaps ); i++ )
			{
				ArrayGetString( g_aMaps, i, szMapName, charsmax( szMapName ) );

				menu_additem( iMenu2, szMapName, szMapName );
			}
			menu_display( id, iMenu2, 0 );
		}
		
	case 11:
		{
			if( ~ get_user_flags( id ) & g_iConfig[ FREEZE_FLAG ] )
			{
				client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_MENU" );
				menu_destroy( iMenu );
				
				return PLUGIN_HANDLED;
			}
			
			formatex( szMenuTitle, charsmax( szMenuTitle ), "%L", id, "FREEZE_MENU" );
			iMenu2 = menu_create( szMenuTitle, "@FreezeMenu" );
			
			new iPlayers[ MAX_PLAYERS ], iNum, iTempId, szName[ MAX_NAME_LENGTH ], szId[ 3 ];
			get_players( iPlayers, iNum, "ah" );
			
			for( new i; i < iNum; i++ )
			{
				iTempId = iPlayers[ i ];
				
				get_user_name( iTempId, szName, charsmax( szName ) );
				
				num_to_str( iTempId, szId, charsmax( szId ) );
				menu_additem( iMenu2, szName, szId );
			}
			menu_display( id, iMenu2, 0 );
		}
	}
	menu_destroy( iMenu );
	return PLUGIN_HANDLED;
}

GetTeamName( iTeam, szOutput[ ], iSize )
{
	switch( iTeam )
	{
	case TEAM_T:
		{
			copy( szOutput, iSize, "TERRORIST" );
		}

	case TEAM_CT:
		{
			copy( szOutput, iSize, "CT" );
		}

	case TEAM_SPEC:
		{
			copy( szOutput, iSize, "SPECTATOR" );
		}
	}
}
///////////////////////////////////////////////////////////////////// END OF COMMANDS MENU /////////////////////////////////////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////// COMMAND MENUS /////////////////////////////////////////////////////////////////////////////////////////////////////////

@MapMenu( id, iMenu, iItem )
{
	if( iItem == MENU_EXIT )
	{
		menu_destroy( iMenu );
		return PLUGIN_HANDLED;
	}
	
	new iAccess, szMap[ MAX_MAP_NAME_LENGTH ], iCallback;
	menu_item_getinfo( iMenu, iItem, iAccess, szMap, charsmax( szMap ), _, _, iCallback );
	menu_destroy( iMenu );
	
	if( ! is_map_valid( szMap ) )
	{
		CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "MAP_NOT_FOUND_COLORED" );
		return PLUGIN_HANDLED;
	}
	
	new szName[ MAX_NAME_LENGTH ], szModName[ 10 ];
	get_user_name( id, szName, charsmax( szName ) );
	get_modname( szModName, charsmax( szModName ) );
	
	if( ! equali( szModName, "zp" ) )
	{
		message_begin( MSG_ALL, SVC_INTERMISSION );
		message_end( );
	}
	
	CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "MAP_CHANGE", szName, szMap );
	log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_MAP_CHANGE", szName, szMap );
	
	set_task( 2.0, "OnMapChange", _, szMap, ( strlen( szMap ) + 1 ) );
	return PLUGIN_HANDLED;
}

@SlapMenu( id, iMenu, iItem )
{
	if( iItem == MENU_EXIT )
	{
		menu_destroy( iMenu );
		return PLUGIN_HANDLED;
	}
	
	new iAccess, szId[ 3 ], iCallback;
	menu_item_getinfo( iMenu, iItem, iAccess, szId, charsmax( szId ), _, _, iCallback );
	menu_destroy( iMenu );
	
	new iPlayer = str_to_num( szId );
	
	if( ! is_user_connected( iPlayer ) )
	{
		CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "PLAYER_NOT_FOUND_COLORED" );
		return PLUGIN_HANDLED;
	}
	
	if( ! is_user_alive( iPlayer ) )
	{
		client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "SLAP_DEAD_PLAYER" );
		return PLUGIN_HANDLED;
	}
	
	new iImmunityLevel = GetImmunityLevel( id );
	new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
	
	if( iImmunityLevel < iImmunityLevelTarget )
	{
		CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY_COLORED" );
		return PLUGIN_HANDLED;
	}
	
	g_iSlap[ id ][ SLAP_ID ] = iPlayer;	
	client_cmd( id, "messagemode slapPlayerValue" );
	
	return PLUGIN_HANDLED;
}

@TeamMenu( id, iMenu, iItem )
{
	if( iItem == MENU_EXIT )
	{
		g_iTeamSwitch[ id ] = 0;
		arrayset( g_szTeamSwitch[ id ], 0, sizeof( g_szTeamSwitch[ ] ) );
		
		menu_destroy( iMenu );
		return PLUGIN_HANDLED;
	}

	new iAccess, szInfo[ 10 ], iCallback;
	menu_item_getinfo( iMenu, iItem, iAccess, szInfo, charsmax( szInfo ), _, _, iCallback );
	menu_destroy( iMenu );
	
	if( equali( szInfo, "switch" ) )
	{
		// if it's TEAM_SPEC (3), reset  back to TEAM_T (1), otherwise increase by 1 (TEAM_T becomes TEAM_CT, TEAM_CT becomes TEAM_SPEC)
		switch( g_iTeamSwitch[ id ] )
		{
		case TEAM_T:
			{
				g_iTeamSwitch[ id ] = TEAM_CT;
			}
			
		case TEAM_CT:
			{
				g_iTeamSwitch[ id ] = TEAM_SPEC;
			}
			
		case TEAM_SPEC:
			{
				g_iTeamSwitch[ id ] = TEAM_T;
			}
		}
		
		GetTeamName( g_iTeamSwitch[ id ], g_szTeamSwitch[ id ], charsmax( g_szTeamSwitch[ ] ) );
		set_task( 0.1, "ReOpenTeamMenu", id + TASK_TEAM_MENU );
		
		return PLUGIN_HANDLED;
	}
	
	new iPlayer = str_to_num( szInfo );
	
	if( ! is_user_connected( iPlayer ) )
	{
		CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "PLAYER_NOT_FOUND_COLORED" );
		return PLUGIN_HANDLED;
	}

	new szTeam[ 20 ];
	get_user_team( iPlayer, szTeam, charsmax( szTeam ) );
	
	if( equali( szTeam, g_szTeamSwitch[ id ] ) ) // same team, reopen menu
	{
		set_task( 0.1, "ReOpenTeamMenu", id + TASK_TEAM_MENU );
		return PLUGIN_HANDLED;
	}
	
	new iImmunityLevel = GetImmunityLevel( id );
	new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
	
	if( iImmunityLevel < iImmunityLevelTarget )
	{
		CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY_COLORED" );
		return PLUGIN_HANDLED;
	}
	
	new szSteamIdAdmin[ MAX_AUTHID_LENGTH ], szNameAdmin[ MAX_NAME_LENGTH ], szNamePlayer[ MAX_NAME_LENGTH ], szTeamFinal[ 20 ];

	get_user_authid( id, szSteamIdAdmin, charsmax( szSteamIdAdmin ) );
	get_user_name( id, szNameAdmin, charsmax( szNameAdmin ) );
	get_user_name( iPlayer, szNamePlayer, charsmax( szNamePlayer ) );
	
	if( equali( g_szTeamSwitch[ id ], "TERRORIST" ) )
	{
		eas_set_user_team( iPlayer, 1 );
		copy( szTeamFinal, charsmax( szTeamFinal ), "Terrorist" );
	}
	
	else if( equali( g_szTeamSwitch[ id ], "CT" ) )
	{
		eas_set_user_team( iPlayer, 2 );
		copy( szTeamFinal, charsmax( szTeamFinal ), "Counter-Terrorist" );
	}
	
	else if( equali( g_szTeamSwitch[ id ], "SPECTATOR" ) )
	{
		eas_set_user_team( iPlayer, 3 );
		copy( szTeamFinal, charsmax( szTeamFinal ), "Spectator" );
	}
	
	CC_SendMatched( 0, iPlayer, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "TEAM_CHANGE", szNameAdmin, szNamePlayer, szTeamFinal );
	log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "TEAM_CHANGE_LOG", szNameAdmin, szSteamIdAdmin, szNamePlayer, szTeamFinal );
	
	set_task( 0.1, "ReOpenTeamMenu", id + TASK_TEAM_MENU );
	
	return PLUGIN_HANDLED;
}

@FreezeMenu( id, iMenu, iItem )
{
	if( iItem == MENU_EXIT )
	{
		menu_destroy( iMenu );
		return PLUGIN_HANDLED;
	}
	
	new iAccess, szId[ 3 ], iCallback;
	menu_item_getinfo( iMenu, iItem, iAccess, szId, charsmax( szId ), _, _, iCallback );
	menu_destroy( iMenu );
	
	new iPlayer = str_to_num( szId );
	
	if( ! is_user_connected( iPlayer ) )
	{
		CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "PLAYER_NOT_FOUND_COLORED" );
		return PLUGIN_HANDLED;
	}
	
	if( ! is_user_alive( iPlayer ) )
	{
		client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "FREEZE_DEAD_PLAYER" );
		return PLUGIN_HANDLED;
	}
	
	new iImmunityLevel = GetImmunityLevel( id );
	new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
	
	if( iImmunityLevel < iImmunityLevelTarget )
	{
		CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY_COLORED" );
		return PLUGIN_HANDLED;
	}
	
	new iValue = g_bFrozen[ iPlayer ] ? 0 : 1;
	FreezePlayer( iPlayer, iValue );

	new szAdminSteamId[ MAX_AUTHID_LENGTH ], szAdminName[ MAX_NAME_LENGTH ], szPlayerName[ MAX_NAME_LENGTH ];
	get_user_name( iPlayer, szPlayerName, charsmax( szPlayerName ) );
	get_user_name( id, szAdminName, charsmax( szAdminName ) );
	get_user_authid( id, szAdminSteamId, charsmax( szAdminSteamId ) );
	
	switch( iValue )
	{
	case 0:
		{
			log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_FREEZE_UNSET", szAdminName, szAdminSteamId, szPlayerName );
			CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "FREEZE_UNSET", szAdminName, szPlayerName );
		}
		
	case 1:
		{
			log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_FREEZE_SET", szAdminName, szAdminSteamId, szPlayerName );
			CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "FREEZE_SET", szAdminName, szPlayerName );
		}
	}
	
	new iMenu = @CommandsMenu( id );
	@CommandsMenu_Handler( id, iMenu, 11 );

	return PLUGIN_HANDLED;
}

@SlayMenu( id, iMenu, iItem )
{
	if( iItem == MENU_EXIT )
	{
		menu_destroy( iMenu );
		return PLUGIN_HANDLED;
	}
	
	new iAccess, szId[ 3 ], iCallback;
	menu_item_getinfo( iMenu, iItem, iAccess, szId, charsmax( szId ), _, _, iCallback );
	menu_destroy( iMenu );
	
	new iPlayer = str_to_num( szId );
	
	if( ! is_user_connected( iPlayer ) )
	{
		CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "PLAYER_NOT_FOUND_COLORED" );
		return PLUGIN_HANDLED;
	}
	
	if( ! is_user_alive( iPlayer ) )
	{
		client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "SLAY_DEAD_PLAYER" );
		return PLUGIN_HANDLED;
	}
	
	new iImmunityLevel = GetImmunityLevel( id );
	new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
	
	if( iImmunityLevel < iImmunityLevelTarget )
	{
		CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY_COLORED" );
		return PLUGIN_HANDLED;
	}
	
	g_iSlay[ id ][ SLAY_ID ] = iPlayer;
	client_cmd( id, "messagemode slayPlayerReason" );
	
	return PLUGIN_HANDLED;
}

@UnbanMenu( id, iMenu, iItem )
{
	if( iItem == MENU_EXIT )
	{
		menu_destroy( iMenu );
		return PLUGIN_HANDLED;
	}
	
	new iAccess, szInfo[ 128 ], szName[ MAX_NAME_LENGTH ], szSteamId[ MAX_AUTHID_LENGTH ], szIP[ MAX_IP_LENGTH ], iCallback;
	menu_item_getinfo( iMenu, iItem, iAccess, szInfo, charsmax( szInfo ), _, _, iCallback );
	menu_destroy( iMenu );
	
	parse( szInfo, szName, charsmax( szName ), szSteamId, charsmax( szSteamId ), szIP, charsmax( szIP ) );
	
	trim( szName );
	trim( szSteamId );
	trim( szIP );
	
	UnbanPlayer2( szName, szSteamId, szIP );
	
	new szNameAdmin[ MAX_NAME_LENGTH ];
	get_user_name( id, szNameAdmin, charsmax( szNameAdmin ) );
	
	CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "UNBANNED", szNameAdmin, szName, szSteamId, szIP );		
	log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_UNBANNED", szNameAdmin, szName, szSteamId, szIP );
	
	if( ArraySize( g_aBans ) )
	{
		set_task( 0.1, "ReOpenUnbanMenu", id + TASK_UNBAN_MENU );
	}
	
	else
	{
		@CommandsMenu( id );
	}
	return PLUGIN_HANDLED;
}

@UnGagMenu( id, iMenu, iItem )
{
	if( iItem == MENU_EXIT )
	{
		menu_destroy( iMenu );
		return PLUGIN_HANDLED;
	}
	
	new iAccess, szInfo[ 128 ], szName[ MAX_NAME_LENGTH ], szSteamId[ MAX_AUTHID_LENGTH ], szIP[ MAX_IP_LENGTH ], iCallback;
	menu_item_getinfo( iMenu, iItem, iAccess, szInfo, charsmax( szInfo ), _, _, iCallback );
	menu_destroy( iMenu );
	
	parse( szInfo, szName, charsmax( szName ), szSteamId, charsmax( szSteamId ), szIP, charsmax( szIP ) );
	
	trim( szName );
	trim( szSteamId );
	trim( szIP );
	
	UnGagPlayer2( szName, szSteamId, szIP );
	
	new szNameAdmin[ MAX_NAME_LENGTH ];
	get_user_name( id, szNameAdmin, charsmax( szNameAdmin ) );
	
	CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "UNGAGGED", szNameAdmin, szName, szSteamId, szIP );
	log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_UNGAGGED", szNameAdmin, szName, szSteamId, szIP );
	
	if( ArraySize( g_aGags ) )
	{
		set_task( 0.1, "ReOpenUnGagMenu", id + TASK_UNGAG_MENU );
	}
	
	else
	{
		@CommandsMenu( id );
	}
	return PLUGIN_HANDLED;
}

@AddBanMenu( id, iMenu, iItem )
{
	if( iItem == MENU_EXIT )
	{
		menu_destroy( iMenu );
		return PLUGIN_HANDLED;
	}
	
	switch( iItem )
	{
	case 0:
		{
			client_cmd( id, "messagemode addBanPlayerName" );
		}
	}
	menu_destroy( iMenu );
	return PLUGIN_HANDLED;
}

@AddGagMenu( id, iMenu, iItem )
{
	if( iItem == MENU_EXIT )
	{
		menu_destroy( iMenu );
		return PLUGIN_HANDLED;
	}
	
	switch( iItem )
	{
	case 0:
		{
			client_cmd( id, "messagemode addgagPlayerName" );
		}
	}
	menu_destroy( iMenu );
	return PLUGIN_HANDLED;
}

@KickMenu( id, iMenu, iItem )
{
	if( iItem == MENU_EXIT )
	{
		menu_destroy( iMenu );
		return PLUGIN_HANDLED;
	}
	
	new iAccess, szId[ 3 ], iCallback;
	menu_item_getinfo( iMenu, iItem, iAccess, szId, charsmax( szId ), _, _, iCallback );
	menu_destroy( iMenu );
	
	new iPlayer = str_to_num( szId );
	
	if( ! is_user_connected( iPlayer ) )
	{
		CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "PLAYER_NOT_FOUND_COLORED" );
		return PLUGIN_HANDLED;
	}
	
	new iImmunityLevel = GetImmunityLevel( id );
	new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
	
	if( iImmunityLevel < iImmunityLevelTarget )
	{
		CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], "CANT_PERFORM_IMMUNITY_COLORED" );
		return PLUGIN_HANDLED;
	}
	
	g_iKick[ id ] = iPlayer;
	client_cmd( id, "messagemode kickReason" );

	return PLUGIN_HANDLED;
}

@BanMenu( id, iMenu, iItem )
{
	if( iItem == MENU_EXIT )
	{
		menu_destroy( iMenu );
		return PLUGIN_HANDLED;
	}
	
	new iAccess, szId[ 3 ], iCallback;
	menu_item_getinfo( iMenu, iItem, iAccess, szId, charsmax( szId ), _, _, iCallback );
	menu_destroy( iMenu );
	
	new iPlayer = str_to_num( szId );
	
	if( ! is_user_connected( iPlayer ) )
	{
		CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "PLAYER_NOT_FOUND_COLORED" );
		return PLUGIN_HANDLED;
	}
	
	new iImmunityLevel = GetImmunityLevel( id );
	new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
	
	if( iImmunityLevel < iImmunityLevelTarget )
	{
		CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY_COLORED" );
		return PLUGIN_HANDLED;
	}
	
	g_iBan[ id ][ BAN_ID ] = iPlayer;
	client_cmd( id, "messagemode banPlayerMinutes" );

	return PLUGIN_HANDLED;
}

@GagMenu( id, iMenu, iItem )
{
	if( iItem == MENU_EXIT )
	{
		menu_destroy( iMenu );
		return PLUGIN_HANDLED;
	}
	
	new iAccess, szId[ 3 ], iCallback;
	menu_item_getinfo( iMenu, iItem, iAccess, szId, charsmax( szId ), _, _, iCallback );
	menu_destroy( iMenu );
	
	new iPlayer = str_to_num( szId );
	
	if( ! is_user_connected( iPlayer ) )
	{
		CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "PLAYER_NOT_FOUND_COLORED" );
		return PLUGIN_HANDLED;
	}
	
	new iImmunityLevel = GetImmunityLevel( id );
	new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
	
	if( iImmunityLevel < iImmunityLevelTarget )
	{
		CC_SendMessage( id, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY_COLORED" );
		return PLUGIN_HANDLED;
	}
	
	g_iGag[ id ][ GAG_ID ] = iPlayer;
	client_cmd( id, "messagemode gagPlayerSeconds" );

	return PLUGIN_HANDLED;
}

///////////////////////////////////////////////////////////////////// END OF COMMAND MENUS /////////////////////////////////////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////// CONSOLE COMMANDS /////////////////////////////////////////////////////////////////////////////////////////////////////////////

@Gag( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ GAG_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}

	new szName[ MAX_NAME_LENGTH ], szReason[ MAX_REASON_LENGTH ], szSeconds[ 8 ], szFlags[ 5 ];
	read_argv( 1, szName, charsmax( szName ) );
	read_argv( 2, szSeconds, charsmax( szSeconds ) );
	read_argv( 3, szReason, charsmax( szReason ) );
	read_argv( 4, szFlags, charsmax( szFlags ) );
	
	if( read_argc( ) != 5 )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "AMX_GAG_USAGE" );
		return PLUGIN_HANDLED;
	}
	
	new iPlayer = cmd_target( id, szName, CMDTARGET_NO_BOTS );
	
	if( ! iPlayer )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "PLAYER_NOT_FOUND" );
		return PLUGIN_HANDLED;
	}
	
	new iImmunityLevel = GetImmunityLevel( id );
	new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
	
	if( iImmunityLevel < iImmunityLevelTarget )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY" );
		return PLUGIN_HANDLED;
	}
	
	new szSteamIdUser[ MAX_AUTHID_LENGTH ], szExpireDate[ MAX_DATE_LENGTH ], szIpUser[ MAX_IP_LENGTH ], szNameAdmin[ MAX_NAME_LENGTH ], szNameUser[ MAX_NAME_LENGTH ];
	
	get_user_ip( iPlayer, szIpUser, charsmax( szIpUser ), 1 );
	get_user_authid( iPlayer, szSteamIdUser, charsmax( szSteamIdUser ) );
	get_user_name( id, szNameAdmin, charsmax( szNameAdmin ) );
	get_user_name( iPlayer, szNameUser, charsmax( szNameUser ) );

	new iSeconds = str_to_num( szSeconds );
	
	if( iSeconds == 0 )
	{
		CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "GAGGED_PERMANENT", szNameAdmin, szNameUser, szFlags, szReason );
		log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_GAGGED_PERMANENT", szNameAdmin, szNameUser, szSteamIdUser, szIpUser, szReason );
		
		copy( szExpireDate, charsmax( szExpireDate ), "never" );
	}
	
	else
	{
		get_time( "%m/%d/%Y - %H:%M:%S", szExpireDate, charsmax( szExpireDate ) );
		
		AddSecondsToDate( szExpireDate, iSeconds, szExpireDate, charsmax( szExpireDate ) );
		
		if( iSeconds == 1 )
		{
			CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "GAGGED_SINGULAR", szNameAdmin, szNameUser, szReason, szFlags );
			log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_GAGGED_SINGULAR", szNameAdmin, szNameUser, szSteamIdUser, szIpUser, szReason, szExpireDate, szFlags );
		}
		
		else
		{
			CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "GAGGED_PLURAL", szNameAdmin, szNameUser, iSeconds, szReason, szFlags );
			log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_GAGGED_PLURAL", szNameAdmin, szNameUser, szSteamIdUser, szIpUser, iSeconds, szReason, szExpireDate, szFlags );
		}
	}
	
	trim( szNameUser );
	trim( szSteamIdUser );
	trim( szIpUser );
	trim( szExpireDate );
	trim( szReason );
	trim( szNameAdmin );
	
	new eData[ PlayerGag ];	
	copy( eData[ Player_Name ], charsmax( eData[ Player_Name ] ), szNameUser );
	copy( eData[ Player_SteamId ], charsmax( eData[ Player_SteamId ] ), szSteamIdUser );
	copy( eData[ Player_IP ], charsmax( eData[ Player_IP ] ), szIpUser );
	copy( eData[ Player_GagExpire ], charsmax( eData[ Player_GagExpire ] ), szExpireDate );
	copy( eData[ Player_GagReason ], charsmax( eData[ Player_GagReason ] ), szReason );
	copy( eData[ Player_GagFlags ], charsmax( eData[ Player_GagFlags ] ), szFlags );
	
	ArrayPushArray( g_aGags, eData );
	
	if( ( szFlags[ 0 ] == 'v' || szFlags[ 1 ] == 'v' ) && is_user_connected( id ) )
	{
		set_speak( iPlayer, SPEAK_MUTED );
	}
	
	GagPlayer( szNameUser, szSteamIdUser, szIpUser, szReason, szFlags, szExpireDate );
	
	set_task( 1.0, "TaskCheckGagExpire", id + TASK_GAG_CHECK, .flags="b" );
	
	return PLUGIN_HANDLED;
}

@UnGag( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ UNGAG_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}
	
	new szIdentity[ MAX_AUTHID_LENGTH ];
	read_argv( 1, szIdentity, charsmax( szIdentity ) );
	
	if( read_argc( ) != 2 )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "AMX_UNGAG_USAGE" );
		return PLUGIN_HANDLED;
	}
	
	ReadGags( );
	
	new eData[ PlayerGag ], bool:bFoundPlayer;
	for( new i; i < ArraySize( g_aGags ); i++ )
	{
		ArrayGetArray( g_aGags, i, eData );
		
		if( equali( szIdentity, eData[ Player_Name ] ) || equali( szIdentity, eData[ Player_SteamId ] ) || equali( szIdentity, eData[ Player_IP ] ) )
		{
			UnGagPlayer( szIdentity );
			
			new szNameAdmin[ MAX_NAME_LENGTH ];
			get_user_name( id, szNameAdmin, charsmax( szNameAdmin ) );
			
			CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "UNGAGGED", szNameAdmin, eData[ Player_Name ] );
			
			log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_UNGAGGED", szNameAdmin, eData[ Player_Name ] );
			bFoundPlayer = true;
			
			break;
		}
	}
	
	if( ! bFoundPlayer )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "PLAYER_NOT_FOUND" );
	}
	
	return PLUGIN_HANDLED;
}

@AdminSay( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ SAY_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}
	
	new szText[ MAX_TEXT_LENGTH ];
	read_args( szText, charsmax( szText ) );

	trim( szText );
	remove_quotes( szText );
	
	if( ! szText[ 0 ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "EMPTY_STRING_CONSOLE" );
		return PLUGIN_HANDLED;
	}
	
	new szName[ MAX_NAME_LENGTH ];
	get_user_name( id, szName, charsmax( szName ) );
	
	CC_SendMessage( 0, "&x04%s : &x04%s", szName, szText );
	return PLUGIN_HANDLED;
}

@AdminChat( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ CHAT_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}
	
	new szText[ MAX_TEXT_LENGTH ];
	read_args( szText, charsmax( szText ) );

	trim( szText );
	remove_quotes( szText );
	
	if( ! szText[ 0 ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "EMPTY_STRING_CONSOLE" );
		return PLUGIN_HANDLED;
	}
	
	new szName[ MAX_NAME_LENGTH ];
	get_user_name( id, szName, charsmax( szName ) );
	
	new iPlayers[ 32 ], iNum, iTempId;
	get_players( iPlayers, iNum, "ch" );
	
	for( new i; i < iNum; i++ )
	{
		iTempId = iPlayers[ i ];
		
		if( get_user_flags( iTempId ) & g_iConfig[ CHAT_FLAG ] )
		{
			CC_SendMessage( iTempId, "&x04(CHAT) &x03%s &x04:  &x01%s", szName, szText );
		}
	}
	return PLUGIN_HANDLED;
}

@Warn( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ WARN_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}
	
	new szName[ MAX_NAME_LENGTH ], szReason[ MAX_REASON_LENGTH ];
	read_argv( 1, szName, charsmax( szName ) );
	read_argv( 2, szReason, charsmax( szReason ) );
	
	if( read_argc( ) != 3 )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "AMX_WARN_USAGE" );
		return PLUGIN_HANDLED;
	}
	
	new iPlayer = cmd_target( id, szName, CMDTARGET_NO_BOTS );
	
	if( ! is_user_connected( iPlayer ) )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "PLAYER_NOT_FOUND" );
		return PLUGIN_HANDLED;
	}
	
	new iImmunityLevel = GetImmunityLevel( id );
	new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
	
	if( iImmunityLevel < iImmunityLevelTarget )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY" );
		return PLUGIN_HANDLED;
	}
	
	new szAdminSteamId[ MAX_AUTHID_LENGTH ], szAdminName[ MAX_NAME_LENGTH ], szPlayerName[ MAX_NAME_LENGTH ];
	get_user_name( iPlayer, szPlayerName, charsmax( szPlayerName ) );
	get_user_name( id, szAdminName, charsmax( szAdminName ) );
	get_user_authid( id, szAdminSteamId, charsmax( szAdminSteamId ) );
	
	log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_WARN", szAdminName, szAdminSteamId, szPlayerName, szReason );
	
	new iPlayers[ MAX_PLAYERS ], iNum, iTempId;
	get_players( iPlayers, iNum );
	
	CC_SendMessage( iPlayer, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], iPlayer, "WARN_HIM", szAdminName, szReason );
	
	for( new i; i < iNum; i++ )
	{
		iTempId = iPlayers[ i ];
		
		if( iTempId != iPlayer )
		{
			CC_SendMessage( iTempId, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], iTempId, "WARN_OTHERS", szAdminName, szPlayerName, szReason );
		}
	}
	
	return PLUGIN_HANDLED;
}

@Noclip( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ NOCLIP_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}
	
	new szName[ MAX_NAME_LENGTH ], szValue[ 3 ];
	read_argv( 1, szName, charsmax( szName ) );
	read_argv( 2, szValue, charsmax( szValue ) );
	
	if( read_argc( ) != 3 )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "AMX_NOCLIP_USAGE" );
		return PLUGIN_HANDLED;
	}
	
	new iPlayer = cmd_target( id, szName, CMDTARGET_ALLOW_SELF );
	
	if( ! is_user_connected( iPlayer ) )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "PLAYER_NOT_FOUND" );
		return PLUGIN_HANDLED;
	}
	
	if( ! is_user_alive( iPlayer ) )
	{
		client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NOCLIP_DEAD_PLAYER" );
		return PLUGIN_HANDLED;
	}
	
	new iImmunityLevel = GetImmunityLevel( id );
	new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
	
	if( iImmunityLevel < iImmunityLevelTarget )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY" );
		return PLUGIN_HANDLED;
	}
	
	new iValue = str_to_num( szValue );
	
	if( iValue < 0 || iValue > 1 )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "INVALID_NOCLIP_VALUE" );
		return PLUGIN_HANDLED;
	}
	
	set_user_noclip( iPlayer, iValue );
	
	new szAdminSteamId[ MAX_AUTHID_LENGTH ], szAdminName[ MAX_NAME_LENGTH ], szPlayerName[ MAX_NAME_LENGTH ];
	get_user_name( iPlayer, szPlayerName, charsmax( szPlayerName ) );
	get_user_name( id, szAdminName, charsmax( szAdminName ) );
	get_user_authid( id, szAdminSteamId, charsmax( szAdminSteamId ) );

	switch( iValue )
	{
	case 0:
		{
			log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_NOCLIP_UNSET", szAdminName, szAdminSteamId, szPlayerName );
			CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "NOCLIP_UNSET", szAdminName, szPlayerName );
		}
		
	case 1:
		{
			log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_NOCLIP_SET", szAdminName, szAdminSteamId, szPlayerName );
			CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "NOCLIP_SET", szAdminName, szPlayerName );
		}
	}
	
	return PLUGIN_HANDLED;
}

@Godmode( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ GODMODE_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}
	
	new szName[ MAX_NAME_LENGTH ], szValue[ 3 ];
	read_argv( 1, szName, charsmax( szName ) );
	read_argv( 2, szValue, charsmax( szValue ) );
	
	if( read_argc( ) != 3 )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "AMX_GODMODE_USAGE" );
		return PLUGIN_HANDLED;
	}
	
	new iPlayer = cmd_target( id, szName, CMDTARGET_ALLOW_SELF );
	
	if( ! is_user_connected( iPlayer ) )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "PLAYER_NOT_FOUND" );
		return PLUGIN_HANDLED;
	}
	
	if( ! is_user_alive( iPlayer ) )
	{
		client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "GODMODE_DEAD_PLAYER" );
		return PLUGIN_HANDLED;
	}
	
	new iImmunityLevel = GetImmunityLevel( id );
	new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
	
	if( iImmunityLevel < iImmunityLevelTarget )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY" );
		return PLUGIN_HANDLED;
	}
	
	new iValue = str_to_num( szValue );
	
	if( iValue < 0 || iValue > 1 )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "INVALID_GODMODE_VALUE" );
		return PLUGIN_HANDLED;
	}
	
	set_user_godmode( iPlayer, iValue );
	
	new szAdminSteamId[ MAX_AUTHID_LENGTH ], szAdminName[ MAX_NAME_LENGTH ], szPlayerName[ MAX_NAME_LENGTH ];
	get_user_name( iPlayer, szPlayerName, charsmax( szPlayerName ) );
	get_user_name( id, szAdminName, charsmax( szAdminName ) );
	get_user_authid( id, szAdminSteamId, charsmax( szAdminSteamId ) );

	switch( iValue )
	{
	case 0:
		{
			log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_GODMODE_UNSET", szAdminName, szAdminSteamId, szPlayerName );
			CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "GODMODE_UNSET", szAdminName, szPlayerName );
		}
		
	case 1:
		{
			log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_GODMODE_SET", szAdminName, szAdminSteamId, szPlayerName );
			CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "GODMODE_SET", szAdminName, szPlayerName );
		}
	}
	
	return PLUGIN_HANDLED;
}

@Freeze( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ FREEZE_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}
	
	new szName[ MAX_NAME_LENGTH ], szValue[ 3 ];
	read_argv( 1, szName, charsmax( szName ) );
	read_argv( 2, szValue, charsmax( szValue ) );
	
	if( read_argc( ) != 3 )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "AMX_FREEZE_USAGE" );
		return PLUGIN_HANDLED;
	}
	
	new iPlayer = cmd_target( id, szName, CMDTARGET_ALLOW_SELF );
	
	if( ! is_user_connected( iPlayer ) )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "PLAYER_NOT_FOUND" );
		return PLUGIN_HANDLED;
	}
	
	if( ! is_user_alive( iPlayer ) )
	{
		client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "FREEZE_DEAD_PLAYER" );
		return PLUGIN_HANDLED;
	}
	
	new iImmunityLevel = GetImmunityLevel( id );
	new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
	
	if( iImmunityLevel < iImmunityLevelTarget )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY" );
		return PLUGIN_HANDLED;
	}
	
	new iValue = str_to_num( szValue );
	
	if( iValue < 0 || iValue > 1 )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "INVALID_FREEZE_VALUE" );
		return PLUGIN_HANDLED;
	}
	
	FreezePlayer( iPlayer, iValue );
	
	new szAdminSteamId[ MAX_AUTHID_LENGTH ], szAdminName[ MAX_NAME_LENGTH ], szPlayerName[ MAX_NAME_LENGTH ];
	get_user_name( iPlayer, szPlayerName, charsmax( szPlayerName ) );
	get_user_name( id, szAdminName, charsmax( szAdminName ) );
	get_user_authid( id, szAdminSteamId, charsmax( szAdminSteamId ) );
	
	switch( iValue )
	{
	case 0:
		{
			log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_FREEZE_UNSET", szAdminName, szAdminSteamId, szPlayerName );
			CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "FREEZE_UNSET", szAdminName, szPlayerName );
		}
		
	case 1:
		{
			log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_FREEZE_SET", szAdminName, szAdminSteamId, szPlayerName );
			CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "FREEZE_SET", szAdminName, szPlayerName );
		}
	}
	
	return PLUGIN_HANDLED;
}

@Screenshot( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ SCREENSHOT_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}
	
	new szName[ MAX_NAME_LENGTH ];
	read_argv( 1, szName, charsmax( szName ) );
	
	if( read_argc( ) != 2 )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "AMX_SCREENSHOT_USAGE" );
		return PLUGIN_HANDLED;
	}
	
	new iPlayer = cmd_target( id, szName, CMDTARGET_ALLOW_SELF );
	
	if( ! iPlayer )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "PLAYER_NOT_FOUND" );
		return PLUGIN_HANDLED;
	}
	
	new iImmunityLevel = GetImmunityLevel( id );
	new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
	
	if( iImmunityLevel < iImmunityLevelTarget )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY" );
		return PLUGIN_HANDLED;
	}
	
	ScreenShot( iPlayer );
	
	new szAdminSteamId[ MAX_AUTHID_LENGTH ], szAdminName[ MAX_NAME_LENGTH ], szPlayerName[ MAX_NAME_LENGTH ];
	get_user_name( iPlayer, szPlayerName, charsmax( szPlayerName ) );
	get_user_name( id, szAdminName, charsmax( szAdminName ) );
	get_user_authid( id, szAdminSteamId, charsmax( szAdminSteamId ) );

	log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_SCREENSHOT", szAdminName, szAdminSteamId, szPlayerName );
	CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "SCREENSHOT", szAdminName, szPlayerName );
	
	return PLUGIN_HANDLED;
}

@Help( id )
{
	new szArg1[ 8 ], iFlags = get_user_flags( id );
	new iStart = read_argv( 1, szArg1, 7 ) ? str_to_num( szArg1 ) : 1;
	new iHelpAmount = 10;
	
	// HACK: ADMIN_ADMIN is never set as a user's actual flags, so those types of commands never show
	if( iFlags > 0 && !( iFlags & ADMIN_USER ) )
	{
		iFlags |= ADMIN_ADMIN;
	}
	
	if( id == 0 && read_argc( ) == 3 )
	iHelpAmount = read_argv( 2, szArg1, 7 ) ? str_to_num( szArg1 ) : 10;

	if( --iStart < 0 )
	iStart = 0;

	new iClcmdNum = get_concmdsnum( iFlags, id );

	if( iStart >= iClcmdNum )
	iStart = iClcmdNum - 1;

	console_print( id, "^n----- %L -----", id, "HELP_COMS" );
	
	new szInfo[ 128 ], szCmd[ 32 ], eFlags;
	new iEnd = iStart + iHelpAmount // HELPAMOUNT

	if( iEnd > iClcmdNum )
	iEnd = iClcmdNum;

	for( new i = iStart; i < iEnd; i++ )
	{
		get_concmd( i, szCmd, charsmax( szCmd ), eFlags, szInfo, charsmax( szInfo ), iFlags, id );
		console_print( id, "%3d: %s %s", i + 1, szCmd, szInfo );
	}
	
	console_print( id, "----- %L -----", id, "HELP_ENTRIES", iStart + 1, iEnd, iClcmdNum );

	if( iEnd < iClcmdNum )
	console_print( id, "----- %L -----", id, "HELP_USE_MORE", iEnd + 1 );
	
	else
	console_print( id, "----- %L -----", id, "HELP_USE_BEGIN" );

	return PLUGIN_HANDLED;
}

@Plugins( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ PLUGINS_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}
	
	if( id == 0 ) // If server executes redirect this to "amxx plugins" for more in depth output
	{
		server_cmd( "amxx plugins" );
		server_exec( );
		
		return PLUGIN_HANDLED;
	}

	new szName[ MAX_NAME_LENGTH ], szVersion[ 8 ], szAuthor[ MAX_NAME_LENGTH ], szFileName[ 64 ], szStatus[ 32 ];
	new iStartId, iEndId;

	new szTemp[ 128 ];

	new iNum = get_pluginsnum( );
	
	if( read_argc( ) > 1 )
	{
		read_argv( 1, szTemp, charsmax( szTemp ) );
		iStartId = str_to_num( szTemp ) - 1; // zero-based
	}

	iEndId = min( iStartId + 10, iNum );
	
	new iRunning;
	
	console_print( id, "%L", id, "CURRENTLY_LOADED" );
	
	new i = iStartId;
	
	while( i < iEndId )
	{
		get_plugin( i++, szFileName, charsmax( szFileName ), szName, charsmax( szName ), szVersion, charsmax( szVersion ), szAuthor, charsmax( szAuthor ), szStatus, charsmax( szStatus ) );
		console_print( id, "%-18.17s %-11.10s %-17.16s %-16.15s %-9.8s", szName, szVersion, szAuthor, szFileName, szStatus );
		
		if( szStatus[ 0 ] == 'd' || szStatus[ 0 ] == 'r') // "debug" or "running"
		{
			iRunning++;
		}
	}
	console_print( id, "%d %L, %d %L", iEndId-iStartId, id, "PLUGINS", iRunning, id, "RUNNING" );
	console_print( id, "----- Entries %d - %d of %d -----", iStartId + 1, iEndId, iNum );
	
	if( iEndId < iNum )
	{
		formatex( szTemp, charsmax( szTemp ),"----- %L -----", id, "HELP_USE_MORE", iEndId + 1);
		replace_all( szTemp, charsmax( szTemp ), "amx_help", "amx_plugins" );
		console_print( id, "%s", szTemp );
	}
	
	else
	{
		formatex( szTemp, charsmax( szTemp ),"----- %L -----", id, "HELP_USE_BEGIN" );
		replace_all( szTemp, charsmax( szTemp ), "amx_help", "amx_plugins" );
		console_print( id, "%s", szTemp );
	}

	return PLUGIN_HANDLED;
}

@Modules( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ MODULES_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}

	new szName[ MAX_NAME_LENGTH ], szVersion[ 8 ], szAuthor[ MAX_NAME_LENGTH ], iStatus, szStatus[ 16 ];
	
	new iNum = get_modulesnum( );
	
	console_print( id, "%L", id, "LOADED_MODULES" );
	
	for( new i; i < iNum; i++ )
	{
		get_module( i, szName, charsmax( szName ), szAuthor, charsmax( szAuthor ), szVersion, charsmax( szVersion ), iStatus )
		
		switch( iStatus )
		{
		case module_loaded:
			{
				new szRunning[ 15 ];
				formatex( szRunning, charsmax( szRunning ), "%L", id, "RUNNING" );
				copy( szStatus, charsmax( szStatus ), szRunning );
			}
			
		default:
			{
				new szTempString[ 64 ];
				
				formatex( szTempString, charsmax( szTempString ), "%L", id, "BAD_LOAD" );
				copy( szStatus, charsmax( szStatus ), szTempString );
				
				formatex( szTempString, charsmax( szTempString ), "%L", id, "UNKNOWN" );
				copy( szName, charsmax( szName ), szTempString );
				copy( szAuthor, charsmax( szAuthor ), szTempString );
				copy( szVersion, charsmax( szVersion ), szTempString );
			}
		}
		
		console_print( id, "%-23.22s %-11.10s %-20.19s %-11.10s", szName, szVersion, szAuthor, szStatus );
	}
	console_print( id, "%d %L", iNum, id, "MODULES" );
	return PLUGIN_HANDLED;
}

@Cvar( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ CVAR_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}
	
	new szCvar[ 32 ], szValue[ 64 ];
	
	read_argv( 1, szCvar, charsmax( szCvar ) );
	read_argv( 2, szValue, charsmax( szValue ) );
	
	new iPointer;
	
	if( equali( szCvar, "add" ) && ( get_user_flags( id ) & ADMIN_RCON ) )
	{
		if( ( iPointer = get_cvar_pointer( szValue ) ) != 0 )
		{
			new iFlags = get_pcvar_flags( iPointer );
			
			if( ! ( iFlags & FCVAR_PROTECTED ) )
			{
				set_pcvar_flags( iPointer, iFlags | FCVAR_PROTECTED );
			}
		}
		return PLUGIN_HANDLED;
	}
	
	if( ( iPointer = get_cvar_pointer( szCvar ) ) == 0 )
	{
		console_print( id, "%L", id, "UNKNOWN_CVAR", szCvar );
		return PLUGIN_HANDLED;
	}
	
	if( bOnlyRcon( szCvar ) && ! ( get_user_flags( id ) & ADMIN_RCON ) )
	{
		// Exception for the new onlyRcon rules:
		// sv_password is allowed to be modified by ADMIN_PASSWORD
		if( ! ( equali( szCvar, "sv_password" ) && ( get_user_flags( id ) & ADMIN_PASSWORD ) ) )
		{
			console_print( id, "%L", id, "NO_ACCESS_CVAR" );
			return PLUGIN_HANDLED;
		}
	}
	
	if( read_argc( ) < 3 )
	{
		get_pcvar_string( iPointer, szValue, charsmax( szValue ) );
		console_print( id, "CVAR ^"%s^" %L ^"%s^"", szCvar, id, "IS", szValue );
		
		return PLUGIN_HANDLED;
	}

	new szSteamId[ MAX_AUTHID_LENGTH ], szName[ MAX_NAME_LENGTH ];
	
	get_user_authid( id, szSteamId, charsmax( szSteamId ) );
	get_user_name( id, szName, charsmax( szName ) );
	
	log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_CVAR_SET", szName, szSteamId, szCvar, szValue );
	set_cvar_string( szCvar, szValue );

	new iPlayers[ MAX_PLAYERS ], iNum, iTempId, szCvarValue[ 64 ];
	get_players( iPlayers, iNum, "ch" );
	
	for( new i; i < iNum; i++ )
	{
		iTempId = iPlayers[ i ];
		
		if( get_pcvar_flags( iPointer ) & FCVAR_PROTECTED || equali( szCvar, "rcon_password" ) )
		{
			formatex( szCvarValue, charsmax( szCvarValue ), "*** %L ***", id, "PROTECTED" );
		}
		else
		{
			copy( szCvarValue, charsmax( szCvarValue ), szValue );
		}
		CC_SendMessage( iTempId, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CVAR_SET", szName, szCvar, szCvarValue );
	}
	console_print( id, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CVAR_SET_SUCCESS", szCvar, szValue );
	return PLUGIN_HANDLED;
}

@Rcon( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ RCON_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}
	
	new szCmd[ 128 ], szSteamId[ MAX_AUTHID_LENGTH ], szName[ MAX_NAME_LENGTH ];
	
	read_args( szCmd, charsmax( szCmd ) );
	
	get_user_authid( id, szSteamId, charsmax( szSteamId ) );
	get_user_name( id, szName, charsmax( szName ) );
	
	log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "RCON_SENT", szName, szSteamId, szCmd );
	
	console_print( id, "%L", id, "CMD_SENT_SERVER", szCmd );
	server_cmd( "%s", szCmd );
	
	return PLUGIN_HANDLED;
}

@ShowRcon( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ SHOW_RCON_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}
	
	new szRconPw[ 64 ];
	get_pcvar_string( g_pRconPassword, szRconPw, charsmax( szRconPw ) );
	
	if( ! szRconPw[ 0 ] )
	{
		@Rcon( id );
	}
	
	else
	{
		new szArgs[ 128 ];
		
		read_args( szArgs, charsmax( szArgs ) );
		client_cmd( id, "rcon_password %s", szRconPw );
		client_cmd( id, "rcon %s", szArgs );
	}
	
	return PLUGIN_HANDLED
}

@Kick( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ KICK_FLAG ] )
	{	
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}

	new szName[ MAX_NAME_LENGTH ], szReason[ MAX_REASON_LENGTH ];
	read_argv( 1, szName, charsmax( szName ) );
	read_argv( 2, szReason, charsmax( szReason ) );
	
	trim( szReason );
	remove_quotes( szReason );
	
	if( read_argc( ) != 3 )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "AMX_KICK_USAGE" );
		return PLUGIN_HANDLED;
	}
	
	new iPlayer = cmd_target( id, szName, CMDTARGET_ALLOW_SELF );
	
	if( ! iPlayer )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "PLAYER_NOT_FOUND" );
		return PLUGIN_HANDLED;
	}
	
	new iImmunityLevel = GetImmunityLevel( id );
	new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
	
	if( iImmunityLevel < iImmunityLevelTarget )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY" );
		return PLUGIN_HANDLED;
	}
	
	new szNameAdmin[ MAX_NAME_LENGTH ], szNameUser[ MAX_NAME_LENGTH ], iUserIdUser;
	
	get_user_name( id, szNameAdmin, charsmax( szNameAdmin ) );
	get_user_name( iPlayer, szNameUser, charsmax( szNameUser ) );
	
	iUserIdUser = get_user_userid( iPlayer );
	
	server_cmd( "kick #%d  ^"%s^"", iUserIdUser, szReason );
	
	CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "KICKED", szNameAdmin, szNameUser, szReason );
	log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_KICKED", szNameAdmin, szNameUser, szReason );
	
	return PLUGIN_HANDLED;
}

@AddBan( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ ADD_BAN_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}
	
	new szName[ MAX_NAME_LENGTH ], szSteamId[ MAX_AUTHID_LENGTH ], szIP[ MAX_IP_LENGTH ], szMinutes[ 8 ], szReason[ MAX_REASON_LENGTH ], szNameAdmin[ MAX_NAME_LENGTH ];
	read_argv( 1, szName, charsmax( szName ) );
	read_argv( 2, szSteamId, charsmax( szSteamId ) );
	read_argv( 3, szIP, charsmax( szIP ) );
	read_argv( 4, szMinutes, charsmax( szMinutes ) );
	read_argv( 5, szReason, charsmax( szReason ) );
	
	if( read_argc( ) != 6 )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "AMX_ADDBAN_USAGE" );
		return PLUGIN_HANDLED;
	}

	new iPlayer = cmd_target( id, szName, CMDTARGET_NO_BOTS );
	
	if( is_user_connected( iPlayer ) )
	{
		new iImmunityLevel = GetImmunityLevel( id );
		new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
		
		if( iImmunityLevel < iImmunityLevelTarget )
		{
			client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY" );
			return PLUGIN_HANDLED;
		}
	}
	
	new szExpireDate[ MAX_DATE_LENGTH ], iMinutes = str_to_num( szMinutes );
	
	get_user_name( id, szNameAdmin, charsmax( szNameAdmin ) );
	get_user_name( id, szName, charsmax( szName ) );
	
	if( iMinutes == 0 )
	{
		CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "ADDED_TO_BANLIST_PERMANENT", szNameAdmin, szName, szSteamId, szIP );
		log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_ADDED_TO_BANLIST_PERMANENT", szNameAdmin, szName, szSteamId, szIP, szReason );
		
		copy( szExpireDate, charsmax( szExpireDate ), "never" );
	}
	
	else
	{
		get_time( "%m/%d/%Y - %H:%M:%S", szExpireDate, charsmax( szExpireDate ) );
		
		AddMinutesToDate( szExpireDate, iMinutes, szExpireDate, charsmax( szExpireDate ) );
		
		CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "ADDED_TO_BANLIST", szNameAdmin, szName, szSteamId, szIP, iMinutes );
		log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_ADDED_TO_BANLIST", szNameAdmin, szName, szSteamId, szIP, iMinutes, szExpireDate, szReason );
	}
	
	trim( szName );
	trim( szSteamId );
	trim( szIP );
	trim( szExpireDate );
	trim( szReason );
	trim( szNameAdmin );
	
	new eData[ PlayerBan ];	
	copy( eData[ Player_Name ], charsmax( eData[ Player_Name ] ), szName );
	copy( eData[ Player_SteamId ], charsmax( eData[ Player_SteamId ] ), szSteamId );
	copy( eData[ Player_IP ], charsmax( eData[ Player_IP ] ), szIP );
	copy( eData[ Player_BanExpire ], charsmax( eData[ Player_BanExpire ] ), szExpireDate );
	copy( eData[ Player_BanReason ], charsmax( eData[ Player_BanReason ] ), szReason );
	copy( eData[ Player_BannedBy ], charsmax( eData[ Player_BannedBy ] ), szNameAdmin );
	
	ArrayPushArray( g_aBans, eData );
	AddBan( szName, szSteamId, szIP, szExpireDate, szReason, szNameAdmin );
	
	if( is_user_connected( iPlayer ) )
	{
		KickPlayerOut( iPlayer );
	}
	
	return PLUGIN_HANDLED;
}

@AddGag( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ ADD_GAG_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}
	
	new szName[ MAX_NAME_LENGTH ], szSteamId[ MAX_AUTHID_LENGTH ], szIP[ MAX_IP_LENGTH ], szSeconds[ 8 ], szFlags[ 5 ], szReason[ MAX_REASON_LENGTH ], szNameAdmin[ MAX_NAME_LENGTH ];
	read_argv( 1, szName, charsmax( szName ) );
	read_argv( 2, szSteamId, charsmax( szSteamId ) );
	read_argv( 3, szIP, charsmax( szIP ) );
	read_argv( 4, szSeconds, charsmax( szSeconds ) );
	read_argv( 5, szFlags, charsmax( szFlags ) );
	read_argv( 6, szReason, charsmax( szReason ) );
	
	if( read_argc( ) != 7 )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "AMX_ADDGAG_USAGE" );
		return PLUGIN_HANDLED;
	}

	if( ! equali( szFlags, "sv" ) && ! equali( szFlags, "vs" ) && ! equali( szFlags, "s" ) && ! equali( szFlags, "v" ) )
	{
		client_print( id, print_console, "%L", id, "INVALID_FLAGS" );
		return PLUGIN_HANDLED;
	}
	
	new iPlayer = cmd_target( id, szName, CMDTARGET_NO_BOTS );
	
	if( is_user_connected( iPlayer ) )
	{
		new iImmunityLevel = GetImmunityLevel( id );
		new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
		
		if( iImmunityLevel < iImmunityLevelTarget )
		{
			client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY" );
			return PLUGIN_HANDLED;
		}
	}
	
	new szExpireDate[ MAX_DATE_LENGTH ], iSeconds = str_to_num( szSeconds );
	get_user_name( id, szNameAdmin, charsmax( szNameAdmin ) );
	get_user_name( id, szName, charsmax( szName ) );
	
	if( iSeconds == 0 )
	{
		CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "ADDED_TO_GAGLIST_PERMANENT", szNameAdmin, szName, szSteamId, szIP );
		log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_ADDED_TO_GAGLIST_PERMANENT", szNameAdmin, szName, szSteamId, szIP, szFlags, szReason );
		
		copy( szExpireDate, charsmax( szExpireDate ), "never" );
	}
	
	else
	{
		get_time( "%m/%d/%Y - %H:%M:%S", szExpireDate, charsmax( szExpireDate ) );
		
		AddSecondsToDate( szExpireDate, iSeconds, szExpireDate, charsmax( szExpireDate ) );
		
		CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "ADDED_TO_GAGLIST", szNameAdmin, szName, szSteamId, szIP, iSeconds );
		log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_ADDED_TO_GAGLIST", szNameAdmin, szName, szSteamId, szIP, iSeconds, szExpireDate, szFlags, szReason );
	}
	
	trim( szName );
	trim( szSteamId );
	trim( szIP );
	trim( szReason );
	trim( szFlags );
	trim( szExpireDate );
	
	new eData[ PlayerGag ];	
	copy( eData[ Player_Name ], charsmax( eData[ Player_Name ] ), szName );
	copy( eData[ Player_SteamId ], charsmax( eData[ Player_SteamId ] ), szSteamId );
	copy( eData[ Player_IP ], charsmax( eData[ Player_IP ] ), szIP );
	copy( eData[ Player_GagReason ], charsmax( eData[ Player_GagReason ] ), szReason );
	copy( eData[ Player_GagFlags ], charsmax( eData[ Player_GagFlags ] ), szFlags );
	copy( eData[ Player_GagExpire ], charsmax( eData[ Player_GagExpire ] ), szExpireDate );
	
	ArrayPushArray( g_aGags, eData );
	AddGag( szName, szSteamId, szIP, szReason, szFlags, szExpireDate );
	
	if( is_user_connected( iPlayer ) )
	{
		CheckGagged( iPlayer );
	}
	
	return PLUGIN_HANDLED;
}

@Psay( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ PSAY_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}
	
	new szName[ MAX_NAME_LENGTH ], szMessage[ 192 ];
	read_argv( 1, szName, charsmax( szName ) );
	read_argv( 2, szMessage, charsmax( szMessage ) );
	
	if( read_argc( ) != 3 )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "AMX_PSAY_USAGE" );
		return PLUGIN_HANDLED;
	}
	
	new iPlayer = cmd_target( id, szName, CMDTARGET_NO_BOTS );
	
	if( ! iPlayer )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "PLAYER_NOT_FOUND" );
		return PLUGIN_HANDLED;
	}
	
	get_user_name( iPlayer, szName, charsmax( szName ) );
	
	new szAdminName[ 32 ];
	get_user_name( id, szAdminName, charsmax( szAdminName ) );
	
	CC_SendMessage( id, "%L", id, "PSAY_HIM", szName, szMessage );
	CC_SendMessage( iPlayer, "%L", iPlayer, "PSAY_YOU", szAdminName, szMessage );
	
	return PLUGIN_HANDLED;
}

@Who( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ WHO_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}
	
	new iFlags, szFlags[ MAX_FLAGS_LENGTH ], iPlayers[ MAX_PLAYERS ], iNum, iTempId, szName[ MAX_NAME_LENGTH ], szSteamId[ MAX_AUTHID_LENGTH ], szIp[ MAX_IP_LENGTH ];
	get_players( iPlayers, iNum );
	
	client_print( id, print_console, "^nName       SteamID       IP       Flags       Rank" );   
	
	for( new i; i < iNum; i++ )
	{
		iTempId = iPlayers[ i ];
		
		get_user_name( iTempId, szName, charsmax( szName ) );
		get_user_authid( iTempId, szSteamId, charsmax( szSteamId ) );
		get_user_ip( iTempId, szIp, charsmax( szIp ), 1 );
		
		iFlags = get_user_flags( iTempId );
		get_flags( iFlags, szFlags, charsmax( szFlags ) );
		
		if( g_iConfig[ RANKS_ENABLED ] )
		{
			new szRank[ 32 ];
			eas_get_player_rank( iTempId, szRank, charsmax( szRank ) );
			
			client_print( id, print_console, "%s   %s   %s   %s   %s", szName, szSteamId, szIp, szFlags, szRank );
		}
		
		else
		{
			client_print( id, print_console, "%s     %s     %s     %s", szName, szSteamId, szIp, szFlags );
		}
	}
	return PLUGIN_HANDLED;
}

@Last( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ LAST_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}
	
	client_print( id, print_console, "%L      %L      %L      %L      %L", id, "NAME", id, "STEAM_ID", id, "IP", id, "FLAGS", id, "RANK" );
	
	new eData[ PlayerDisconnectData ], eData2[ PlayerDisconnectData ], szMessage[ 256 ];
	for( new i; i < ArraySize( g_aDisconnectInfo ); i++ )
	{
		ArrayGetArray( g_aDisconnectInfo, i, eData );
		
		// check if already exists, if so, delete old records
		for( new j; j < ArraySize( g_aDisconnectInfo ); i++ )
		{
			ArrayGetArray( g_aDisconnectInfo, j, eData2 );
			
			if( equali( eData[ Player_Name ], eData2[ Player_Name ] ) || equali( eData[ Player_SteamId ], eData2[ Player_SteamId ] ) || equali( eData[ Player_IP ], eData2[ Player_IP ] ) && ( i != j ) )
			{
				ArrayDeleteItem( g_aDisconnectInfo, i );
			}
		}
		
		formatex( szMessage, charsmax( szMessage ), "%s        %s        %s        %s        %s", eData[ Player_DisconnectName ], eData[ Player_DisconnectSteamID ], eData[ Player_DisconnectIP ], eData[ Player_DisconnectFlags ], eData[ Player_DisconnectRank ] );
		client_print( id, print_console, szMessage );
	}
	return PLUGIN_HANDLED;
}

@Team( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ TEAM_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}
	
	new szName[ MAX_NAME_LENGTH ], szTeam[ 12 ], szRespawn[ 2 ];
	read_argv( 1, szName, charsmax( szName ) );
	read_argv( 2, szTeam, charsmax( szTeam ) );
	read_argv( 3, szRespawn, charsmax( szRespawn ) );
	
	if( read_argc( ) != 4 )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "AMX_TEAM_USAGE" );
		return PLUGIN_HANDLED;
	}
	
	new iPlayer = cmd_target( id, szName, CMDTARGET_ALLOW_SELF );
	
	if( ! iPlayer )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "PLAYER_NOT_FOUND" );
		return PLUGIN_HANDLED;
	}
	
	new iImmunityLevel = GetImmunityLevel( id );
	new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
	
	if( iImmunityLevel < iImmunityLevelTarget )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY" );
		return PLUGIN_HANDLED;
	}
	
	new iTeam, szTeamFinal[ 20 ];
	if( is_str_num( szTeam ) )
	{
		iTeam = str_to_num( szTeam );
		switch( iTeam )
		{
		case 1:
			{
				eas_set_user_team( iPlayer, 1 );
				copy( szTeamFinal, charsmax( szTeamFinal ), "Terrorist" );
			}
			
		case 2:
			{
				eas_set_user_team( iPlayer, 2 );
				copy( szTeamFinal, charsmax( szTeamFinal ), "Counter-Terrorist" );
			}
			
		case 3:
			{
				eas_set_user_team( iPlayer, 3 );
				copy( szTeamFinal, charsmax( szTeamFinal ), "Spectator" );
			}
			
		default:
			{
				client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "INVALID_TEAM" );
				return PLUGIN_HANDLED;
			}
		}
	}
	
	else
	{
		if( equali( szTeam, "T" ) || equali( szTeam, "TERRORIST" ) )
		{
			iTeam = 1;
			eas_set_user_team( iPlayer, iTeam );
			
			copy( szTeamFinal, charsmax( szTeamFinal ), "Terrorist" );
		}
		
		else if( equali( szTeam, "CT" ) )
		{
			iTeam = 2;
			eas_set_user_team( iPlayer, iTeam );
			
			copy( szTeamFinal, charsmax( szTeamFinal ), "Counter-Terrorist" );
		}
		
		else if( equali( szTeam, "SPEC" ) || equali( szTeam, "SPECTATOR" ) )
		{
			iTeam = 3;
			eas_set_user_team( iPlayer, iTeam );
			
			copy( szTeamFinal, charsmax( szTeamFinal ), "Spectator" );
		}
		
		else
		{
			client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "INVALID_TEAM" );
			return PLUGIN_HANDLED;
		}
	}
	
	new iRespawn = str_to_num( szRespawn );
	
	//if( iRespawn != 0 && iRespawn != 1 )
	//{
	//	iRespawn = 0;
	//}
	
	!( 0 <= iRespawn <= 1 ) ? ( iRespawn = 0 ) : iRespawn;
	
	if( iRespawn == 1 )
	{
		ExecuteHamB( Ham_CS_RoundRespawn, iPlayer );
	}

	new szSteamIdAdmin[ MAX_AUTHID_LENGTH ], szNameAdmin[ MAX_NAME_LENGTH ], szNamePlayer[ MAX_NAME_LENGTH ];

	get_user_authid( id, szSteamIdAdmin, charsmax( szSteamIdAdmin ) );
	get_user_name( id, szNameAdmin, charsmax( szNameAdmin ) );
	get_user_name( iPlayer, szNamePlayer, charsmax( szNamePlayer ) );
	
	CC_SendMatched( 0, iPlayer, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "TEAM_CHANGE", szNameAdmin, szNamePlayer, szTeamFinal );
	log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "TEAM_CHANGE_LOG", szNameAdmin, szSteamIdAdmin, szNamePlayer, szTeamFinal );
	
	return PLUGIN_HANDLED;
}	

@Ban( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ BAN_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}

	new szName[ MAX_NAME_LENGTH ], szReason[ MAX_REASON_LENGTH ], szMinutes[ 8 ];
	read_argv( 1, szName, charsmax( szName ) );
	read_argv( 2, szMinutes, charsmax( szMinutes ) );
	read_argv( 3, szReason, charsmax( szReason ) );
	
	if( read_argc( ) != 4 )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "AMX_BAN_USAGE" );
		return PLUGIN_HANDLED;
	}
	
	new iPlayer = cmd_target( id, szName, CMDTARGET_NO_BOTS );
	
	if( ! iPlayer )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "PLAYER_NOT_FOUND" );
		return PLUGIN_HANDLED;
	}
	
	new iImmunityLevel = GetImmunityLevel( id );
	new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
	
	if( iImmunityLevel < iImmunityLevelTarget )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY" );
		return PLUGIN_HANDLED;
	}
	
	new szSteamIdUser[ MAX_AUTHID_LENGTH ], szIpUser[ MAX_IP_LENGTH ], szNameAdmin[ MAX_NAME_LENGTH ], szNameUser[ MAX_NAME_LENGTH ];
	
	get_user_ip( iPlayer, szIpUser, charsmax( szIpUser ), 1 );
	get_user_authid( iPlayer, szSteamIdUser, charsmax( szSteamIdUser ) );
	get_user_name( id, szNameAdmin, charsmax( szNameAdmin ) );
	get_user_name( iPlayer, szNameUser, charsmax( szNameUser ) );
	
	new szExpireDate[ MAX_DATE_LENGTH ], iMinutes = str_to_num( szMinutes );
	
	if( iMinutes == 0 )
	{
		CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "BANNED_PERMANENT", szNameAdmin, szNameUser, szReason );
		log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_BANNED_PERMANENT", szNameAdmin, szNameUser, szSteamIdUser, szIpUser, szReason );
		
		copy( szExpireDate, charsmax( szExpireDate ), "never" );
	}
	
	else
	{
		get_time( "%m/%d/%Y - %H:%M:%S", szExpireDate, charsmax( szExpireDate ) );
		
		AddMinutesToDate( szExpireDate, iMinutes, szExpireDate, charsmax( szExpireDate ) );
		
		if( iMinutes == 1 )
		{
			CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "BANNED_SINGULAR", szNameAdmin, szNameUser, szReason, szExpireDate );
			log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_BANNED_SINGULAR", szNameAdmin, szNameUser, szSteamIdUser, szIpUser, szReason, szExpireDate );
		}
		
		else
		{
			CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "BANNED_PLURAL", szNameAdmin, szNameUser, iMinutes, szReason, szExpireDate );
			log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_BANNED_PLURAL", szNameAdmin, szNameUser, szSteamIdUser, szIpUser, iMinutes, szReason, szExpireDate );
		}
	}
	
	trim( szNameUser );
	trim( szSteamIdUser );
	trim( szIpUser );
	trim( szExpireDate );
	trim( szReason );
	trim( szNameAdmin );
	
	new eData[ PlayerBan ];	
	copy( eData[ Player_Name ], charsmax( eData[ Player_Name ] ), szNameUser );
	copy( eData[ Player_SteamId ], charsmax( eData[ Player_SteamId ] ), szSteamIdUser );
	copy( eData[ Player_IP ], charsmax( eData[ Player_IP ] ), szIpUser );
	copy( eData[ Player_BanExpire ], charsmax( eData[ Player_BanExpire ] ), szExpireDate );
	copy( eData[ Player_BanReason ], charsmax( eData[ Player_BanReason ] ), szReason );
	copy( eData[ Player_BannedBy ], charsmax( eData[ Player_BannedBy ] ), szNameAdmin );
	
	ArrayPushArray( g_aBans, eData );
	BanPlayer( szNameUser, szSteamIdUser, szIpUser, szExpireDate, szReason, szNameAdmin );
	
	if( is_user_connected( iPlayer ) )
	{
		KickPlayerOut( iPlayer )
	}
	
	return PLUGIN_HANDLED;
}

@Unban( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ UNBAN_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}
	
	new szIdentity[ MAX_AUTHID_LENGTH ];
	read_argv( 1, szIdentity, charsmax( szIdentity ) );
	
	if( read_argc( ) != 2 )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "AMX_UNBAN_USAGE" );
		return PLUGIN_HANDLED;
	}
	
	ReadBans( );
	
	new eData[ PlayerBan ], bool:bPlayerFound;
	for( new i; i < ArraySize( g_aBans ); i++ )
	{
		ArrayGetArray( g_aBans, i, eData );
		
		if( equali( szIdentity, eData[ Player_Name ] ) || equali( szIdentity, eData[ Player_SteamId ] ) || equali( szIdentity, eData[ Player_IP ] ) )
		{
			UnbanPlayer( szIdentity );
			
			new szNameAdmin[ MAX_NAME_LENGTH ];
			get_user_name( id, szNameAdmin, charsmax( szNameAdmin ) );
			
			CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "UNBANNED", szNameAdmin, eData[ Player_Name ], eData[ Player_SteamId ], eData[ Player_IP ] );

			log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_UNBANNED", szNameAdmin, eData[ Player_Name ], eData[ Player_SteamId ], eData[ Player_IP ] );
			bPlayerFound = true;
			
			break;
		}
	}
	if( ! bPlayerFound )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "PLAYER_NOT_FOUND" );
	}
	return PLUGIN_HANDLED;
}

@Slay( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ SLAY_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}

	new szName[ MAX_NAME_LENGTH ], szReason[ MAX_REASON_LENGTH ];
	read_argv( 1, szName, charsmax( szName ) );
	read_argv( 2, szReason, charsmax( szReason ) );
	
	trim( szReason );
	remove_quotes( szReason );
	
	if( read_argc( ) != 3 )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "AMX_SLAY_USAGE" );
		return PLUGIN_HANDLED;
	}
	
	new iPlayer = cmd_target( id, szName, CMDTARGET_ALLOW_SELF );
	
	if( ! is_user_connected( iPlayer ) )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "PLAYER_NOT_FOUND" );
		return PLUGIN_HANDLED;
	}
	
	if( ! is_user_alive( iPlayer ) )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "SLAY_DEAD_PLAYER" );
		return PLUGIN_HANDLED;
	}
	
	new iImmunityLevel = GetImmunityLevel( id );
	new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
	
	if( iImmunityLevel < iImmunityLevelTarget )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY" );
		return PLUGIN_HANDLED;
	}
	
	new szNameAdmin[ MAX_NAME_LENGTH ], szNameUser[ MAX_NAME_LENGTH ];
	
	get_user_name( id, szNameAdmin, charsmax( szNameAdmin ) );
	get_user_name( iPlayer, szNameUser, charsmax( szNameUser ) );
	
	user_kill( iPlayer );
	
	CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "SLAY", szNameAdmin, szNameUser, szReason );
	log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_SLAY", szNameAdmin, szNameUser, szReason );
	
	return PLUGIN_HANDLED;
}

@Slap( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ SLAP_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}

	new szName[ MAX_NAME_LENGTH ], szReason[ MAX_REASON_LENGTH ], szValue[ 3 ], iValue;
	read_argv( 1, szName, charsmax( szName ) );
	read_argv( 2, szValue, charsmax( szValue ) );
	read_argv( 3, szReason, charsmax( szReason ) );
	
	trim( szReason );
	remove_quotes( szReason );
	
	if( read_argc( ) != 4 )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "AMX_SLAP_USAGE" );
		return PLUGIN_HANDLED;
	}
	
	new iPlayer = cmd_target( id, szName, CMDTARGET_ALLOW_SELF );
	
	if( ! is_user_connected( iPlayer ) )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "PLAYER_NOT_FOUND" );
		return PLUGIN_HANDLED;
	}
	
	if( ! is_user_alive( iPlayer ) )
	{
		client_print( id, print_chat, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "SLAP_DEAD_PLAYER" );
		return PLUGIN_HANDLED;
	}
	
	new iImmunityLevel = GetImmunityLevel( id );
	new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
	
	if( iImmunityLevel < iImmunityLevelTarget )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY" );
		return PLUGIN_HANDLED;
	}
	
	new szNameAdmin[ MAX_NAME_LENGTH ], szNameUser[ MAX_NAME_LENGTH ];
	
	get_user_name( id, szNameAdmin, charsmax( szNameAdmin ) );
	get_user_name( iPlayer, szNameUser, charsmax( szNameUser ) );
	
	iValue = str_to_num( szValue );
	
	user_slap( iPlayer, iValue );
	
	CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ],  LANG_PLAYER, "SLAP", szNameAdmin, szNameUser, iValue, szReason );
	log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_SLAP", szNameAdmin, szNameUser, iValue, szReason );
	
	return PLUGIN_HANDLED;
}

@Map( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ MAP_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}

	new szMap[ MAX_MAP_NAME_LENGTH ];
	new iMapLen = read_argv( 1, szMap, charsmax( szMap ) );
	
	if( read_argc( ) != 2 )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "AMX_MAP_USAGE" );
		return PLUGIN_HANDLED;
	}
	
	if( ! is_map_valid( szMap ) )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "MAP_NOT_FOUND" );
		return PLUGIN_HANDLED;
	}

	new szName[ MAX_NAME_LENGTH ];
	get_user_name( id, szName, charsmax( szName ) );

	new szModName[ 10 ];
	get_modname( szModName, charsmax( szModName ) );
	
	if( ! equali( szModName, "zp" ) )
	{
		message_begin( MSG_ALL, SVC_INTERMISSION );
		message_end( );
	}
	
	CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "MAP_CHANGE", szName, szMap );
	log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_MAP_CHANGE", szName, szMap );
	
	set_task( 2.0, "OnMapChange", _, szMap, iMapLen + 1 );
	
	return PLUGIN_HANDLED
}

@Nick( id )
{
	if( ~ get_user_flags( id ) & g_iConfig[ NICK_FLAG ] )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "NO_ACCESS_COMMAND" );
		return PLUGIN_HANDLED;
	}

	new szCurrentName[ MAX_NAME_LENGTH ], szNewName[ MAX_NAME_LENGTH ], szAdminName[ MAX_NAME_LENGTH ];

	read_argv( 1, szCurrentName, charsmax( szCurrentName ) );
	read_argv( 2, szNewName, charsmax( szNewName ) );
	
	if( read_argc( ) != 3 )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "AMX_NICK_USAGE" );
		return PLUGIN_HANDLED;
	}
	
	get_user_name( id, szAdminName, charsmax( szAdminName ) );
	
	new iPlayer = cmd_target( id, szCurrentName, CMDTARGET_ALLOW_SELF );
	
	if( ! iPlayer )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "PLAYER_NOT_FOUND" );
		return PLUGIN_HANDLED;
	}
	
	get_user_name( iPlayer, szCurrentName, charsmax( szCurrentName ) );
	
	new iImmunityLevel = GetImmunityLevel( id );
	new iImmunityLevelTarget = GetImmunityLevel( iPlayer );
	
	if( iImmunityLevel < iImmunityLevelTarget )
	{
		client_print( id, print_console, "%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "CANT_PERFORM_IMMUNITY" );
		return PLUGIN_HANDLED;
	}

	client_cmd( iPlayer, "name ^"%s^"", szNewName );

	CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], LANG_PLAYER, "NICK_CHANGE", szAdminName, szCurrentName, szNewName );
	
	log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "LOG_NICK_CHANGE", szAdminName, szCurrentName, szNewName );
	
	return PLUGIN_HANDLED;
}

///////////////////////////////////////////////////////////////////////////////// END OF CONSOLE COMMANDS /////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////// STOCKS AND PRIVATE FUNCTIONS ///////////////////////////////////////////////////////////////////////////////////////////////

CleanVars( id )
{
	g_bFrozen[ id ] = false;
	g_iKick[ id ] = 0;
	g_iTeamSwitch[ id ] = 0;
	
	arrayset( g_iBan[ id ], 0, sizeof( g_iBan[ ] ) );
	arrayset( g_iGag[ id ], 0, sizeof( g_iGag[ ] ) );
	arrayset( g_iAddBan[ id ], 0, sizeof( g_iAddBan[ ] ) );
	arrayset( g_iAddGag[ id ], 0, sizeof( g_iAddGag[ ] ) );
	arrayset( g_iSlay[ id ], 0, sizeof( g_iSlay[ ] ) );
	arrayset( g_iSlap[ id ], 0, sizeof( g_iSlap[ ] ) );
	arrayset( _:fAngles[ id ], _:0.0, sizeof( fAngles[ ] ) );
	arrayset( g_szTeamSwitch[ id ], 0, sizeof( g_szTeamSwitch[ ] ) );
}

GetImmunityLevel( id )
{
	new eData[ PlayerData ], szName[ MAX_NAME_LENGTH ], szSteamID[ MAX_AUTHID_LENGTH ], iImmunityLevel, szPlayerID[ MAX_AUTHID_LENGTH ];
	get_user_name( id, szName, charsmax( szName ) );
	get_user_authid( id, szSteamID, charsmax( szSteamID ) );

	copy( szPlayerID, charsmax( szPlayerID ), eData[ Player_ID ] );
	
	for( new i; i < ArraySize( g_aDataBase ); i++ )
	{
		ArrayGetArray( g_aDataBase, i, eData );
		
		if( equali( szName, szPlayerID ) || equali( szSteamID, szPlayerID ) )
		{
			iImmunityLevel = str_to_num( eData[ Player_Immunity ] );
			break;
		}
	}
	return iImmunityLevel;
}	

AddBan( const szName[ ], const szSteamId[ ], const szIP[ ], const szExpireDate[ ], const szReason[ ], const szAdminName[ ] )
{
	new szFormat[ 192 ];
	
	formatex( szFormat, charsmax( szFormat ), "%s/%s", g_szConfigsDir, g_iConfig[ BANS_FILE ] );
	new iFilePointer = fopen( szFormat, "r+" );
	
	if( iFilePointer )
	{			
		new szByteVal[ 1 ];
		
		fseek( iFilePointer , -1 , SEEK_END );
		fread_raw( iFilePointer , szByteVal , sizeof( szByteVal ) , BLOCK_BYTE );
		fseek( iFilePointer , 0 , SEEK_END );
		
		fprintf( iFilePointer, "%s^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^"", ( szByteVal[ 0 ] == 10 ) ? "" : "^n", szName, szSteamId, szIP, szExpireDate, szReason, szAdminName ); // add him to banlist
		fclose( iFilePointer );
	}
	return 1;
}

AddGag( const szName[ ], const szSteamId[ ], const szIP[ ], const szReason[ ], const szFlags[ ], const szExpireDate[ ] )
{
	new szFormat[ 192 ];
	
	formatex( szFormat, charsmax( szFormat ), "%s/%s", g_szConfigsDir, g_iConfig[ GAGS_FILE ] );
	new iFilePointer = fopen( szFormat, "r+" );
	
	if( iFilePointer )
	{			
		new szByteVal[ 1 ];
		
		fseek( iFilePointer , -1 , SEEK_END );
		fread_raw( iFilePointer , szByteVal , sizeof( szByteVal ) , BLOCK_BYTE );
		fseek( iFilePointer , 0 , SEEK_END );
		
		fprintf( iFilePointer, "%s^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^"", ( szByteVal[ 0 ] == 10 ) ? "" : "^n", szName, szSteamId, szIP, szReason, szFlags, szExpireDate ); // add him to gaglist
		fclose( iFilePointer );
	}
	return 1;
}

UnbanPlayer( const szIdentity[ ] )
{
	new const szTempFileName[ ] = "tempfile.ini";

	new szFormat[ 128 ], szData[ 128 ], szName[ MAX_NAME_LENGTH ], szSteamId[ MAX_AUTHID_LENGTH ], szIP[ MAX_IP_LENGTH ];
	
	static szTempFilePath[ 256 ];
	formatex( szTempFilePath, charsmax( szTempFilePath ), "%s/%s", g_szConfigsDir, szTempFileName );
	
	formatex( szFormat, charsmax( szFormat ), "%s/%s", g_szConfigsDir, g_iConfig[ BANS_FILE ] );
	new iFilePointer = fopen( szFormat, "rt" );

	if( iFilePointer )
	{
		new iInputFilePointer = fopen( szTempFilePath, "wt" );
		
		if( iInputFilePointer )
		{
			while( fgets( iFilePointer, szData, charsmax( szData ) ) )
			{
				switch( szData[ 0 ] )
				{
				case EOS, '#', ';', '/':
					{
						fprintf( iInputFilePointer, szData ); // write as it was before
					}

				default:
					{			
						parse( szData, szName, charsmax( szName ), szSteamId, charsmax( szSteamId ), szIP, charsmax( szIP ) );
						
						trim( szName );
						trim( szSteamId );
						trim( szIP );
						
						if( ! equali( szIdentity, szName ) && ! equali( szIdentity, szSteamId ) && ! equali( szIdentity, szIP ) ) // not the person we're looking for
						{
							fprintf( iInputFilePointer, szData ); // write as it was before
						}
						
						else
						{
							continue;
						}
					}
				}
			}
			fclose( iInputFilePointer );
			fclose( iFilePointer );

			delete_file( szFormat );
			rename_file( szTempFilePath, szFormat, 1 );
		}
	}
	return 0;
}

UnGagPlayer( const szIdentity[ ] )
{
	new const szTempFileName[ ] = "tempfile.ini";

	new szFormat[ 128 ], szData[ 192 ], szName[ MAX_NAME_LENGTH ], szSteamId[ MAX_AUTHID_LENGTH ], szIP[ MAX_IP_LENGTH ];
	
	new szTempFilePath[ 64 ];
	formatex( szTempFilePath, charsmax( szTempFilePath ), "%s/%s", g_szConfigsDir, szTempFileName );
	
	formatex( szFormat, charsmax( szFormat ), "%s/%s", g_szConfigsDir, g_iConfig[ GAGS_FILE ] );
	new iFilePointer = fopen( szFormat, "rt" );
	
	if( iFilePointer )
	{
		new iInputFilePointer = fopen( szTempFilePath, "wt" );
		
		if( iInputFilePointer )
		{
			while( fgets( iFilePointer, szData, charsmax( szData ) ) )
			{
				switch( szData[ 0 ] )
				{
				case EOS, '#', ';', '/':
					{
						fprintf( iInputFilePointer, szData ); // write as it was before
					}

				default:
					{								
						parse( szData, szName, charsmax( szName ), szSteamId, charsmax( szSteamId ), szIP, charsmax( szIP ) );
						
						trim( szName );
						trim( szSteamId );
						trim( szIP );
						
						remove_quotes( szName );
						remove_quotes( szSteamId );
						remove_quotes( szIP );
						
						if( ! equali( szIdentity, szName ) && ! equali( szIdentity, szSteamId ) && ! equali( szIdentity, szIP ) ) // not the person we're looking for
						{
							fprintf( iInputFilePointer, szData ); // write as it was before
						}
					}
				}
			}
			fclose( iInputFilePointer );
			fclose( iFilePointer );

			delete_file( szFormat );
			rename_file( szTempFilePath, szFormat, 1 );
		}
	}
	return 0;
}

UnGagPlayer2( const szNamePlayer[ ], const szSteamIdPlayer[ ], const szIpPlayer[ ] )
{
	new const szTempFileName[ ] = "tempfile.ini";

	new szFormat[ 128 ], szData[ 192 ], szName[ MAX_NAME_LENGTH ], szSteamId[ MAX_AUTHID_LENGTH ], szIP[ MAX_IP_LENGTH ];
	
	new szTempFilePath[ 64 ];
	formatex( szTempFilePath, charsmax( szTempFilePath ), "%s/%s", g_szConfigsDir, szTempFileName );
	
	formatex( szFormat, charsmax( szFormat ), "%s/%s", g_szConfigsDir, g_iConfig[ GAGS_FILE ] );
	new iFilePointer = fopen( szFormat, "rt" );

	if( iFilePointer )
	{
		new iInputFilePointer = fopen( szTempFilePath, "wt" );
		
		if( iInputFilePointer )
		{
			while( fgets( iFilePointer, szData, charsmax( szData ) ) )
			{
				switch( szData[ 0 ] )
				{
				case EOS, '#', ';', '/':
					{
						fprintf( iInputFilePointer, szData ); // write as it was before
					}

				default:
					{			
						parse( szData, szName, charsmax( szName ), szSteamId, charsmax( szSteamId ), szIP, charsmax( szIP ) );
						
						trim( szName );
						trim( szSteamId );
						trim( szIP );
						
						if( equali( szNamePlayer, szName ) && equali( szSteamIdPlayer, szSteamId ) && equali( szIpPlayer, szIP ) )
						{
							new eData[ PlayerGag ];
							for( new i; i < ArraySize( g_aGags ); i++ )
							{
								ArrayGetArray( g_aGags, i, eData );
								
								if( equali( eData[ Player_Name ], szName ) && equali( eData[ Player_SteamId ], szSteamIdPlayer ) && equali( eData[ Player_IP ], szIP ) )
								{
									ArrayDeleteItem( g_aGags, i );
									break;
								}
							}	
						}
						
						else
						{
							fprintf( iInputFilePointer, szData ); // write as it was before
						}
					}
				}
			}
			fclose( iInputFilePointer );
			fclose( iFilePointer );

			delete_file( szFormat );
			rename_file( szTempFilePath, szFormat, 1 );
		}
	}
	return 0;
}

UnbanPlayer2( const szNamePlayer[ ], const szSteamIdPlayer[ ], const szIpPlayer[ ] )
{
	new const szTempFileName[ ] = "tempfile.ini";

	new szFormat[ 128 ], szData[ 192 ], szName[ MAX_NAME_LENGTH ], szSteamId[ MAX_AUTHID_LENGTH ], szIP[ MAX_IP_LENGTH ];
	
	new szTempFilePath[ 64 ];
	formatex( szTempFilePath, charsmax( szTempFilePath ), "%s/%s", g_szConfigsDir, szTempFileName );
	
	formatex( szFormat, charsmax( szFormat ), "%s/%s", g_szConfigsDir, g_iConfig[ BANS_FILE ] );
	new iFilePointer = fopen( szFormat, "rt" );

	if( iFilePointer )
	{
		new iInputFilePointer = fopen( szTempFilePath, "wt" );
		
		if( iInputFilePointer )
		{
			while( fgets( iFilePointer, szData, charsmax( szData ) ) )
			{
				switch( szData[ 0 ] )
				{
				case EOS, '#', ';', '/':
					{
						fprintf( iInputFilePointer, szData ); // write as it was before
					}

				default:
					{			
						parse( szData, szName, charsmax( szName ), szSteamId, charsmax( szSteamId ), szIP, charsmax( szIP ) );
						
						trim( szName );
						trim( szSteamId );
						trim( szIP );
						
						if( equali( szNamePlayer, szName ) && equali( szSteamIdPlayer, szSteamId ) && equali( szIpPlayer, szIP ) )
						{
							new eData[ PlayerBan ];
							for( new i; i < ArraySize( g_aBans ); i++ )
							{
								ArrayGetArray( g_aBans, i, eData );
								
								if( equali( eData[ Player_Name ], szName ) && equali( eData[ Player_SteamId ], szSteamIdPlayer ) && equali( eData[ Player_IP ], szIP ) )
								{
									ArrayDeleteItem( g_aBans, i );
									break;
								}
							}	
						}
						
						else
						{
							fprintf( iInputFilePointer, szData ); // write as it was before
						}
					}
				}
			}
			fclose( iInputFilePointer );
			fclose( iFilePointer );

			delete_file( szFormat );
			rename_file( szTempFilePath, szFormat, 1 );
		}
	}
	return 0;
}

BanPlayer( const szName[ ], const szSteamId[ ], const szIP[ ], const szExpireDate[ ], const szReason[ ], const szBannedBy[ ]  )
{
	new szFormat[ 128 ];
	formatex( szFormat, charsmax( szFormat ), "%s/%s", g_szConfigsDir, g_iConfig[ BANS_FILE ] );
	
	new iFilePointer = fopen( szFormat, "r+" );
	
	if( iFilePointer )
	{			
		new szByteVal[ 1 ];
		
		fseek( iFilePointer , -1 , SEEK_END );
		fread_raw( iFilePointer , szByteVal , sizeof( szByteVal ) , BLOCK_BYTE );
		fseek( iFilePointer , 0 , SEEK_END );
		
		fprintf( iFilePointer, "%s^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^"", ( szByteVal[ 0 ] == 10 ) ? "" : "^n", szName, szSteamId, szIP, szExpireDate, szReason, szBannedBy ); // add him to banlist
		fclose( iFilePointer );
	}
	return 1;
}

GagPlayer( const szName[ ], const szSteamId[ ], const szIP[ ], const szReason[ ], const szFlags[ ], const szExpireDate[ ] )
{
	new szFormat[ 128 ];
	formatex( szFormat, charsmax( szFormat ), "%s/%s", g_szConfigsDir, g_iConfig[ GAGS_FILE ] );
	
	new iFilePointer = fopen( szFormat, "r+" );
	
	if( iFilePointer )
	{			
		new szByteVal[ 1 ];
		
		fseek( iFilePointer , -1 , SEEK_END );
		fread_raw( iFilePointer , szByteVal , sizeof( szByteVal ) , BLOCK_BYTE );
		fseek( iFilePointer , 0 , SEEK_END );
		
		fprintf( iFilePointer, "%s^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^"", ( szByteVal[ 0 ] == 10 ) ? "" : "^n", szName, szSteamId, szIP, szReason, szFlags, szExpireDate ); // add him to gaglist
		fclose( iFilePointer );
	}
	return 1;
}

AddMinutesToDate( const szDate[ ], const iMinutes, szReturnDate[ ], const iSize )
{
	new const szFormatRule[ ] = "%m/%d/%Y - %H:%M:%S";
	new const iSecondsInMinute = 60;
	
	new iCurrentTimeStamp = parse_time( szDate, szFormatRule );
	iCurrentTimeStamp = iCurrentTimeStamp + ( iMinutes * iSecondsInMinute );
	format_time( szReturnDate, iSize, szFormatRule, iCurrentTimeStamp );
}

AddSecondsToDate( const szDate[ ], const iSeconds, szReturnDate[ ], const iSize )
{
	new const szFormatRule[ ] = "%m/%d/%Y - %H:%M:%S";
	
	new iCurrentTimeStamp = parse_time( szDate, szFormatRule );
	iCurrentTimeStamp = iCurrentTimeStamp + iSeconds;
	format_time( szReturnDate, iSize, szFormatRule, iCurrentTimeStamp );
}

ReadBans( )
{
	ArrayClear( g_aBans );
	ArrayClear( g_aBanExists );

	static szFile[ 128 ], szData[ 192 ];
	
	formatex( szFile, charsmax( szFile ), "%s/%s", g_szConfigsDir, g_iConfig[ BANS_FILE ] );
	
	new iFile = fopen( szFile, "rt" );
	
	if( iFile )
	{
		while( fgets( iFile, szData, charsmax( szData ) ) )
		{
			trim( szData );
			
			switch( szData[ 0 ] )
			{
			case EOS, '#', ';', '/':
				{
					continue;
				}

			default:
				{
					new eData[ PlayerBan ], szName[ MAX_NAME_LENGTH ], szSteamId[ MAX_AUTHID_LENGTH ], szIP[ MAX_IP_LENGTH ], szBanExpire[ 32 ], szBanReason[ 32 ], szBannedBy[ 32 ];
					
					parse( szData, szName, charsmax( szName ), szSteamId, charsmax( szSteamId ), szIP, charsmax( szIP ), szBanExpire, charsmax( szBanExpire ), szBanReason, charsmax( szBanReason ), szBannedBy, charsmax( szBannedBy ) );
					
					trim( szName );
					trim( szSteamId );
					trim( szIP );
					trim( szBanExpire );
					trim( szBanReason );
					trim( szBannedBy );
					
					copy( eData[ Player_Name ], charsmax( eData[ Player_Name ] ), szName );
					copy( eData[ Player_SteamId ], charsmax( eData[ Player_SteamId ] ), szSteamId );
					copy( eData[ Player_IP ], charsmax( eData[ Player_IP ] ), szIP );
					copy( eData[ Player_BanExpire ], charsmax( eData[ Player_BanExpire ] ), szBanExpire );
					copy( eData[ Player_BanReason ], charsmax( eData[ Player_BanReason ] ), szBanReason );
					copy( eData[ Player_BannedBy ], charsmax( eData[ Player_BannedBy ] ), szBannedBy );
					
					ArrayPushArray( g_aBans, eData );
					ArrayPushCell( g_aBanExists, 0 );
				}
			}
		}
		fclose( iFile );
	}
	return PLUGIN_CONTINUE;
}

ReadGags( )
{
	ArrayClear( g_aGags );
	ArrayClear( g_aGagExists );

	static szFile[ 128 ], szData[ 192 ];
	
	formatex( szFile, charsmax( szFile ), "%s/%s", g_szConfigsDir, g_iConfig[ GAGS_FILE ] );
	
	new iFile = fopen( szFile, "rt" );
	
	if( iFile )
	{
		while( fgets( iFile, szData, charsmax( szData ) ) )
		{
			trim( szData );
			
			switch( szData[ 0 ] )
			{
			case EOS, '#', ';', '/':
				{
					continue;
				}

			default:
				{
					new eData[ PlayerGag ], szName[ MAX_NAME_LENGTH ], szSteamId[ MAX_AUTHID_LENGTH ], szIP[ MAX_IP_LENGTH ], szGagExpire[ MAX_DATE_LENGTH ], szGagReason[ MAX_REASON_LENGTH ], szGagFlags[ 5 ];
					
					parse( szData, szName, charsmax( szName ), szSteamId, charsmax( szSteamId ), szIP, charsmax( szIP ), szGagReason, charsmax( szGagReason ), szGagFlags, charsmax( szGagFlags ), szGagExpire, charsmax( szGagExpire ) );
					
					trim( szName );
					trim( szSteamId );
					trim( szIP );
					trim( szGagReason );
					trim( szGagFlags );
					trim( szGagExpire );
					
					copy( eData[ Player_Name ], charsmax( eData[ Player_Name ] ), szName );
					copy( eData[ Player_SteamId ], charsmax( eData[ Player_SteamId ] ), szSteamId );
					copy( eData[ Player_IP ], charsmax( eData[ Player_IP ] ), szIP );
					copy( eData[ Player_GagExpire ], charsmax( eData[ Player_GagExpire ] ), szGagExpire );
					copy( eData[ Player_GagReason ], charsmax( eData[ Player_GagReason ] ), szGagReason );
					copy( eData[ Player_GagFlags ], charsmax( eData[ Player_GagFlags ] ), szGagFlags );
					
					ArrayPushArray( g_aGags, eData );
					ArrayPushCell( g_aGagExists, 0 );
				}
			}
		}
		fclose( iFile );
	}
	return PLUGIN_CONTINUE;
}

public KickPlayerOut( id )
{
	if( get_user_flags( id ) & g_iConfig[ IMMUNITY_FLAG ] )
	{
		return PLUGIN_HANDLED;
	}

	else
	{
		new eData[ PlayerBan ], szSteamId[ MAX_AUTHID_LENGTH ], szName[ MAX_NAME_LENGTH ], szIP[ MAX_IP_LENGTH ];
		get_user_authid( id, szSteamId, charsmax( szSteamId ) );
		get_user_name( id, szName, charsmax( szName ) );
		get_user_ip( id, szIP, charsmax( szIP ), 1 );

		for( new i; i < ArraySize( g_aBans ); i++ )
		{
			ArrayGetArray( g_aBans, i, eData );
			
			if( equali( szSteamId, eData[ Player_SteamId ] ) || equali( szName, eData[ Player_Name ] ) || equali( szIP, eData[ Player_IP ] ) )
			{
				if( ! HasDatePassed( eData[ Player_BanExpire ] ) || equali( eData[ Player_BanExpire ], "never" ) )
				{
					if( equali( eData[ Player_BanExpire ], "never" ) )
					{				
						client_print( id, print_console, "************************************************" );
						client_print( id, print_console, "%L", id, "BAN_INFO_BANNED" );
						client_print( id, print_console, "%L", id, "BAN_INFO_EXPIRE_NEVER" );
						client_print( id, print_console, "%L", id, "BAN_INFO_REASON", eData[ Player_BanReason ] );
						client_print( id, print_console, "%L", id, "BAN_INFO_BY", eData[ Player_BannedBy ] );
						client_print( id, print_console, "************************************************" );
					}
					
					else
					{
						client_print( id, print_console, "************************************************" );
						client_print( id, print_console, "%L", id, "BAN_INFO_BANNED" );
						client_print( id, print_console, "%L", id, "BAN_INFO_EXPIRE", eData[ Player_BanExpire ] );
						client_print( id, print_console, "%L", id, "BAN_INFO_REASON", eData[ Player_BanReason ] );
						client_print( id, print_console, "%L", id, "BAN_INFO_BY", eData[ Player_BannedBy ] );
						client_print( id, print_console, "************************************************" );
					}
					
					server_cmd( "kick #%d  %L", get_user_userid( id ), id, "CHECK_CONSOLE_INFO" );
					break;
				}
			}
		}
	}
	return PLUGIN_CONTINUE;
}

public CheckBanned( id )
{
	if( get_user_flags( id ) & g_iConfig[ IMMUNITY_FLAG ] )
	{
		return PLUGIN_HANDLED;
	}

	else
	{
		new eData[ PlayerBan ], szSteamId[ MAX_AUTHID_LENGTH ], szName[ MAX_NAME_LENGTH ], szIP[ MAX_IP_LENGTH ];
		get_user_authid( id, szSteamId, charsmax( szSteamId ) );
		get_user_name( id, szName, charsmax( szName ) );
		get_user_ip( id, szIP, charsmax( szIP ), 1 );

		for( new i; i < ArraySize( g_aBans ); i++ )
		{
			ArrayGetArray( g_aBans, i, eData );
			
			if( equali( szSteamId, eData[ Player_SteamId ] ) || equali( szName, eData[ Player_Name ] ) || equali( szIP, eData[ Player_IP ] ) )
			{
				if( ! HasDatePassed( eData[ Player_BanExpire ] ) || equali( eData[ Player_BanExpire ], "never" ) )
				{
					if( equali( eData[ Player_BanExpire ], "never" ) )
					{				
						client_print( id, print_console, "************************************************" );
						client_print( id, print_console, "%L", id, "BAN_INFO_BANNED" );
						client_print( id, print_console, "%L", id, "BAN_INFO_EXPIRE_NEVER" );
						client_print( id, print_console, "%L", id, "BAN_INFO_REASON", eData[ Player_BanReason ] );
						client_print( id, print_console, "%L", id, "BAN_INFO_BY", eData[ Player_BannedBy ] );
						client_print( id, print_console, "************************************************" );
					}
					
					else
					{
						client_print( id, print_console, "************************************************" );
						client_print( id, print_console, "%L", id, "BAN_INFO_BANNED" );
						client_print( id, print_console, "%L", id, "BAN_INFO_EXPIRE", eData[ Player_BanExpire ] );
						client_print( id, print_console, "%L", id, "BAN_INFO_REASON", eData[ Player_BanReason ] );
						client_print( id, print_console, "%L", id, "BAN_INFO_BY", eData[ Player_BannedBy ] );
						client_print( id, print_console, "************************************************" );
					}
					
					switch( g_iConfig[ BANNED_CONNECT_LOG ] )
					{
					case METHOD_CHAT:
						{
							CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "BANNED_PLAYER_CONNECTED", eData[ Player_Name ], eData[ Player_SteamId ], eData[ Player_IP ]  );
						}
						
					case METHOD_LOG:
						{
							log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "BANNED_PLAYER_CONNECTED_LOG", eData[ Player_Name ], eData[ Player_SteamId ], eData[ Player_IP ] );
						}
						
					case METHOD_BOTH:
						{
							CC_SendMessage( 0, "&x04%s %L", g_iConfig[ SYSTEM_PREFIX ], id, "BANNED_PLAYER_CONNECTED", eData[ Player_Name ], eData[ Player_SteamId ], eData[ Player_IP ] );
							log_to_file( g_iConfig[ LOGS_FILE ], "%L", LANG_PLAYER, "BANNED_PLAYER_CONNECTED_LOG", eData[ Player_Name ], eData[ Player_SteamId ], eData[ Player_IP ] );
						}
					}
					
					server_cmd( "kick #%d  %L", get_user_userid( id ), id, "CHECK_CONSOLE_INFO" );
					break;
				}
			}
		}
	}
	return PLUGIN_CONTINUE;
}

CheckGagged( id )
{
	if( get_user_flags( id ) & g_iConfig[ IMMUNITY_FLAG ] )
	{
		return PLUGIN_HANDLED;
	}

	else
	{
		new eData[ PlayerGag ], szSteamId[ MAX_AUTHID_LENGTH ], szName[ MAX_NAME_LENGTH ], szIP[ MAX_IP_LENGTH ];
		get_user_authid( id, szSteamId, charsmax( szSteamId ) );
		get_user_name( id, szName, charsmax( szName ) );
		get_user_ip( id, szIP, charsmax( szIP ), 1 );

		for( new i; i < ArraySize( g_aGags ); i++ )
		{
			ArrayGetArray( g_aGags, i, eData );
			
			if( equali( szSteamId, eData[ Player_SteamId ] ) || equali( szName, eData[ Player_Name ] ) || equali( szIP, eData[ Player_IP ] ) )
			{
				if( ! HasDatePassed( eData[ Player_GagExpire ] ) )
				{
					set_speak( id, SPEAK_MUTED );
					break;
				}
			}
		}
	}
	return PLUGIN_CONTINUE;
}

CheckExpiredBans( ) // check for bans that have expired
{
	new eData[ PlayerBan ];
	for( new i; i < ArraySize( g_aBans ); i++ )
	{
		ArrayGetArray( g_aBans, i, eData );
		
		if( ! equali( eData[ Player_BanExpire ], "never" ) )
		{
			if( HasDatePassed( eData[ Player_BanExpire ] ) )
			{
				RemoveExpiredBan( i );
			}
		}
	}
}

CheckExpiredGags( ) // check for gags that have expired
{
	new eData[ PlayerGag ];
	for( new i; i < ArraySize( g_aGags ); i++ )
	{
		ArrayGetArray( g_aGags, i, eData );
		
		if( ! equali( eData[ Player_GagExpire ], "never" ) )
		{
			if( HasDatePassed( eData[ Player_GagExpire ] ) )
			{
				RemoveExpiredGag( i );
			}
		}
	}
}

RemoveExpiredBan( iItem )
{
	new eData[ PlayerBan ];
	ArrayGetArray( g_aBans, iItem, eData );

	new const szTempFileName[ ] = "tempfile.ini";

	new szFormat[ 128 ], szData[ 192 ], szName[ MAX_NAME_LENGTH ], szSteamId[ MAX_AUTHID_LENGTH ], szIP[ MAX_IP_LENGTH ];
	
	new szTempFilePath[ 64 ];
	formatex( szTempFilePath, charsmax( szTempFilePath ), "%s/%s", g_szConfigsDir, szTempFileName );
	
	formatex( szFormat, charsmax( szFormat ), "%s/%s", g_szConfigsDir, g_iConfig[ BANS_FILE ] );
	new iFilePointer = fopen( szFormat, "rt" );

	if( iFilePointer )
	{
		new iInputFilePointer = fopen( szTempFilePath, "wt" );
		
		if( iInputFilePointer )
		{
			while( fgets( iFilePointer, szData, charsmax( szData ) ) )
			{
				switch( szData[ 0 ] )
				{
				case EOS, '#', ';', '/':
					{
						fprintf( iInputFilePointer, szData ); // write as it was before
					}

				default:
					{			
						parse( szData, szName, charsmax( szName ), szSteamId, charsmax( szSteamId ), szIP, charsmax( szIP ) );
						
						trim( szName );
						trim( szSteamId );
						trim( szIP );
						
						if( ! equali( eData[ Player_Name ], szName ) && ! equali( eData[ Player_SteamId ], szSteamId ) && ! equali( eData[ Player_IP ], szIP ) )
						{
							fprintf( iInputFilePointer, szData ); // write as it was before
						}
					}
				}
			}
			fclose( iInputFilePointer );
			fclose( iFilePointer );

			delete_file( szFormat );
			rename_file( szTempFilePath, szFormat, 1 );
		}
	}
	CheckExistingBans( );
	return 0;
}

RemoveExpiredGag( iItem )
{
	new eData[ PlayerGag ];
	ArrayGetArray( g_aGags, iItem, eData );

	new const szTempFileName[ ] = "tempfile.ini";

	new szFormat[ 128 ], szData[ 192 ], szName[ MAX_NAME_LENGTH ], szSteamId[ MAX_AUTHID_LENGTH ], szIP[ MAX_IP_LENGTH ];
	
	new szTempFilePath[ 64 ];
	formatex( szTempFilePath, charsmax( szTempFilePath ), "%s/%s", g_szConfigsDir, szTempFileName );
	
	formatex( szFormat, charsmax( szFormat ), "%s/%s", g_szConfigsDir, g_iConfig[ GAGS_FILE ] );
	new iFilePointer = fopen( szFormat, "rt" );

	if( iFilePointer )
	{
		new iInputFilePointer = fopen( szTempFilePath, "wt" );
		
		if( iInputFilePointer )
		{
			while( fgets( iFilePointer, szData, charsmax( szData ) ) )
			{
				switch( szData[ 0 ] )
				{
				case EOS, '#', ';', '/':
					{
						fprintf( iInputFilePointer, szData ); // write as it was before
					}

				default:
					{			
						parse( szData, szName, charsmax( szName ), szSteamId, charsmax( szSteamId ), szIP, charsmax( szIP ) );
						
						trim( szName );
						trim( szSteamId );
						trim( szIP );
						
						if( ! equali( eData[ Player_Name ], szName ) && ! equali( eData[ Player_SteamId ], szSteamId ) && ! equali( eData[ Player_IP ], szIP ) )
						{
							fprintf( iInputFilePointer, szData ); // write as it was before
						}
					}
				}
			}
			fclose( iInputFilePointer );
			fclose( iFilePointer );

			delete_file( szFormat );
			rename_file( szTempFilePath, szFormat, 1 );
		}
	}
	CheckExistingGags( );
	return 0;
}

CheckExistingBans( ) // check if the bans that are stored inside the array are also stored in the file
{
	static szFile[ 128 ], szData[ 192 ], eData[ PlayerBan ];
	formatex( szFile, charsmax( szFile ), "%s/%s", g_szConfigsDir, g_iConfig[ BANS_FILE ] );
	
	new iFile = fopen( szFile, "rt" );
	
	if( iFile )
	{
		while( fgets( iFile, szData, charsmax( szData ) ) )
		{
			trim( szData );
			
			switch( szData[ 0 ] )
			{
			case EOS, '#', ';', '/':
				{
					continue;
				}

			default:
				{
					for( new i; i < ArraySize( g_aBans ); i++ )
					{
						ArrayGetArray( g_aBans, i, eData );
						
						new szName[ MAX_NAME_LENGTH ], szSteamId[ MAX_AUTHID_LENGTH ], szIP[ MAX_IP_LENGTH ], szExpireDate[ 32 ], szReason[ MAX_REASON_LENGTH ];
						parse( szData, szName, charsmax( szName ), szSteamId, charsmax( szSteamId ), szIP, charsmax( szIP ), szExpireDate, charsmax( szExpireDate ), szReason, charsmax( szReason ) );
						
						trim( szName );
						trim( szSteamId );
						trim( szIP );
						trim( szExpireDate );
						trim( szReason );
						
						if( equali( eData[ Player_Name ], szName ) && equali( eData[ Player_SteamId ], szSteamId ) && equali( eData[ Player_IP ], szIP ) && equali( eData[ Player_BanExpire ], szExpireDate ) && equali( eData[ Player_BanReason ], szReason ) )
						{						
							ArraySetCell( g_aBanExists, i, 1 );
						}
					}
				}
			}
		}
		fclose( iFile );
		
		for( new i; i < ArraySize( g_aBans ); i++ )
		{
			if( ArrayGetCell( g_aBanExists, i ) != 1 )
			{
				ArrayDeleteItem( g_aBans, i );
			}
		}
	}
}

CheckExistingGags( )
{
	static szFile[ 128 ], szData[ 192 ], eData[ PlayerGag ];
	formatex( szFile, charsmax( szFile ), "%s/%s", g_szConfigsDir, g_iConfig[ GAGS_FILE ] );
	
	new iFile = fopen( szFile, "rt" );
	
	if( iFile )
	{
		while( fgets( iFile, szData, charsmax( szData ) ) )
		{
			trim( szData );
			
			switch( szData[ 0 ] )
			{
			case EOS, '#', ';', '/':
				{
					continue;
				}

			default:
				{
					for( new i; i < ArraySize( g_aGags ); i++ )
					{
						ArrayGetArray( g_aGags, i, eData );
						
						new szName[ MAX_NAME_LENGTH ], szSteamId[ MAX_AUTHID_LENGTH ], szIP[ MAX_IP_LENGTH ], szFlags[ 5 ], szExpireDate[ MAX_DATE_LENGTH ], szReason[ MAX_REASON_LENGTH ];
						parse( szData, szName, charsmax( szName ), szSteamId, charsmax( szSteamId ), szIP, charsmax( szIP ), szReason, charsmax( szReason ), szFlags, charsmax( szFlags ), szExpireDate, charsmax( szExpireDate ) );
						
						trim( szName );
						trim( szSteamId );
						trim( szIP );
						trim( szReason );
						trim( szFlags );
						trim( szExpireDate );
						
						if( equali( eData[ Player_Name ], szName ) && equali( eData[ Player_SteamId ], szSteamId ) && equali( eData[ Player_IP ], szIP ) && equali( eData[ Player_GagExpire ], szExpireDate ) && equali( eData[ Player_GagReason ], szReason ) && equali( eData[ Player_GagFlags ], szFlags ) )
						{						
							ArraySetCell( g_aGagExists, i, 1 );
						}
					}
				}
			}
		}
		fclose( iFile );
		
		for( new i; i < ArraySize( g_aGags ); i++ )
		{
			if( ArrayGetCell( g_aGagExists, i ) != 1 )
			{				
				ArrayDeleteItem( g_aGags, i );
			}
		}
	}
}

ReadUsers( )
{
	ArrayClear( g_aDataBase );

	new eData[ PlayerData ];

	new szFormat[ 64 ], szPlayerData[ 128 ];	
	formatex( szFormat, charsmax( szFormat ), "%s/%s", g_szConfigsDir, g_iConfig[ USERS_FILE ] );
	
	new iFile = fopen( szFormat, "rt" );
	
	if( iFile )
	{
		while( fgets( iFile, szPlayerData, charsmax( szPlayerData ) ) )
		{
			trim( szPlayerData );
			
			switch( szPlayerData[ 0 ] )
			{
			case EOS, '#', '/':
				{
					continue;
				}
				
			default:
				{
					parse( szPlayerData, eData[ Player_ID ], charsmax( eData[ Player_ID ] ), eData[ Player_Password ], charsmax( eData[ Player_Password ] ), eData[ Player_AccessFlags ],
					charsmax( eData[ Player_AccessFlags ] ), eData[ Player_Prefix ], charsmax( eData[ Player_Prefix ] ), eData[ Player_Model_T ], charsmax( eData[ Player_Model_T ] ),
					eData[ Player_Model_CT ], charsmax( eData[ Player_Model_CT ] ), eData[ Player_Immunity ], charsmax( eData[ Player_Immunity ] ), eData[ Player_Expire_Date ], charsmax( eData[ Player_Expire_Date ] ) );

					if( szPlayerData[ 0 ] == ';' )
					{
						replace( eData[ Player_ID ], charsmax( eData[ Player_ID ] ), ";", "" ); // Just remove the ';', no need to suspend, main plugin does it for us
					}
					
					ArrayPushArray( g_aDataBase, eData );
				}
			}
		}
		fclose( iFile );
	}
}

ReadMaps( )
{
	ArrayClear( g_aMaps );

	new szData[ MAX_MAP_NAME_LENGTH ];
	
	new iFile = fopen( g_szMapsFile, "rt" );
	
	if( iFile )
	{
		while( fgets( iFile, szData, charsmax( szData ) ) )
		{
			trim( szData );
			
			switch( szData[ 0 ] )
			{
			case EOS, '#', '/':
				{
					continue;
				}
				
			default:
				{
					ArrayPushString( g_aMaps, szData );
				}
			}
		}
		fclose( iFile );
	}
}

bool:HasDatePassed( const szDate[ ] )
{
	return get_systime( ) >= parse_time( szDate, "%m/%d/%Y - %H:%M:%S" );
}

bool:bOnlyRcon( const szName[ ] )
{
	new iPointer = get_cvar_pointer( szName );
	if( iPointer && get_pcvar_flags( iPointer ) & FCVAR_PROTECTED )
	{
		return true;
	}
	return false;
}

ScreenShot( id )
{
	client_cmd( id, "snapshot" );
}

ReadConfig( )
{
	new szFile[ 128 ], szData[ 64 ];
	
	formatex( szFile, charsmax( szFile ), "%s/%s", g_szConfigsDir, g_szConfigFile );
	
	new iFile = fopen( szFile, "rt" );
	
	if( iFile )
	{
		while( fgets( iFile, szData, charsmax( szData ) ) )
		{
			trim( szData );
			
			switch( szData[ 0 ] )
			{
			case EOS, '#', ';', '/':
				{
					continue;
				}

			default:
				{
					new szKey[ 32 ], szValue[ 64 ];
					strtok( szData, szKey, charsmax( szKey ), szValue, charsmax( szValue ), '=' );
					
					trim( szKey );
					trim( szValue );
					
					remove_quotes( szKey );
					remove_quotes( szValue );
					
					if( ! szValue[ 0 ] )
					{
						continue;
					}
					
					if( equali( szKey, "BANS_FILE" ) )
					{
						copy( g_iConfig[ BANS_FILE ], charsmax( g_iConfig[ BANS_FILE ] ), szValue );
					}
					
					else if( equali( szKey, "GAGS_FILE" ) )
					{
						copy( g_iConfig[ GAGS_FILE ], charsmax( g_iConfig[ GAGS_FILE ] ), szValue );
					}
					
					else if( equali( szKey, "LOGS_FILE" ) )
					{
						copy( g_iConfig[ LOGS_FILE ], charsmax( g_iConfig[ LOGS_FILE ] ), szValue );
					}
					
					else if( equali( szKey, "USERS_FILE" ) )
					{
						copy( g_iConfig[ USERS_FILE ], charsmax( g_iConfig[ USERS_FILE ] ), szValue );
					}
					
					else if( equali( szKey, "SYSTEM_PREFIX" ) )
					{
						copy( g_iConfig[ SYSTEM_PREFIX ], charsmax( g_iConfig[ SYSTEM_PREFIX ] ), szValue );
					}
					
					else if( equali( szKey, "BANNED_CONNECT_LOG" ) )
					{
						g_iConfig[ BANNED_CONNECT_LOG ] = str_to_num( szValue );
					}
					
					else if( equali( szKey, "KICK_FLAG" ) )
					{
						g_iConfig[ KICK_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "BAN_FLAG" ) )
					{
						g_iConfig[ BAN_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "ADD_BAN_FLAG" ) )
					{
						g_iConfig[ ADD_BAN_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "ADD_GAG_FLAG" ) )
					{
						g_iConfig[ ADD_GAG_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "GAG_FLAG" ) )
					{
						g_iConfig[ GAG_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "UNBAN_FLAG" ) )
					{
						g_iConfig[ UNBAN_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "SLAY_FLAG" ) )
					{
						g_iConfig[ SLAY_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "SLAP_FLAG" ) )
					{
						g_iConfig[ SLAP_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "CVAR_FLAG" ) )
					{
						g_iConfig[ CVAR_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "PLUGINS_FLAG" ) )
					{
						g_iConfig[ PLUGINS_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "MAP_FLAG" ) )
					{
						g_iConfig[ MAP_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "NICK_FLAG" ) )
					{
						g_iConfig[ NICK_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "RCON_FLAG" ) )
					{
						g_iConfig[ RCON_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "SHOW_RCON_FLAG" ) )
					{
						g_iConfig[ SHOW_RCON_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "MODULES_FLAG" ) )
					{
						g_iConfig[ MODULES_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "CHAT_FLAG" ) )
					{
						g_iConfig[ CHAT_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "FREEZE_FLAG" ) )
					{
						g_iConfig[ FREEZE_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "SCREENSHOT_FLAG" ) )
					{
						g_iConfig[ SCREENSHOT_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "COMMANDS_MENU_FLAG" ) )
					{
						g_iConfig[ COMMANDS_MENU_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "UNGAG_FLAG" ) )
					{
						g_iConfig[ UNGAG_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "SAY_FLAG" ) )
					{
						g_iConfig[ SAY_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "TEAM_FLAG" ) )
					{
						g_iConfig[ TEAM_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "PSAY_FLAG" ) )
					{
						g_iConfig[ PSAY_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "LAST_FLAG" ) )
					{
						g_iConfig[ LAST_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "WHO_FLAG" ) )
					{
						g_iConfig[ WHO_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "IMMUNITY_FLAG" ) )
					{
						g_iConfig[ IMMUNITY_FLAG ] = read_flags( szValue );
					}
					
					else if( equali( szKey, "UPDATE_BAN_FILE_FREQUENCY" ) )
					{
						g_iConfig[ UPDATE_BAN_FILE_FREQUENCY ] = _:str_to_float( szValue );
					}
					
					else if( equali( szKey, "UPDATE_GAG_FILE_FREQUENCY" ) )
					{
						g_iConfig[ UPDATE_GAG_FILE_FREQUENCY ] = _:str_to_float( szValue );
					}
					
					else if( equali( szKey, "TIME_CHECK_ADMINS" ) )
					{
						g_iConfig[ TIME_CHECK_ADMINS ] = _:str_to_float( szValue );
					}
					
					else if( equali( szKey, "DISCONNECT_INFO_SECONDS_EXPIRE" ) )
					{
						g_iConfig[ DISCONNECT_INFO_SECONDS_EXPIRE ] = str_to_num( szValue );
					}
					
					else if( equali( szKey, "FREQUENCY_CHECK_DISCONNECT_INFO" ) )
					{
						g_iConfig[ FREQUENCY_CHECK_DISCONNECT_INFO ] = _:str_to_float( szValue );
					}
					
					else if( equali( szKey, "RANKS_ENABLED" ) )
					{
						g_iConfig[ RANKS_ENABLED ] = str_to_num( szValue );
					}
					
					else if( equali( szKey, "CMDMENU_COMMANDS" ) )
					{
						while( szValue[ 0 ] != 0 && strtok( szValue, szKey, charsmax( szKey ), szValue, charsmax( szValue ), ',' ) )
						{
							trim( szKey );
							trim( szValue );
							
							register_concmd( szKey, "@CommandsMenu" );
						}
					}
				}
			}
		}
		fclose( iFile );
	}
}

eas_set_user_team( id, iTeam )
{
	if( is_user_alive( id ) )
	{
		ExecuteHamB( Ham_Killed, id, id, false );
	}
	cs_set_user_team( id, iTeam );
}

FreezePlayer( id, iValue )
{
	new iFlags = pev( id , pev_flags )

	switch( iValue )
	{
	case 0:
		{
			if( iFlags & FL_FROZEN )
			{
				set_pev( id, pev_flags, iFlags & ~FL_FROZEN );
				
				g_bFrozen[ id ] = false;
				
				if( g_iFwThink )
				{
					unregister_forward( FM_PlayerPreThink , g_iFwThink );
				}
			}
		}

	case 1:
		{
			if( ~iFlags & FL_FROZEN )
			{
				set_pev( id, pev_flags, iFlags | FL_FROZEN );
				g_bFrozen[ id ] = true;
				pev( id, pev_v_angle, fAngles[ id ] );
				
				g_iFwThink = register_forward( FM_PlayerPreThink , "fw_PlayerPreThink" );
			}
		}
	}
}
//////////////////////////////////////////////////////////////////////////// END OF STOCKS AND PRIVATE FUNCTIONS ////////////////////////////////////////////////////////////////////////////////////
__________________

Last edited by edon1337; 08-24-2019 at 08:17.
edon1337 is offline