From 80ae7c8dadf1835911508aa0dd40ad968411079e Mon Sep 17 00:00:00 2001 From: WessTorn Date: Tue, 3 Aug 2021 03:31:33 +0300 Subject: [PATCH] add set team time /ct /tt --- data/lang/mixsystem.txt | 6 +- scripting/HnsMatchSystem.sma | 2 +- scripting/include/hns-match/say.inc | 90 ++++++++++++++++++++++-- scripting/include/hns-match/showinfo.inc | 3 - 4 files changed, 89 insertions(+), 12 deletions(-) diff --git a/data/lang/mixsystem.txt b/data/lang/mixsystem.txt index 3ccc41f..06a9cdf 100644 --- a/data/lang/mixsystem.txt +++ b/data/lang/mixsystem.txt @@ -3,9 +3,13 @@ STATUS_NOPLAY = %s ^3%s^1 is ^3not available^1 for pick [^3NOPLAY^1] STATUS_PLAY = %s ^3%s^1 is now ^3available^1 for pick [^3PLAY^1] SET_WINTIME = %s ^3%s^1 set ^3wintime^1 to ^3%d^1 minutes. -NOT_SET_TIME = %s Disable mr mode, before changing wintimer. SET_ROUNDTIME = %s ^3%s ^1 set ^3roundtime^1 to ^3%.2f^1 minutes. SET_MAXROUNDS = %s ^3%s ^1 set ^3maxrounds^1 to ^3%d^1 rounds. +SER_TIME_TT = %s ^3%n^1 set timer for team TT to ^3%s:%s^1. +SER_TIME_CT = %s ^3%n^1 set timer for team CT to ^3%s:%s^1. +NOT_SET_TT = %s Invalid syntax. Example: ^3/tt 15:43^1. +NOT_SET_СT = %s Invalid syntax. Example: ^3/ct 15:43^1. +NOT_SET_TIME = %s Disable mr mode, before changing wintimer. NOT_SET_MR = %s Disable timer mode, before changing maxrounds. KILL_HIMSELF = %s ^3%s ^1killed himself diff --git a/scripting/HnsMatchSystem.sma b/scripting/HnsMatchSystem.sma index e8d8465..9809c2e 100644 --- a/scripting/HnsMatchSystem.sma +++ b/scripting/HnsMatchSystem.sma @@ -9,7 +9,7 @@ public plugin_precache() { } public plugin_init() { - register_plugin("Hide'n'Seek Match System", "1.2.2", "??"); // Спасибо: Cultura, Garey, Medusa, Ruffman, Conor + register_plugin("Hide'n'Seek Match System", "1.2.3", "??"); // Спасибо: Cultura, Garey, Medusa, Ruffman, Conor get_mapname(g_eMatchInfo[e_mMapName], charsmax(g_eMatchInfo[e_mMapName])); diff --git a/scripting/include/hns-match/say.inc b/scripting/include/hns-match/say.inc index 25bd97c..109bce7 100644 --- a/scripting/include/hns-match/say.inc +++ b/scripting/include/hns-match/say.inc @@ -24,15 +24,16 @@ public sayHandle(id) { szTarget, charsmax(szTarget)); if (equali(szArgs, "/wintime", 8)) { - if(g_iCurrentRules == e_mMR) { - client_print_color(id, print_team_blue, "%L", id, "NOT_SET_TIME", prefix); - return PLUGIN_HANDLED; - } trim(szTarget); if (!getUserInAccess(id)) return PLUGIN_HANDLED; + if(g_iCurrentRules == e_mMR) { + client_print_color(id, print_team_blue, "%L", id, "NOT_SET_TIME", prefix); + return PLUGIN_HANDLED; + } + if (is_str_num(szTarget)) { set_pcvar_num(g_eCvars[e_cCapTime], str_to_num(szTarget)); client_print_color(0, print_team_blue, "%L", id, "SET_WINTIME", prefix, getUserName(id), str_to_num(szTarget)); @@ -54,19 +55,94 @@ public sayHandle(id) { } if (equali(szArgs, "/maxround", 10)) { + trim(szTarget); + + if (!getUserInAccess(id)) + return PLUGIN_HANDLED; + if(g_iCurrentRules == e_mTimer) { client_print_color(id, print_team_blue, "%L", id, "NOT_SET_MR", prefix); return PLUGIN_HANDLED; } + + if (is_str_num(szTarget)) { + set_pcvar_num(g_eCvars[e_cMaxRounds], str_to_num(szTarget)); + client_print_color(0, print_team_blue, "%L", id, "SET_MAXROUNDS", prefix, getUserName(id), str_to_num(szTarget)); + } + return PLUGIN_CONTINUE; + } + + if (equali(szArgs, "/tt", 15)) { trim(szTarget); if (!getUserInAccess(id)) return PLUGIN_HANDLED; - if (is_str_num(szTarget)) { - set_pcvar_num(g_eCvars[e_cMaxRounds], str_to_num(szTarget)); - client_print_color(0, print_team_blue, "%L", id, "SET_MAXROUNDS", prefix, getUserName(id), str_to_num(szTarget)); + if(g_iCurrentRules != e_mTimer) { + return PLUGIN_HANDLED; + } + + new szMinutes[10], szSeconds[16]; + replace(szTarget, charsmax(szTarget), ":", " "); + replace(szTarget, charsmax(szTarget), ".", " "); + + if (!parse(szTarget, szMinutes, charsmax(szMinutes), szSeconds, charsmax(szSeconds))) { + client_print_color(id, print_team_blue, "%L", id, "NOT_SET_TT", prefix); + return PLUGIN_HANDLED; } + + if (!szMinutes[0] || !szSeconds[0]) { + client_print_color(id, print_team_blue, "%L", id, "NOT_SET_TT", prefix); + return PLUGIN_HANDLED; + } + + new minutes = str_to_num(szMinutes); + new seconds = str_to_num(szSeconds); + + if (seconds >= 60) { + client_print_color(id, print_team_blue, "%L", id, "NOT_SET_TT", prefix); + return PLUGIN_HANDLED; + } + + g_flSidesTime[!g_iCurrentSW] = (get_pcvar_float(g_eCvars[e_cCapTime]) - (minutes + (seconds / 60.0))) * 60.0; + client_print_color(0, print_team_blue, "%L", 0, "SER_TIME_TT", prefix, id, szMinutes, szSeconds); + return PLUGIN_CONTINUE; + } + + if (equali(szArgs, "/ct", 15)) { + trim(szTarget); + + if (!getUserInAccess(id)) + return PLUGIN_HANDLED; + + if(g_iCurrentRules != e_mTimer) { + return PLUGIN_HANDLED; + } + + new szMinutes[10], szSeconds[16]; + replace(szTarget, charsmax(szTarget), ":", " "); + replace(szTarget, charsmax(szTarget), ".", " "); + + if (!parse(szTarget, szMinutes, charsmax(szMinutes), szSeconds, charsmax(szSeconds))) { + client_print_color(id, print_team_blue, "%L", id, "NOT_SET_СT", prefix); + return PLUGIN_HANDLED; + } + + if (!szMinutes[0] || !szSeconds[0]) { + client_print_color(id, print_team_blue, "%L", id, "NOT_SET_СT", prefix); + return PLUGIN_HANDLED; + } + + new minutes = str_to_num(szMinutes); + new seconds = str_to_num(szSeconds); + + if (seconds >= 60) { + client_print_color(id, print_team_blue, "%L", id, "NOT_SET_СT", prefix); + return PLUGIN_HANDLED; + } + + g_flSidesTime[!g_iCurrentSW] = (get_pcvar_float(g_eCvars[e_cCapTime]) - (minutes + (seconds / 60.0))) * 60.0; + client_print_color(0, print_team_blue, "%L", 0, "SER_TIME_CT", prefix, id, szMinutes, szSeconds); return PLUGIN_CONTINUE; } diff --git a/scripting/include/hns-match/showinfo.inc b/scripting/include/hns-match/showinfo.inc index de83939..9305643 100644 --- a/scripting/include/hns-match/showinfo.inc +++ b/scripting/include/hns-match/showinfo.inc @@ -114,9 +114,6 @@ public apply_stats() { } public task_ShowPlayerInfo() { - if(g_iCurrentMode != e_mMatch) - return; - new iPlayers[MAX_PLAYERS], iNum; get_players(iPlayers, iNum);