Skip to content

Commit 959c5da

Browse files
committed
scheduler: add native map_scheduler_stop_vote
1 parent ce9f2bf commit 959c5da

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

cstrike/addons/amxmodx/scripting/include/map_manager_scheduler.inc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ native IgnoreFlags:map_scheduler_get_ignore_check();
3434

3535
/**
3636
* Set ignore flags for starting vote.
37-
*
37+
*
3838
* @param flags Flags from IgnoreFlags enum
3939
*
4040
* @noreturn
@@ -43,16 +43,23 @@ native map_scheduler_set_ignore_check(IgnoreFlags:flags);
4343

4444
/**
4545
* Start vote by scheduler, work with own cvars.
46-
*
46+
*
4747
* @param type Type of vote, used const VOTE_BY_*
4848
*
4949
* @noreturn
5050
*/
5151
native map_scheduler_start_vote(type);
5252

53+
/**
54+
* Stop vote by scheduler.
55+
*
56+
* @noreturn
57+
*/
58+
native map_scheduler_stop_vote();
59+
5360
/**
5461
* Extend current map time.
55-
*
62+
*
5663
* @param count Extend time param, bonus time = count * cvarnum(extend_time)
5764
*
5865
* @noreturn

cstrike/addons/amxmodx/scripting/map_manager_scheduler.sma

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#endif
1010

1111
#define PLUGIN "Map Manager: Scheduler"
12-
#define VERSION "0.2.2"
12+
#define VERSION "0.2.3"
1313
#define AUTHOR "Mistrick"
1414

1515
#pragma semicolon 1
@@ -146,6 +146,7 @@ public plugin_natives()
146146
register_native("map_scheduler_get_ignore_check", "native_get_ignore_check");
147147
register_native("map_scheduler_set_ignore_check", "native_set_ignore_check");
148148
register_native("map_scheduler_start_vote", "native_start_vote");
149+
register_native("map_scheduler_stop_vote", "native_stop_vote");
149150
register_native("map_scheduler_extend_map", "native_extend_map");
150151
register_native("is_vote_will_in_next_round", "native_vote_will_in_next_round");
151152
register_native("get_last_round_state", "native_get_last_round_state");
@@ -189,11 +190,22 @@ public native_start_vote(plugin, params)
189190

190191
return 1;
191192
}
193+
public native_stop_vote(plugin, params)
194+
{
195+
if(!is_vote_started()) {
196+
return 0;
197+
}
198+
199+
stop_vote();
200+
201+
return 1;
202+
}
192203
public native_extend_map(plugin, params)
193204
{
194205
enum { arg_count = 1 };
195206
new count = get_param(arg_count);
196207
g_iExtendedNum += count;
208+
// TODO: rounds support?
197209
set_float(TIMELIMIT, get_float(TIMELIMIT) + float(get_num(EXTENDED_TIME)) * float(count));
198210
return 1;
199211
}
@@ -257,13 +269,23 @@ public concmd_startvote(id, level, cid)
257269
}
258270
public concmd_stopvote(id, level, cid)
259271
{
272+
if(!is_vote_started()) {
273+
return PLUGIN_HANDLED;
274+
}
275+
260276
if(!cmd_access(id, level, cid, 1)) {
261277
return PLUGIN_HANDLED;
262278
}
263279

264280
new name[32]; get_user_name(id, name, charsmax(name));
265281
log_amx("%s stopped vote", id ? name : "Server");
266282

283+
stop_vote();
284+
285+
return PLUGIN_HANDLED;
286+
}
287+
stop_vote()
288+
{
267289
mapm_stop_vote();
268290

269291
if(mapm_get_vote_type() == VOTE_BY_SCHEDULER_SECOND) {
@@ -277,8 +299,6 @@ public concmd_stopvote(id, level, cid)
277299
set_float(TIMELIMIT, g_fOldTimeLimit);
278300
}
279301
}
280-
281-
return PLUGIN_HANDLED;
282302
}
283303
public clcmd_votemap()
284304
{

0 commit comments

Comments
 (0)