RSSy MYGO.pl Opublikowano Październik 11, 2021 o 23:21 RSSy Udostępnij Opublikowano Październik 11, 2021 o 23:21 Hi there. Can someone please add a CVAR to disable/enable this plugin? Thank you so much in advance! PHP Code: #include < amxmodx > #include < fakemeta > #if AMXX_VERSION_NUM <= 182 #include < dhudmessage > #include < cvar_util > #if !defined _cvar_util_included #assert "cvar_util.inc library required ! Download it at : https://forums.alliedmods.net/showthread.php?t=154642#InstallationFiles" #endif #else #define client_disconnect client_disconnected #endif #define MAX_FPS_POSSIBLE 999.0 #define MIN_FPS_POSSIBLE 60.0 #define MAX_WARNINGS_POSSIBLE 5.0 /* * v0.1: Dev-CS.ru * v0.2: Dev-CS.ru * v0.3: Fixed a bug while a player is frozen causing FPS Overrates, added CVars! * v0.4: Organized the if statement checks in the cmdstart forward. */ new Float:g_fMaxFPS, g_MaxFPS_Warnings, g_MaxFPS_Punishment; public plugin_natives() { register_dictionary("fps_checker.txt"); } public plugin_cfg() { new szLang[3]; get_server_language(szLang); if(GetLangTransKey("MAXIMUM_FPS_ALLOWED") == TransKey_Bad) { AddTranslation(szLang, CreateLangKey("MAXIMUM_FPS_ALLOWED"), "Maximum FPS allowed in the server is"); server_print("[ FPS CHECKER ] (%s) Adding a translation key 'MAXIMUM_FPS_ALLOWED' text translation!", szLang); } if(GetLangTransKey("MAXIMUM_FPS_SLAY_REASON") == TransKey_Bad) { AddTranslation(szLang, CreateLangKey("MAXIMUM_FPS_SLAY_REASON"), "* You've been slayed due having your FPS over the %2.f limit!"); server_print("[ FPS CHECKER ] (%s) Adding a translation key 'MAXIMUM_FPS_SLAY_REASON' text translation!", szLang); } } get_server_language(szServerLang[3]="") { static szOutPut[3], iPCVar_language = 0; if( !iPCVar_language ) iPCVar_language = get_cvar_pointer("amx_language"); get_pcvar_string(iPCVar_language, szOutPut, charsmax(szOutPut)); for(new i, maxloop = get_langsnum(), szLang[3]; i < maxloop; i++) { get_lang(i, szLang) if(equal(szLang,szOutPut)) { copy(szServerLang, charsmax(szServerLang), szOutPut); return i; } } return -1; } public plugin_init() { register_plugin("Fps Checker", "0.4", "Dev-CS.ru & Natsheh"); register_forward(FM_CmdStart, "fw_CmdStart", true); #if AMXX_VERSION_NUM <= 182 CvarCache( CvarRegister("fps_checker_maxfps", "105", "Maximum FPS for players", FCVAR_SERVER, true, MIN_FPS_POSSIBLE, true, MAX_FPS_POSSIBLE), CvarType_Float, g_fMaxFPS ); CvarCache( CvarRegister("fps_checker_maxwarnings", "3", "Max warnings given before the action", FCVAR_SERVER, true, 0.0, true, MAX_WARNINGS_POSSIBLE), CvarType_Integer, g_MaxFPS_Warnings ); CvarCache( CvarRegister("fps_checker_punishment", "0", "Punishment type < 0 - kick / 1 - slay / else = ban >", FCVAR_SERVER, true, 0.0), CvarType_Integer, g_MaxFPS_Punishment ); #else bind_pcvar_float( create_cvar("fps_checker_maxfps", "105", FCVAR_SERVER, "Maximum FPS for players", true, MIN_FPS_POSSIBLE, true, MAX_FPS_POSSIBLE), g_fMaxFPS ); bind_pcvar_num( create_cvar("fps_checker_maxwarnings", "3", FCVAR_SERVER, "Max warnings given before the action", true, 0.0, true, MAX_WARNINGS_POSSIBLE), g_MaxFPS_Warnings ); bind_pcvar_num( create_cvar("fps_checker_punishment", "0", FCVAR_SERVER, "Punishment type < 0 - kick / 1 - slay / else = ban >", true, 0.0), g_MaxFPS_Punishment ); #endif } enum fps_s { warnings, num_cmds, msec_sum, Float: next_check, Float: fps } new g_fps_info[33][fps_s], bool:g_bIsUserBotOrHLTV[33]; public client_putinserver(id) { g_bIsUserBotOrHLTV[id] = (is_user_bot(id) || is_user_hltv(id)) ? true : false; g_fps_info[id][warnings] = g_fps_info[id][num_cmds] = g_fps_info[id][msec_sum] = 0; g_fps_info[id][next_check] = g_fps_info[id][fps] = 0.0; } public client_disconnect(id) { g_fps_info[id][next_check] = get_gametime() + 999999999.0; } public fw_CmdStart(id, uc_handle) { if (!g_bIsUserBotOrHLTV[id] && (pev(id, pev_flags) & FL_FROZEN) == 0) { if(g_fps_info[id][next_check] <= get_gametime()) { g_fps_info[id][fps] = (g_fps_info[id][num_cmds] * 1000.0) / g_fps_info[id][msec_sum]; if (g_fps_info[id][fps] > g_fMaxFPS) { if (++g_fps_info[id][warnings] > g_MaxFPS_Warnings) { static szReason[32]; formatex(szReason, charsmax(szReason), "%2.f+ FPS", g_fMaxFPS); punish_user(id, szReason); g_fps_info[id][warnings] = 0; } else { set_dhudmessage( 225, 0, 0, 0.5, 0.65, 1, 0.5, 1.0, 0.01, 0.01 ); show_dhudmessage( id, "%L %2.f FPS", LANG_SERVER, "MAXIMUM_FPS_ALLOWED", g_fMaxFPS); } } g_fps_info[id][num_cmds] = g_fps_info[id][msec_sum] = 0; g_fps_info[id][next_check] = get_gametime() + 1.0; } g_fps_info[id][num_cmds] ++; g_fps_info[id][msec_sum] += get_uc(uc_handle, UC_Msec); } } punish_user(const id, const szReason[]) { switch( g_MaxFPS_Punishment ) { case 0: server_cmd("kick #%d ^" %s ^"", get_user_userid(id), szReason); case 1: { if(!is_user_alive(id)) return; user_kill(id); client_print(id, print_chat, "%L", LANG_SERVER, "MAXIMUM_FPS_SLAY_REASON", g_fMaxFPS); } default: { server_cmd("banid ^"%d^" ^"#%d^"; writeid; kick #%d ^" Banned %d minutes: %s ^";", g_MaxFPS_Punishment, get_user_userid(id), get_user_userid(id), g_MaxFPS_Punishment, szReason); } } } Przeczytaj cały wpis Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
Rekomendowane odpowiedzi