Skip to content

Commit 7281bf9

Browse files
committed
refactor for prefix cvar
1 parent bd62156 commit 7281bf9

File tree

4 files changed

+41
-33
lines changed

4 files changed

+41
-33
lines changed

addons/amxmodx/scripting/map_manager_effects.sma

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <map_manager>
55

66
#define PLUGIN "Map Manager: Effects"
7-
#define VERSION "0.0.3"
7+
#define VERSION "0.0.4"
88
#define AUTHOR "Mistrick"
99

1010
#pragma semicolon 1
@@ -27,7 +27,9 @@ enum Cvars {
2727
FREEZETIME,
2828
VOTE_IN_NEW_ROUND,
2929
PREPARE_TIME,
30-
VOTE_TIME
30+
VOTE_TIME,
31+
CHANGE_TYPE,
32+
LAST_ROUND
3133
};
3234

3335
enum {
@@ -70,6 +72,8 @@ public plugin_cfg()
7072
g_pCvars[VOTE_IN_NEW_ROUND] = get_cvar_pointer("mapm_vote_in_new_round");
7173
g_pCvars[PREPARE_TIME] = get_cvar_pointer("mapm_prepare_time");
7274
g_pCvars[VOTE_TIME] = get_cvar_pointer("mapm_vote_time");
75+
g_pCvars[CHANGE_TYPE] = get_cvar_pointer("mapm_change_type");
76+
g_pCvars[LAST_ROUND] = get_cvar_pointer("mapm_last_round");
7377
}
7478
}
7579
public plugin_end()
@@ -158,7 +162,9 @@ public mapm_vote_finished(map[], type, total_votes)
158162
g_bFreezetimeChanged = false;
159163
set_float(FREEZETIME, get_float(FREEZETIME) - get_float(PREPARE_TIME) - get_float(VOTE_TIME) - 1);
160164
}
161-
freeze_unfreeze(1);
165+
if(get_num(CHANGE_TYPE) || get_num(LAST_ROUND)) {
166+
freeze_unfreeze(1);
167+
}
162168
}
163169
DisableHamForward(g_hHamSpawn);
164170
}

addons/amxmodx/scripting/map_manager_informer.sma

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#endif
88

99
#define PLUGIN "Map Manager: Informer"
10-
#define VERSION "0.0.2"
10+
#define VERSION "0.0.3"
1111
#define AUTHOR "Mistrick"
1212

1313
#pragma semicolon 1
@@ -26,7 +26,7 @@ new g_pCvars[Cvars];
2626

2727
new g_iTeamScore[2];
2828
new g_szCurMap[MAPNAME_LENGTH];
29-
new PREFIX[32];
29+
new g_sPrefix[48];
3030

