From 03ab644961a4024e4efb6b5402d4a560008856e6 Mon Sep 17 00:00:00 2001 From: WessTorn Date: Wed, 22 May 2024 13:37:36 +0300 Subject: [PATCH] add speclist spechide --- data/lang/match_additons.txt | 16 +++++++++---- scripting/HnsMatchPlayerInfo.sma | 39 ++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/data/lang/match_additons.txt b/data/lang/match_additons.txt index 6f49e57..198c302 100644 --- a/data/lang/match_additons.txt +++ b/data/lang/match_additons.txt @@ -69,6 +69,10 @@ HUD_ON = %s HUD info is now ^3enabled^1. HUD_OFF = %s HUD info is now ^3disabled^1. ROUNDINFO_ON = %s Round info is now ^3enabled^1. ROUNDINFO_OFF = %s Round info is now ^3disabled^1. +SPECLIST_ON = %s Speclist is now ^3enabled^1. +SPECLIST_OFF = %s Speclist is now ^3disabled^1. +SPECHIDE_ON = %s Spechide is now ^3enabled^1. +SPECHIDE_OFF = %s Spechide is now ^3disabled^1. DMG_SPAM = %s Please wait ^3%.1f^1 seconds between commands! DMG_ERR = %s There is no OR multiple players with matching pattern -> ^3%s^1. @@ -146,10 +150,14 @@ STATS_TOP = %s Показать топ — ^3/top MAPS_NOM = %s ^3%n^1 номинировал карту: ^3%s^1. -HUD_ON = %s HUD информация ^3включена^1. -HUD_OFF = %s HUD информация ^3выключена^1. -ROUNDINFO_ON = %s Информация лучших игроков ^3включена^1. -ROUNDINFO_OFF = %s Информация лучших игроков ^3выключена^1. +HUD_ON = %s HUD информация: ^3включена^1. +HUD_OFF = %s HUD информация: ^3выключена^1. +ROUNDINFO_ON = %s Информация лучших игроков: ^3включена^1. +ROUNDINFO_OFF = %s Информация лучших игроков: ^3выключена^1. +SPECLIST_ON = %s Список наблюдателей: ^3включен^1. +SPECLIST_OFF = %s Список наблюдателей: ^3выключен^1. +SPECHIDE_ON = %s Спрятать в списке наблюдателей: ^3включен^1. +SPECHIDE_OFF = %s Спрятать в списке наблюдателей: ^3выключен^1. DMG_SPAM = %s Пожалуйста, подождите ^3%.1f^1 секунды между командами! DMG_ERR = %s Не существует ИЛИ нескольких игроков с совпадающим шаблоном -> ^3%s^1. diff --git a/scripting/HnsMatchPlayerInfo.sma b/scripting/HnsMatchPlayerInfo.sma index 0ee55b8..6247804 100644 --- a/scripting/HnsMatchPlayerInfo.sma +++ b/scripting/HnsMatchPlayerInfo.sma @@ -46,6 +46,8 @@ new g_eBestIndex[SHOW_STATS]; new g_eBestStats[SHOW_STATS]; enum _: SPEC_DATA { + bool:SHOW_SPEC, + bool:SPEC_HIDE, bool:IS_SPEC, SPEC_TARGET, bool:IS_POV @@ -61,6 +63,8 @@ public plugin_init() { RegisterSayCmd("hud", "hudinfo", "cmdHudInfo", 0, "Show hud info"); RegisterSayCmd("ri", "roundinfo", "cmdRoundInfo", 0, "Show hud info"); RegisterSayCmd("top", "tops", "ShowTop", 0, "Show top"); + RegisterSayCmd("showspec", "speclist", "cmdShowSpec", 0, "On/Off speclist"); + RegisterSayCmd("spechide", "hidespec", "cmdSpecHide", 0, "Spec hide"); RegisterHookChain(RG_CBasePlayer_TakeDamage, "rgTakeDamage", true); @@ -78,6 +82,7 @@ public client_disconnected(id) { if (g_eSpecPlayers[id][IS_SPEC]) { arrayset(g_eSpecPlayers[id], 0, SPEC_DATA); } + } public rgPlayerSpawn(id) { @@ -116,6 +121,8 @@ public plugin_cfg() { public client_putinserver(id) { g_HudOnOff[id] = true; g_HudRoundOnOff[id] = true; + g_eSpecPlayers[id][SHOW_SPEC] = true; + g_eSpecPlayers[id][SPEC_HIDE] = false; } public sayHandle(id) { @@ -188,6 +195,30 @@ public cmdRoundInfo(id) { return PLUGIN_HANDLED; } +public cmdShowSpec(id) { + g_eSpecPlayers[id][SHOW_SPEC] = !g_eSpecPlayers[id][SHOW_SPEC]; + + if (g_eSpecPlayers[id][SHOW_SPEC]) { + client_print_color(id, print_team_blue, "%L", id, "SPECLIST_ON", g_szPrefix); + } else { + client_print_color(id, print_team_blue, "%L", id, "SPECLIST_OFF", g_szPrefix); + } + + return PLUGIN_HANDLED; +} + +public cmdSpecHide(id) { + g_eSpecPlayers[id][SPEC_HIDE] = !g_eSpecPlayers[id][SPEC_HIDE]; + + if (g_eSpecPlayers[id][SPEC_HIDE]) { + client_print_color(id, print_team_blue, "%L", id, "SPECHIDE_ON", g_szPrefix); + } else { + client_print_color(id, print_team_blue, "%L", id, "SPECHIDE_OFF", g_szPrefix); + } + + return PLUGIN_HANDLED; +} + public hns_round_end() { if (hns_get_mode() != MODE_MIX || hns_get_state() == STATE_PAUSED || hns_get_status() != MATCH_STARTED) { reset_best_players(); @@ -456,10 +487,18 @@ public task_ShowPlayerInfo() { new szSpecMess[512], iSpecLen; new iSpecNum; for (new j = 0; j < MAX_PLAYERS; j++) { + if (!g_eSpecPlayers[show_id][SHOW_SPEC]) { + break; + } + if (!g_eSpecPlayers[j][IS_SPEC]) { continue; } + if (g_eSpecPlayers[j][SPEC_HIDE]) { + continue; + } + if (!is_user_connected(j)) { continue; }