From 9a742672cf72d4af5539201d5ab6a92f823d03be Mon Sep 17 00:00:00 2001 From: Nordic Warrior Date: Tue, 7 Sep 2021 19:22:37 +0300 Subject: [PATCH 1/4] core: added CVar `mapm_early_finish_vote` which allows to finish voting early if all players have voted. --- cstrike/addons/amxmodx/configs/map_manager.cfg | 4 ++++ cstrike/addons/amxmodx/data/lang/mapmanager.txt | 2 ++ cstrike/addons/amxmodx/scripting/map_manager_core.sma | 10 +++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cstrike/addons/amxmodx/configs/map_manager.cfg b/cstrike/addons/amxmodx/configs/map_manager.cfg index b5b20a8..2c0b06e 100644 --- a/cstrike/addons/amxmodx/configs/map_manager.cfg +++ b/cstrike/addons/amxmodx/configs/map_manager.cfg @@ -44,6 +44,10 @@ mapm_vote_item_offset "0" // если вклчен аддон "Online Sorter" mapm_only_external_vote_items "0" +// Позволяет завершить голосование досрочно, если проголосовали все игроки. +// 0 - disable, 1 - enable +mapm_early_finish_vote "0" + // Scheduler diff --git a/cstrike/addons/amxmodx/data/lang/mapmanager.txt b/cstrike/addons/amxmodx/data/lang/mapmanager.txt index 9b9409d..5c047dc 100644 --- a/cstrike/addons/amxmodx/data/lang/mapmanager.txt +++ b/cstrike/addons/amxmodx/data/lang/mapmanager.txt @@ -54,6 +54,7 @@ MAPM_WINS = wins MAPM_VOTE_IN_NEXTROUND = Wait vote in next round. MAPM_SECOND_VOTE = Second vote. MAPM_CHANGELEVEL_NEXTROUND = Map will change in next round. +MAPM_EARLY_FINISH_VOTE = All players have voted, so we are ending voting^3 early. [ru] MAPM_VOTE_WILL_BEGIN = Голосование начнется в следующем раунде. @@ -111,3 +112,4 @@ MAPM_WINS = побед MAPM_VOTE_IN_NEXTROUND = Подождите, голосование начнется в следующем раунде. MAPM_SECOND_VOTE = Второе голосование. MAPM_CHANGELEVEL_NEXTROUND = Карта сменится в следующем раунде. +MAPM_EARLY_FINISH_VOTE = Проголосовали все игроки,^3 досрочно^1 завершаем голосование. diff --git a/cstrike/addons/amxmodx/scripting/map_manager_core.sma b/cstrike/addons/amxmodx/scripting/map_manager_core.sma index 939167c..272afd9 100644 --- a/cstrike/addons/amxmodx/scripting/map_manager_core.sma +++ b/cstrike/addons/amxmodx/scripting/map_manager_core.sma @@ -51,7 +51,8 @@ enum Cvars { PREPARE_TIME, VOTE_TIME, VOTE_ITEM_OFFSET, - ONLY_EXTERNAL_VOTE_ITEMS + ONLY_EXTERNAL_VOTE_ITEMS, + EARLY_FINISH_VOTE }; new g_pCvars[Cvars]; @@ -102,6 +103,7 @@ public plugin_init() g_pCvars[VOTE_TIME] = register_cvar("mapm_vote_time", "10"); // seconds g_pCvars[VOTE_ITEM_OFFSET] = register_cvar("mapm_vote_item_offset", "0"); g_pCvars[ONLY_EXTERNAL_VOTE_ITEMS] = register_cvar("mapm_only_external_vote_items", "0"); + g_pCvars[EARLY_FINISH_VOTE] = register_cvar("mapm_early_finish_vote", "0"); g_hForwards[MAPLIST_LOADED] = CreateMultiForward("mapm_maplist_loaded", ET_IGNORE, FP_CELL, FP_STRING); g_hForwards[MAPLIST_UNLOADED] = CreateMultiForward("mapm_maplist_unloaded", ET_IGNORE); @@ -553,6 +555,12 @@ public countdown(taskid) show_votemenu(id); } } + + if(get_num(EARLY_FINISH_VOTE) && g_iTotalVotes == pnum) { + g_iTimer = 0; + + client_print_color(0, print_team_default, "%s^1 %L", g_sPrefix, LANG_PLAYER, "MAPM_EARLY_FINISH_VOTE"); + } } new type = COUNTDOWN_UNKNOWN; From 2ccab8c3336ac16b02657257bb0649f32f2f224f Mon Sep 17 00:00:00 2001 From: Nord1cWarr1or Date: Sun, 6 Feb 2022 14:06:11 +0300 Subject: [PATCH 2/4] core: move `mapm_early_finish_vote` logic to add_item_votes() --- .../amxmodx/scripting/map_manager_core.sma | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/cstrike/addons/amxmodx/scripting/map_manager_core.sma b/cstrike/addons/amxmodx/scripting/map_manager_core.sma index 0ecdca9..ae60ec5 100644 --- a/cstrike/addons/amxmodx/scripting/map_manager_core.sma +++ b/cstrike/addons/amxmodx/scripting/map_manager_core.sma @@ -90,6 +90,8 @@ new g_sPrefix[48]; new g_sDisplayedItemName[MAX_VOTELIST_SIZE + 1][MAPNAME_LENGTH * 2]; +new g_playersnum; + public plugin_init() { register_plugin(PLUGIN, VERSION + VERSION_HASH, AUTHOR); @@ -575,19 +577,13 @@ public countdown(taskid) g_iShowPercent = get_num(SHOW_PERCENT); g_bShowSelects = get_num(SHOW_SELECTS); - new players[32], pnum; get_players(players, pnum, "ch"); - for(new i, id; i < pnum; i++) { + new players[32]; get_players(players, g_playersnum, "ch"); + for(new i, id; i < g_playersnum; i++) { id = players[i]; if(!dont_show_result || g_iVoted[id] == NOT_VOTED) { show_votemenu(id); } } - - if(get_num(EARLY_FINISH_VOTE) && g_iTotalVotes == pnum) { - g_iTimer = 0; - - client_print_color(0, print_team_default, "%s^1 %L", g_sPrefix, LANG_PLAYER, "MAPM_EARLY_FINISH_VOTE"); - } } new type = COUNTDOWN_UNKNOWN; @@ -701,6 +697,12 @@ add_item_votes(item, value) { g_iVotes[item] += value; g_iTotalVotes += value; + + if(get_num(EARLY_FINISH_VOTE) && g_iTotalVotes == g_playersnum) { + g_iTimer = 0; + + client_print_color(0, print_team_default, "%s^1 %L", g_sPrefix, LANG_PLAYER, "MAPM_EARLY_FINISH_VOTE"); + } } finish_vote() { From 2c4f893a1ed6cf53ae4a334d11651de2030a5563 Mon Sep 17 00:00:00 2001 From: Nord1cWarr1or Date: Sun, 6 Feb 2022 21:24:47 +0300 Subject: [PATCH 3/4] apply changes from code rewiew --- cstrike/addons/amxmodx/data/lang/mapmanager.txt | 2 +- cstrike/addons/amxmodx/scripting/map_manager_core.sma | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cstrike/addons/amxmodx/data/lang/mapmanager.txt b/cstrike/addons/amxmodx/data/lang/mapmanager.txt index bff60eb..15251ca 100644 --- a/cstrike/addons/amxmodx/data/lang/mapmanager.txt +++ b/cstrike/addons/amxmodx/data/lang/mapmanager.txt @@ -43,7 +43,7 @@ MAPM_WINS = wins MAPM_VOTE_IN_NEXTROUND = Wait vote in next round. MAPM_SECOND_VOTE = Second vote. MAPM_CHANGELEVEL_NEXTROUND = Map will change in next round. -MAPM_EARLY_FINISH_VOTE = All players have voted, so we are ending voting^3 early. +MAPM_EARLY_FINISH_VOTE = All players have voted, so we are ending voting^3 early^1. [ru] MAPM_VOTE_WILL_BEGIN = Голосование начнется в следующем раунде. diff --git a/cstrike/addons/amxmodx/scripting/map_manager_core.sma b/cstrike/addons/amxmodx/scripting/map_manager_core.sma index ae60ec5..9fe8084 100644 --- a/cstrike/addons/amxmodx/scripting/map_manager_core.sma +++ b/cstrike/addons/amxmodx/scripting/map_manager_core.sma @@ -90,7 +90,7 @@ new g_sPrefix[48]; new g_sDisplayedItemName[MAX_VOTELIST_SIZE + 1][MAPNAME_LENGTH * 2]; -new g_playersnum; +new g_iPlayersNum; public plugin_init() { @@ -577,8 +577,8 @@ public countdown(taskid) g_iShowPercent = get_num(SHOW_PERCENT); g_bShowSelects = get_num(SHOW_SELECTS); - new players[32]; get_players(players, g_playersnum, "ch"); - for(new i, id; i < g_playersnum; i++) { + new players[32]; get_players(players, g_iPlayersNum, "ch"); + for(new i, id; i < g_iPlayersNum; i++) { id = players[i]; if(!dont_show_result || g_iVoted[id] == NOT_VOTED) { show_votemenu(id); @@ -698,9 +698,8 @@ add_item_votes(item, value) g_iVotes[item] += value; g_iTotalVotes += value; - if(get_num(EARLY_FINISH_VOTE) && g_iTotalVotes == g_playersnum) { + if(get_num(EARLY_FINISH_VOTE) && g_iTotalVotes == g_iPlayersNum) { g_iTimer = 0; - client_print_color(0, print_team_default, "%s^1 %L", g_sPrefix, LANG_PLAYER, "MAPM_EARLY_FINISH_VOTE"); } } From 963eb98686169439cfffe914e7cfae1584a9f042 Mon Sep 17 00:00:00 2001 From: Nord1cWarr1or Date: Sun, 6 Feb 2022 21:25:10 +0300 Subject: [PATCH 4/4] core: bump version --- cstrike/addons/amxmodx/scripting/map_manager_core.sma | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cstrike/addons/amxmodx/scripting/map_manager_core.sma b/cstrike/addons/amxmodx/scripting/map_manager_core.sma index 9fe8084..4cfb1a1 100644 --- a/cstrike/addons/amxmodx/scripting/map_manager_core.sma +++ b/cstrike/addons/amxmodx/scripting/map_manager_core.sma @@ -7,7 +7,7 @@ #endif #define PLUGIN "Map Manager: Core" -#define VERSION "3.1.3" +#define VERSION "3.1.4" #define AUTHOR "Mistrick" #pragma semicolon 1