3131
public plugin_init()
3232
{
@@ -40,7 +40,6 @@ public plugin_init()
4040
register_event("TeamScore", "event_teamscore", "a");
4141

4242
get_mapname(g_szCurMap, charsmax(g_szCurMap));
43-
mapm_get_prefix(PREFIX, charsmax(PREFIX));
4443
}
4544
public plugin_cfg()
4645
{
@@ -49,6 +48,8 @@ public plugin_cfg()
4948
g_pCvars[MAXROUNDS] = get_cvar_pointer("mp_maxrounds");
5049
g_pCvars[NEXTMAP] = get_cvar_pointer("amx_nextmap");
5150
g_pCvars[EXTENDED_TYPE] = get_cvar_pointer("mapm_extended_type");
51+
52+
mapm_get_prefix(g_sPrefix, charsmax(g_sPrefix));
5253
}
5354
public event_teamscore()
5455
{
@@ -60,52 +61,51 @@ public clcmd_timeleft(id)
6061
new win_limit = get_num(WINLIMIT);
6162
new max_rounds = get_num(MAXROUNDS);
6263

64+
// TODO: need subtract left_wins/left_rounds if mapm_change_type 0 or 1
6365
if((win_limit || max_rounds) && get_num(EXTENDED_TYPE) == EXTEND_ROUNDS) {
6466
new text[128], len;
6567
len = formatex(text, charsmax(text), "%L ", LANG_PLAYER, "MAPM_TIME_TO_END");
6668
if(win_limit) {
6769
new left_wins = win_limit - max(g_iTeamScore[0], g_iTeamScore[1]);
68-
// TODO: add to ML MAPM_WINS
6970
len += formatex(text[len], charsmax(text) - len, "%d %L", left_wins, LANG_PLAYER, "MAPM_WINS");
7071
}
7172
if(win_limit && max_rounds) {
7273
len += formatex(text[len], charsmax(text) - len, " %L ", LANG_PLAYER, "MAPM_TIMELEFT_OR");
7374
}
7475
if(max_rounds) {
7576
new left_rounds = max_rounds - g_iTeamScore[0] - g_iTeamScore[1];
76-
// TODO: add to ML MAPM_ROUNDS
7777
len += formatex(text[len], charsmax(text) - len, "%d %L", left_rounds, LANG_PLAYER, "MAPM_ROUNDS");
7878
}
79-
client_print_color(0, print_team_default, "%s^1 %s.", PREFIX, text);
79+
client_print_color(0, print_team_default, "%s^1 %s.", g_sPrefix, text);
8080
} else {
8181
if (get_num(TIMELIMIT)) {
8282
new a = get_timeleft();
83-
client_print_color(0, id, "%s^1 %L:^3 %d:%02d", PREFIX, LANG_PLAYER, "MAPM_TIME_TO_END", (a / 60), (a % 60));
83+
client_print_color(0, id, "%s^1 %L:^3 %d:%02d", g_sPrefix, LANG_PLAYER, "MAPM_TIME_TO_END", (a / 60), (a % 60));
8484
} else {
8585
if(is_vote_will_in_next_round()) {
8686
// TODO: add ML
87-
client_print_color(0, print_team_default, "%s^1 Wait vote in next round.", PREFIX);
87+
client_print_color(0, print_team_default, "%s^1 Wait vote in next round.", g_sPrefix);
8888
} else {
89-
client_print_color(0, print_team_default, "%s^1 %L", PREFIX, LANG_PLAYER, "MAPM_NO_TIMELIMIT");
89+
client_print_color(0, print_team_default, "%s^1 %L", g_sPrefix, LANG_PLAYER, "MAPM_NO_TIMELIMIT");
9090
}
9191
}
9292
}
9393
}
9494
public clcmd_thetime(id)
9595
{
9696
new curtime[64]; get_time("%Y/%m/%d - %H:%M:%S", curtime, charsmax(curtime));
97-
client_print_color(0, print_team_default, "%s^3 %L", PREFIX, LANG_PLAYER, "MAPM_THETIME", curtime);
97+
client_print_color(0, print_team_default, "%s^3 %L", g_sPrefix, LANG_PLAYER, "MAPM_THETIME", curtime);
9898
}
9999
public clcmd_nextmap(id)
100100
{
101101
if(is_vote_finished()) {
102102
new map[MAPNAME_LENGTH]; get_pcvar_string(g_pCvars[NEXTMAP], map, charsmax(map));
103-
client_print_color(0, id, "%s^1 %L ^3%s^1.", PREFIX, LANG_PLAYER, "MAPM_NEXTMAP", map);
103+
client_print_color(0, id, "%s^1 %L ^3%s^1.", g_sPrefix, LANG_PLAYER, "MAPM_NEXTMAP", map);
104104
} else {
105-
client_print_color(0, id, "%s^1 %L ^3%L^1.", PREFIX, LANG_PLAYER, "MAPM_NEXTMAP", LANG_PLAYER, "MAPM_NOT_SELECTED");
105+
client_print_color(0, id, "%s^1 %L ^3%L^1.", g_sPrefix, LANG_PLAYER, "MAPM_NEXTMAP", LANG_PLAYER, "MAPM_NOT_SELECTED");
106106
}
107107
}
108108
public clcmd_currentmap(id)
109109
{
110-
client_print_color(0, id, "%s^1 %L", PREFIX, LANG_PLAYER, "MAPM_CURRENT_MAP", g_szCurMap);
110+
client_print_color(0, id, "%s^1 %L", g_sPrefix, LANG_PLAYER, "MAPM_CURRENT_MAP", g_szCurMap);
111111
}

