#include < amxmodx >
#include < amxmisc >
#include < reapi >
#pragma semicolon 1
const MS_CHECK__TASK_ID = 16858; // Идентификатор задачи для проверки МС
const Float: MS_CHECK__TASK_DELAY = 5.0; // Задержка задачи для проверки МС
new const MS_CHECK__LOGS_FOLDERNAME[ ] = "ms_check"; // Папка с логами проверки МС
new const MS_CHECK__LOG_FILENAME[ ] = "ms_check"; // Наименование файла логов проверки МС
const MAX_USERID_LENGTH = 16;
const MAX_MS_NAME_LENGTH = 32;
const MAX_TIME_LENGTH = 32;
new g_sLogsDir[ MAX_RESOURCE_PATH_LENGTH ];
new g_sLogsFile[ MAX_RESOURCE_PATH_LENGTH + 32 ];
new bool: g_bMSDetected[ MAX_PLAYERS + 1 ];
public plugin_init( )
{
register_plugin( "Server Master Check", "1.0", "Javekson" );
register_srvcmd( "ms_check", "srvcmd_ServerMasterCheck" );
}
public plugin_cfg( )
{
get_localinfo( "amxx_logs", g_sLogsDir, charsmax( g_sLogsDir ) );
formatex( g_sLogsDir, charsmax( g_sLogsDir ), "%s/%s", g_sLogsDir, MS_CHECK__LOGS_FOLDERNAME );
if( !dir_exists( g_sLogsDir ) ) mkdir( g_sLogsDir );
new sTime[ MAX_TIME_LENGTH ];
get_time( "%d.%m.%Y", sTime, charsmax( sTime ) );
formatex( g_sLogsFile, charsmax( g_sLogsFile ), "%s/%s_%s.log", g_sLogsDir, MS_CHECK__LOG_FILENAME, sTime );
}
public client_putinserver( id )
{
set_task_ex( MS_CHECK__TASK_DELAY, "task_ServerMasterCheck", MS_CHECK__TASK_ID + id, .flags = SetTask_Once );
}
public client_disconnected( id )
{
g_bMSDetected[ id ] = false;
remove_task( MS_CHECK__TASK_ID + id );
}
public task_ServerMasterCheck( iTaskID )
{
new id = iTaskID - MS_CHECK__TASK_ID;
if( !is_user_connected( id ) || is_user_bot( id ) || is_user_hltv( id ) )
return PLUGIN_CONTINUE;
if( !g_bMSDetected[ id ] )
{
new sAuthID[ MAX_AUTHID_LENGTH ], sPlayerName[ MAX_NAME_LENGTH ];
get_user_authid( id, sAuthID, charsmax( sAuthID ) );
get_user_name( id, sPlayerName, charsmax( sPlayerName ) );
if( is_user_steam( id ) )
log_to_file( g_sLogsFile, "^"%-32s %-32s [STEAM]^"", sPlayerName, sAuthID );
else
log_to_file( g_sLogsFile, "^"%-32s %-32s [НЕИЗВЕСТНО]^"", sPlayerName, sAuthID );
}
return PLUGIN_CONTINUE;
}
public srvcmd_ServerMasterCheck( )
{
new sPlayerUserID[ MAX_USERID_LENGTH ], sMSName[ MAX_MS_NAME_LENGTH ];
read_argv( 1, sPlayerUserID, charsmax( sPlayerUserID ) );
read_argv( 2, sMSName, charsmax( sMSName ) );
replace( sPlayerUserID, charsmax( sPlayerUserID ), "#", "" );
new iPlayerUserID;
iPlayerUserID = str_to_num( sPlayerUserID );
new iPlayerID;
iPlayerID = find_player( "k", iPlayerUserID );
g_bMSDetected[ iPlayerID ] = true;
new sPlayerName[ MAX_NAME_LENGTH ], sAuthID[ MAX_AUTHID_LENGTH ];
get_user_name( iPlayerID, sPlayerName, charsmax( sPlayerName ) );
get_user_authid( iPlayerID, sAuthID, charsmax( sAuthID ) );
log_to_file( g_sLogsFile, "^"%-32s %-32s %s^"", sPlayerName, sAuthID, sMSName );
}