From 7281bf95ae9c3961247a42dc1868b1fe7a43ecd7 Mon Sep 17 00:00:00 2001 From: Mistrick Date: Fri, 20 Apr 2018 18:24:01 +0700 Subject: [PATCH] refactor for prefix cvar --- .../amxmodx/scripting/map_manager_effects.sma | 12 ++++++--- .../scripting/map_manager_informer.sma | 26 +++++++++---------- .../scripting/map_manager_nomination.sma | 20 +++++++------- addons/amxmodx/scripting/map_manager_rtv.sma | 16 +++++++----- 4 files changed, 41 insertions(+), 33 deletions(-) diff --git a/addons/amxmodx/scripting/map_manager_effects.sma b/addons/amxmodx/scripting/map_manager_effects.sma index 172ef5b..de55663 100644 --- a/addons/amxmodx/scripting/map_manager_effects.sma +++ b/addons/amxmodx/scripting/map_manager_effects.sma @@ -4,7 +4,7 @@ #include #define PLUGIN "Map Manager: Effects" -#define VERSION "0.0.3" +#define VERSION "0.0.4" #define AUTHOR "Mistrick" #pragma semicolon 1 @@ -27,7 +27,9 @@ enum Cvars { FREEZETIME, VOTE_IN_NEW_ROUND, PREPARE_TIME, - VOTE_TIME + VOTE_TIME, + CHANGE_TYPE, + LAST_ROUND }; enum { @@ -70,6 +72,8 @@ public plugin_cfg() g_pCvars[VOTE_IN_NEW_ROUND] = get_cvar_pointer("mapm_vote_in_new_round"); g_pCvars[PREPARE_TIME] = get_cvar_pointer("mapm_prepare_time"); g_pCvars[VOTE_TIME] = get_cvar_pointer("mapm_vote_time"); + g_pCvars[CHANGE_TYPE] = get_cvar_pointer("mapm_change_type"); + g_pCvars[LAST_ROUND] = get_cvar_pointer("mapm_last_round"); } } public plugin_end() @@ -158,7 +162,9 @@ public mapm_vote_finished(map[], type, total_votes) g_bFreezetimeChanged = false; set_float(FREEZETIME, get_float(FREEZETIME) - get_float(PREPARE_TIME) - get_float(VOTE_TIME) - 1); } - freeze_unfreeze(1); + if(get_num(CHANGE_TYPE) || get_num(LAST_ROUND)) { + freeze_unfreeze(1); + } } DisableHamForward(g_hHamSpawn); } diff --git a/addons/amxmodx/scripting/map_manager_informer.sma b/addons/amxmodx/scripting/map_manager_informer.sma index bf365c3..bad820c 100644 --- a/addons/amxmodx/scripting/map_manager_informer.sma +++ b/addons/amxmodx/scripting/map_manager_informer.sma @@ -7,7 +7,7 @@ #endif #define PLUGIN "Map Manager: Informer" -#define VERSION "0.0.2" +#define VERSION "0.0.3" #define AUTHOR "Mistrick" #pragma semicolon 1 @@ -26,7 +26,7 @@ new g_pCvars[Cvars]; new g_iTeamScore[2]; new g_szCurMap[MAPNAME_LENGTH]; -new PREFIX[32]; +new g_sPrefix[48]; public plugin_init() { @@ -40,7 +40,6 @@ public plugin_init() register_event("TeamScore", "event_teamscore", "a"); get_mapname(g_szCurMap, charsmax(g_szCurMap)); - mapm_get_prefix(PREFIX, charsmax(PREFIX)); } public plugin_cfg() { @@ -49,6 +48,8 @@ public plugin_cfg() g_pCvars[MAXROUNDS] = get_cvar_pointer("mp_maxrounds"); g_pCvars[NEXTMAP] = get_cvar_pointer("amx_nextmap"); g_pCvars[EXTENDED_TYPE] = get_cvar_pointer("mapm_extended_type"); + + mapm_get_prefix(g_sPrefix, charsmax(g_sPrefix)); } public event_teamscore() { @@ -60,12 +61,12 @@ public clcmd_timeleft(id) new win_limit = get_num(WINLIMIT); new max_rounds = get_num(MAXROUNDS); + // TODO: need subtract left_wins/left_rounds if mapm_change_type 0 or 1 if((win_limit || max_rounds) && get_num(EXTENDED_TYPE) == EXTEND_ROUNDS) { new text[128], len; len = formatex(text, charsmax(text), "%L ", LANG_PLAYER, "MAPM_TIME_TO_END"); if(win_limit) { new left_wins = win_limit - max(g_iTeamScore[0], g_iTeamScore[1]); - // TODO: add to ML MAPM_WINS len += formatex(text[len], charsmax(text) - len, "%d %L", left_wins, LANG_PLAYER, "MAPM_WINS"); } if(win_limit && max_rounds) { @@ -73,20 +74,19 @@ public clcmd_timeleft(id) } if(max_rounds) { new left_rounds = max_rounds - g_iTeamScore[0] - g_iTeamScore[1]; - // TODO: add to ML MAPM_ROUNDS len += formatex(text[len], charsmax(text) - len, "%d %L", left_rounds, LANG_PLAYER, "MAPM_ROUNDS"); } - client_print_color(0, print_team_default, "%s^1 %s.", PREFIX, text); + client_print_color(0, print_team_default, "%s^1 %s.", g_sPrefix, text); } else { if (get_num(TIMELIMIT)) { new a = get_timeleft(); - client_print_color(0, id, "%s^1 %L:^3 %d:%02d", PREFIX, LANG_PLAYER, "MAPM_TIME_TO_END", (a / 60), (a % 60)); + client_print_color(0, id, "%s^1 %L:^3 %d:%02d", g_sPrefix, LANG_PLAYER, "MAPM_TIME_TO_END", (a / 60), (a % 60)); } else { if(is_vote_will_in_next_round()) { // TODO: add ML - client_print_color(0, print_team_default, "%s^1 Wait vote in next round.", PREFIX); + client_print_color(0, print_team_default, "%s^1 Wait vote in next round.", g_sPrefix); } else { - client_print_color(0, print_team_default, "%s^1 %L", PREFIX, LANG_PLAYER, "MAPM_NO_TIMELIMIT"); + client_print_color(0, print_team_default, "%s^1 %L", g_sPrefix, LANG_PLAYER, "MAPM_NO_TIMELIMIT"); } } } @@ -94,18 +94,18 @@ public clcmd_timeleft(id) public clcmd_thetime(id) { new curtime[64]; get_time("%Y/%m/%d - %H:%M:%S", curtime, charsmax(curtime)); - client_print_color(0, print_team_default, "%s^3 %L", PREFIX, LANG_PLAYER, "MAPM_THETIME", curtime); + client_print_color(0, print_team_default, "%s^3 %L", g_sPrefix, LANG_PLAYER, "MAPM_THETIME", curtime); } public clcmd_nextmap(id) { if(is_vote_finished()) { new map[MAPNAME_LENGTH]; get_pcvar_string(g_pCvars[NEXTMAP], map, charsmax(map)); - client_print_color(0, id, "%s^1 %L ^3%s^1.", PREFIX, LANG_PLAYER, "MAPM_NEXTMAP", map); + client_print_color(0, id, "%s^1 %L ^3%s^1.", g_sPrefix, LANG_PLAYER, "MAPM_NEXTMAP", map); } else { - client_print_color(0, id, "%s^1 %L ^3%L^1.", PREFIX, LANG_PLAYER, "MAPM_NEXTMAP", LANG_PLAYER, "MAPM_NOT_SELECTED"); + client_print_color(0, id, "%s^1 %L ^3%L^1.", g_sPrefix, LANG_PLAYER, "MAPM_NEXTMAP", LANG_PLAYER, "MAPM_NOT_SELECTED"); } } public clcmd_currentmap(id) { - client_print_color(0, id, "%s^1 %L", PREFIX, LANG_PLAYER, "MAPM_CURRENT_MAP", g_szCurMap); + client_print_color(0, id, "%s^1 %L", g_sPrefix, LANG_PLAYER, "MAPM_CURRENT_MAP", g_szCurMap); } diff --git a/addons/amxmodx/scripting/map_manager_nomination.sma b/addons/amxmodx/scripting/map_manager_nomination.sma index de11002..fae1231 100644 --- a/addons/amxmodx/scripting/map_manager_nomination.sma +++ b/addons/amxmodx/scripting/map_manager_nomination.sma @@ -7,7 +7,7 @@ #endif #define PLUGIN "Map Manager: Nomination" -#define VERSION "0.0.2" +#define VERSION "0.0.3" #define AUTHOR "Mistrick" #pragma semicolon 1 @@ -46,7 +46,7 @@ new g_hCallbackDisabled; new g_iNomMaps[33]; new g_iLastDenominate[33]; -new PREFIX[32]; +new g_sPrefix[48]; public plugin_init() { @@ -93,7 +93,7 @@ public mapm_maplist_loaded(Array:maplist) { g_aMapsList = maplist; g_aNomList = ArrayCreate(NomStruct, 1); - mapm_get_prefix(PREFIX, charsmax(PREFIX)); + mapm_get_prefix(g_sPrefix, charsmax(g_sPrefix)); } public client_disconnected(id) { @@ -140,13 +140,13 @@ nominate_map(id, map[], index) new map_info[MapStruct]; ArrayGetArray(g_aMapsList, index, map_info); if(mapm_get_blocked_count(map)) { - client_print_color(id, print_team_default, "%s^1 %L", PREFIX, id, "MAPM_NOM_NOT_AVAILABLE_MAP"); + client_print_color(id, print_team_default, "%s^1 %L", g_sPrefix, id, "MAPM_NOM_NOT_AVAILABLE_MAP"); return NOMINATION_FAIL; } if(get_num(TYPE) == TYPE_FIXED && ArraySize(g_aNomList) >= get_num(MAPS_IN_VOTE)) { // TODO: add ML - client_print_color(id, print_team_default, "%s^1 All nomination slots are reserved.", PREFIX); + client_print_color(id, print_team_default, "%s^1 All nomination slots are reserved.", g_sPrefix); return NOMINATION_FAIL; } @@ -157,13 +157,13 @@ nominate_map(id, map[], index) if(nom_index != INVALID_MAP_INDEX) { ArrayGetArray(g_aNomList, nom_index, nom_info); if(id != nom_info[NomPlayer]) { - client_print_color(id, print_team_default, "%s^1 %L", PREFIX, id, "MAPM_NOM_ALREADY_NOM"); + client_print_color(id, print_team_default, "%s^1 %L", g_sPrefix, id, "MAPM_NOM_ALREADY_NOM"); return NOMINATION_FAIL; } new systime = get_systime(); if(g_iLastDenominate[id] + get_num(DENOMINATE_TIME) >= systime) { - client_print_color(id, print_team_default, "%s^1 %L", PREFIX, id, "MAPM_NOM_SPAM"); + client_print_color(id, print_team_default, "%s^1 %L", g_sPrefix, id, "MAPM_NOM_SPAM"); return NOMINATION_FAIL; } @@ -171,12 +171,12 @@ nominate_map(id, map[], index) g_iNomMaps[id]--; ArrayDeleteItem(g_aNomList, nom_index); - client_print_color(0, id, "%s^3 %L", PREFIX, LANG_PLAYER, "MAPM_NOM_REMOVE_NOM", name, map); + client_print_color(0, id, "%s^3 %L", g_sPrefix, LANG_PLAYER, "MAPM_NOM_REMOVE_NOM", name, map); return NOMINATION_REMOVED; } if(g_iNomMaps[id] >= get_num(MAPS_PER_PLAYER)) { - client_print_color(id, print_team_default, "%s^1 %L", PREFIX, id, "MAPM_NOM_CANT_NOM"); + client_print_color(id, print_team_default, "%s^1 %L", g_sPrefix, id, "MAPM_NOM_CANT_NOM"); return NOMINATION_FAIL; } @@ -186,7 +186,7 @@ nominate_map(id, map[], index) g_iNomMaps[id]++; - client_print_color(0, id, "%s^3 %L", PREFIX, LANG_PLAYER, "MAPM_NOM_MAP", name, map); + client_print_color(0, id, "%s^3 %L", g_sPrefix, LANG_PLAYER, "MAPM_NOM_MAP", name, map); return NOMINATION_SUCCESS; } diff --git a/addons/amxmodx/scripting/map_manager_rtv.sma b/addons/amxmodx/scripting/map_manager_rtv.sma index 13bbe5a..c0103bc 100644 --- a/addons/amxmodx/scripting/map_manager_rtv.sma +++ b/addons/amxmodx/scripting/map_manager_rtv.sma @@ -7,7 +7,7 @@ #endif #define PLUGIN "Map Manager: Rtv" -#define VERSION "0.0.1" +#define VERSION "0.0.2" #define AUTHOR "Mistrick" #pragma semicolon 1 @@ -37,7 +37,7 @@ new g_iMapStartTime; new bool:g_bVoted[33]; new g_iVotes; -new PREFIX[32]; +new g_sPrefix[48]; public plugin_init() { @@ -55,8 +55,10 @@ public plugin_init() // reset it with sv_restart? g_iMapStartTime = get_systime(); - - mapm_get_prefix(PREFIX, charsmax(PREFIX)); +} +public plugin_cfg() +{ + mapm_get_prefix(g_sPrefix, charsmax(g_sPrefix)); } public client_disconnected(id) { @@ -74,7 +76,7 @@ public clcmd_rtv(id) new delay = get_num(DELAY) * 60 - (get_systime() - g_iMapStartTime); if(delay > 0) { - client_print_color(id, print_team_default, "%s^1 %L", PREFIX, id, "MAPM_RTV_DELAY", delay / 60, delay % 60); + client_print_color(id, print_team_default, "%s^1 %L", g_sPrefix, id, "MAPM_RTV_DELAY", delay / 60, delay % 60); return PLUGIN_HANDLED; } @@ -97,9 +99,9 @@ public clcmd_rtv(id) if(!g_bVoted[id]) { g_bVoted[id] = true; new name[32]; get_user_name(id, name, charsmax(name)); - client_print_color(0, print_team_default, "%s^3 %L.", PREFIX, LANG_PLAYER, "MAPM_RTV_VOTED", name, need_votes); + client_print_color(0, print_team_default, "%s^3 %L.", g_sPrefix, LANG_PLAYER, "MAPM_RTV_VOTED", name, need_votes); } else { - client_print_color(id, print_team_default, "%s^1 %L.", PREFIX, id, "MAPM_RTV_ALREADY_VOTED", need_votes); + client_print_color(id, print_team_default, "%s^1 %L.", g_sPrefix, id, "MAPM_RTV_ALREADY_VOTED", need_votes); } return PLUGIN_HANDLED;