addons/amxmodx/scripting/map_manager_nomination.sma

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#endif
88

99
#define PLUGIN "Map Manager: Nomination"
10-
#define VERSION "0.0.2"
10+
#define VERSION "0.0.3"
1111
#define AUTHOR "Mistrick"
1212

1313
#pragma semicolon 1
@@ -46,7 +46,7 @@ new g_hCallbackDisabled;
4646
new g_iNomMaps[33];
4747
new g_iLastDenominate[33];
4848

49-
new PREFIX[32];
49+
new g_sPrefix[48];
5050

5151
public plugin_init()
5252
{
@@ -93,7 +93,7 @@ public mapm_maplist_loaded(Array:maplist)
9393
{
9494
g_aMapsList = maplist;
9595
g_aNomList = ArrayCreate(NomStruct, 1);
96-
mapm_get_prefix(PREFIX, charsmax(PREFIX));
96+
mapm_get_prefix(g_sPrefix, charsmax(g_sPrefix));
9797
}
9898
public client_disconnected(id)
9999
{
@@ -140,13 +140,13 @@ nominate_map(id, map[], index)
140140
new map_info[MapStruct]; ArrayGetArray(g_aMapsList, index, map_info);
141141

142142
if(mapm_get_blocked_count(map)) {
143-
client_print_color(id, print_team_default, "%s^1 %L", PREFIX, id, "MAPM_NOM_NOT_AVAILABLE_MAP");
143+
client_print_color(id, print_team_default, "%s^1 %L", g_sPrefix, id, "MAPM_NOM_NOT_AVAILABLE_MAP");
144144
return NOMINATION_FAIL;
145145
}
146146

147147
if(get_num(TYPE) == TYPE_FIXED && ArraySize(g_aNomList) >= get_num(MAPS_IN_VOTE)) {
148148
// TODO: add ML
149-
client_print_color(id, print_team_default, "%s^1 All nomination slots are reserved.", PREFIX);
149+
client_print_color(id, print_team_default, "%s^1 All nomination slots are reserved.", g_sPrefix);
150150
return NOMINATION_FAIL;
151151
}
152152

@@ -157,26 +157,26 @@ nominate_map(id, map[], index)
157157
if(nom_index != INVALID_MAP_INDEX) {
158158
ArrayGetArray(g_aNomList, nom_index, nom_info);
159159
if(id != nom_info[NomPlayer]) {
160-
client_print_color(id, print_team_default, "%s^1 %L", PREFIX, id, "MAPM_NOM_ALREADY_NOM");
160+
client_print_color(id, print_team_default, "%s^1 %L", g_sPrefix, id, "MAPM_NOM_ALREADY_NOM");
161161
return NOMINATION_FAIL;
162162
}
163163

164164
new systime = get_systime();
165165
if(g_iLastDenominate[id] + get_num(DENOMINATE_TIME) >= systime) {
166-
client_print_color(id, print_team_default, "%s^1 %L", PREFIX, id, "MAPM_NOM_SPAM");
166+
client_print_color(id, print_team_default, "%s^1 %L", g_sPrefix, id, "MAPM_NOM_SPAM");
167167
return NOMINATION_FAIL;
168168
}
169169

170170
g_iLastDenominate[id] = systime;
171171
g_iNomMaps[id]--;
172172
ArrayDeleteItem(g_aNomList, nom_index);
173173

174-
client_print_color(0, id, "%s^3 %L", PREFIX, LANG_PLAYER, "MAPM_NOM_REMOVE_NOM", name, map);
174+
client_print_color(0, id, "%s^3 %L", g_sPrefix, LANG_PLAYER, "MAPM_NOM_REMOVE_NOM", name, map);
175175
return NOMINATION_REMOVED;
176176
}
177177

178178
if(g_iNomMaps[id] >= get_num(MAPS_PER_PLAYER)) {
179-
client_print_color(id, print_team_default, "%s^1 %L", PREFIX, id, "MAPM_NOM_CANT_NOM");
179+
client_print_color(id, print_team_default, "%s^1 %L", g_sPrefix, id, "MAPM_NOM_CANT_NOM");
180180
return NOMINATION_FAIL;
181181
}
182182

@@ -186,7 +186,7 @@ nominate_map(id, map[], index)
186186

187187
g_iNomMaps[id]++;
188188

189-
client_print_color(0, id, "%s^3 %L", PREFIX, LANG_PLAYER, "MAPM_NOM_MAP", name, map);
189+
client_print_color(0, id, "%s^3 %L", g_sPrefix, LANG_PLAYER, "MAPM_NOM_MAP", name, map);
190190

191191
return NOMINATION_SUCCESS;
192192
}

addons/amxmodx/scripting/map_manager_rtv.sma

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#endif
88

99
#define PLUGIN "Map Manager: Rtv"
10-
#define VERSION "0.0.1"
10+
#define VERSION "0.0.2"
1111
#define AUTHOR "Mistrick"
1212

1313
#pragma semicolon 1
@@ -37,7 +37,7 @@ new g_iMapStartTime;
3737
new bool:g_bVoted[33];
3838
new g_iVotes;
3939

40-
new PREFIX[32];
40+
new g_sPrefix[48];
4141

4242
public plugin_init()
4343
{
@@ -55,8 +55,10 @@ public plugin_init()
5555

5656
// reset it with sv_restart?
5757
g_iMapStartTime = get_systime();
58-
59-
mapm_get_prefix(PREFIX, charsmax(PREFIX));
58+
}
59+
public plugin_cfg()
60+
{
61+
mapm_get_prefix(g_sPrefix, charsmax(g_sPrefix));
6062
}
6163
public client_disconnected(id)
6264
{
@@ -74,7 +76,7 @@ public clcmd_rtv(id)
7476

7577
new delay = get_num(DELAY) * 60 - (get_systime() - g_iMapStartTime);
7678
if(delay > 0) {
77-
client_print_color(id, print_team_default, "%s^1 %L", PREFIX, id, "MAPM_RTV_DELAY", delay / 60, delay % 60);
79+
client_print_color(id, print_team_default, "%s^1 %L", g_sPrefix, id, "MAPM_RTV_DELAY", delay / 60, delay % 60);
7880
return PLUGIN_HANDLED;
7981
}
8082

@@ -97,9 +99,9 @@ public clcmd_rtv(id)
9799
if(!g_bVoted[id]) {
98100
g_bVoted[id] = true;
99101
new name[32]; get_user_name(id, name, charsmax(name));
100-
client_print_color(0, print_team_default, "%s^3 %L.", PREFIX, LANG_PLAYER, "MAPM_RTV_VOTED", name, need_votes);
102+
client_print_color(0, print_team_default, "%s^3 %L.", g_sPrefix, LANG_PLAYER, "MAPM_RTV_VOTED", name, need_votes);
101103
} else {
102-
client_print_color(id, print_team_default, "%s^1 %L.", PREFIX, id, "MAPM_RTV_ALREADY_VOTED", need_votes);
104+
client_print_color(id, print_team_default, "%s^1 %L.", g_sPrefix, id, "MAPM_RTV_ALREADY_VOTED", need_votes);
103105
}
104106

105107
return PLUGIN_HANDLED;

0 commit comments

Comments
 (0)