Skip to content

Commit 4bf32ed

Browse files
committed
core: set nextmap in maps load
move cmd mapm_start_vote for scheduler hide some debug info scheduler: added cmd mapm_stop_vote
1 parent bd6a5f8 commit 4bf32ed

4 files changed

Lines changed: 49 additions & 28 deletions

File tree

map_manager_blocklist.sma

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ load_blocklist()
7575
temp = fopen(temp_file_path, "wt");
7676

7777
new buffer[40], map[MAPNAME_LENGTH], str_count[6], count;
78-
server_print("Blocked list:^n%s", cur_map);
78+
// server_print("Blocked list:^n%s", cur_map);
7979
while(!feof(f)) {
8080
fgets(f, buffer, charsmax(buffer));
8181
parse(buffer, map, charsmax(map), str_count, charsmax(str_count));
@@ -89,7 +89,7 @@ load_blocklist()
8989

9090
fprintf(temp, "^"%s^" ^"%d^"^n", map, count);
9191
TrieSetCell(g_tBlockedList, map, count);
92-
server_print("%s", map);
92+
// server_print("%s", map);
9393
}
9494

9595
fprintf(temp, "^"%s^" ^"%d^"^n", cur_map, BLOCK_MAP_COUNT);

map_manager_core.sma

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
- start/stop vote
66
*/
77
#include <amxmodx>
8-
#include <amxmisc>
98
#include <map_manager_consts>
109
#include <map_manager_stocks>
1110

@@ -102,8 +101,6 @@ public plugin_init()
102101
g_pCvars[PREPARE_TIME] = register_cvar("mapm_prepare_time", "5"); // seconds
103102
g_pCvars[VOTE_TIME] = register_cvar("mapm_vote_time", "10"); // seconds
104103

105-
register_concmd("mapm_start_vote", "concmd_startvote", ADMIN_MAP);
106-
107104
g_hForwards[MAPLIST_LOADED] = CreateMultiForward("mapm_maplist_loaded", ET_IGNORE, FP_CELL);
108105
g_hForwards[PREPARE_VOTELIST] = CreateMultiForward("mapm_prepare_votelist", ET_IGNORE, FP_CELL);
109106
g_hForwards[VOTE_STARTED] = CreateMultiForward("mapm_vote_started", ET_IGNORE, FP_CELL);
@@ -253,7 +250,7 @@ load_maplist(const file[])
253250
set_fail_state("Can't read maps file.");
254251
}
255252

256-
new map_info[MapStruct], text[48], map[MAPNAME_LENGTH], min[3], max[3];
253+
new map_info[MapStruct], text[48], map[MAPNAME_LENGTH], min[3], max[3], bool:nextmap;
257254
new cur_map[MAPNAME_LENGTH]; get_mapname(cur_map, charsmax(cur_map));
258255

259256
while(!feof(f)) {
@@ -263,8 +260,13 @@ load_maplist(const file[])
263260
if(!map[0] || map[0] == ';' || !valid_map(map) || get_map_index(map) != INVALID_MAP_INDEX) continue;
264261

265262
if(equali(map, cur_map)) {
263+
nextmap = true;
266264
continue;
267265
}
266+
if(nextmap) {
267+
nextmap = false;
268+
set_cvar_string("amx_nextmap", map);
269+
}
268270

269271
map_info[MapName] = map;
270272
map_info[MinPlayers] = str_to_num(min);
@@ -285,21 +287,6 @@ load_maplist(const file[])
285287
ExecuteForward(g_hForwards[MAPLIST_LOADED], ret, g_aMapsList);
286288
}
287289
//-----------------------------------------------------//
288-
// Commands stuff
289-
//-----------------------------------------------------//
290-
public concmd_startvote(id, level, cid)
291-
{
292-
if(!cmd_access(id, level, cid, 1)) {
293-
return PLUGIN_HANDLED;
294-
}
295-
296-
if(!prepare_vote(VOTE_BY_CMD)) {
297-
// write vote already started
298-
}
299-
300-
return PLUGIN_HANDLED;
301-
}
302-
//-----------------------------------------------------//
303290
// Vote stuff
304291
//-----------------------------------------------------//
305292
prepare_vote(type)
@@ -308,7 +295,7 @@ prepare_vote(type)
308295
return 0;
309296
}
310297

311-
server_print("--prepare vote--");
298+
// server_print("--prepare vote--");
312299

313300
g_bVoteStarted = true;
314301
g_bVoteFinished = false;
@@ -343,12 +330,12 @@ prepare_vote(type)
343330
}
344331
}
345332

346-
server_print("Votelist:");
333+
/* server_print("Votelist:");
347334
for(new i; i < g_iVoteItems; i++) {
348335
if(g_sVoteList[i][0]) {
349336
server_print("%d - %s", i + 1, g_sVoteList[i]);
350337
}
351-
}
338+
} */
352339

353340
ExecuteForward(g_hForwards[CAN_BE_EXTENDED], ret, type);
354341
g_bCanExtend = !ret;
@@ -447,7 +434,7 @@ public countdown(taskid)
447434
}
448435
start_vote()
449436
{
450-
server_print("--start vote--");
437+
// server_print("--start vote--");
451438

452439
new ret;
453440
ExecuteForward(g_hForwards[VOTE_STARTED], ret, g_iVoteType);
@@ -532,7 +519,7 @@ finish_vote()
532519
g_bVoteStarted = false;
533520

534521
// vote results
535-
server_print("--finish vote--");
522+
// server_print("--finish vote--");
536523

537524
// pre forward
538525
new ret;

map_manager_online_sorter.sma

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ public mapm_prepare_votelist(type)
3838
new Array:array = ArrayCreate(MAPNAME_LENGTH, 1);
3939
new map_info[MapStruct], size = ArraySize(g_aMapsList);
4040

41-
server_print("Found maps for current online:");
41+
// server_print("Found maps for current online:");
4242
for(new i; i < size; i++) {
4343
ArrayGetArray(g_aMapsList, i, map_info);
4444
if(map_info[MinPlayers] <= players_num <= map_info[MaxPlayers]) {
4545
ArrayPushString(array, map_info[MapName]);
46-
server_print("%d - %s", ArraySize(array), map_info[MapName]);
46+
// server_print("%d - %s", ArraySize(array), map_info[MapName]);
4747
}
4848
}
4949

map_manager_scheduler.sma

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <amxmodx>
2+
#include <amxmisc>
23
#include <map_manager>
34

45
#if AMXX_VERSION_NUM < 183
@@ -88,6 +89,9 @@ public plugin_init()
8889

8990
g_pCvars[NEXTMAP] = register_cvar("amx_nextmap", "", FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY);
9091

92+
register_concmd("mapm_start_vote", "concmd_startvote", ADMIN_MAP);
93+
register_concmd("mapm_stop_vote", "concmd_stopvote", ADMIN_MAP);
94+
9195
register_event("TeamScore", "event_teamscore", "a");
9296
register_event("HLTV", "event_newround", "a", "1=0", "2=0");
9397
// register_event("TextMsg", "event_restart", "a", "2=#Game_Commencing", "2=#Game_will_restart_in");
@@ -143,6 +147,36 @@ restore_limits()
143147
g_iExtendedNum = 0;
144148
}
145149
}
150+
public concmd_startvote(id, level, cid)
151+
{
152+
if(!cmd_access(id, level, cid, 1)) {
153+
return PLUGIN_HANDLED;
154+
}
155+
156+
// TODO: add logging
157+
planning_vote(VOTE_BY_CMD);
158+
159+
return PLUGIN_HANDLED;
160+
}
161+
public concmd_stopvote(id, level, cid)
162+
{
163+
if(!cmd_access(id, level, cid, 1)) {
164+
return PLUGIN_HANDLED;
165+
}
166+
167+
// TODO: add logging
168+
mapm_stop_vote();
169+
170+
if(g_bVoteInNewRound) {
171+
g_bVoteInNewRound = false;
172+
173+
if(g_fOldTimeLimit > 0.0) {
174+
set_float(TIMELIMIT, g_fOldTimeLimit);
175+
}
176+
}
177+
178+
return PLUGIN_HANDLED;
179+
}
146180
public task_checktime()
147181
{
148182
if(is_vote_started() || is_vote_finished() || get_float(TIMELIMIT) <= 0.0) {

0 commit comments

Comments
 (0)