Skip to content

Commit

Permalink
scheduler: add native map_scheduler_stop_vote
Browse files Browse the repository at this point in the history
  • Loading branch information
Mistrick committed Nov 2, 2023
1 parent ce9f2bf commit 959c5da
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
13 changes: 10 additions & 3 deletions cstrike/addons/amxmodx/scripting/include/map_manager_scheduler.inc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ native IgnoreFlags:map_scheduler_get_ignore_check();

/**
* Set ignore flags for starting vote.
*
*
* @param flags Flags from IgnoreFlags enum
*
* @noreturn
Expand All @@ -43,16 +43,23 @@ native map_scheduler_set_ignore_check(IgnoreFlags:flags);

/**
* Start vote by scheduler, work with own cvars.
*
*
* @param type Type of vote, used const VOTE_BY_*
*
* @noreturn
*/
native map_scheduler_start_vote(type);

/**
* Stop vote by scheduler.
*
* @noreturn
*/
native map_scheduler_stop_vote();

/**
* Extend current map time.
*
*
* @param count Extend time param, bonus time = count * cvarnum(extend_time)
*
* @noreturn
Expand Down
26 changes: 23 additions & 3 deletions cstrike/addons/amxmodx/scripting/map_manager_scheduler.sma
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#endif

#define PLUGIN "Map Manager: Scheduler"
#define VERSION "0.2.2"
#define VERSION "0.2.3"
#define AUTHOR "Mistrick"

#pragma semicolon 1
Expand Down Expand Up @@ -146,6 +146,7 @@ public plugin_natives()
register_native("map_scheduler_get_ignore_check", "native_get_ignore_check");
register_native("map_scheduler_set_ignore_check", "native_set_ignore_check");
register_native("map_scheduler_start_vote", "native_start_vote");
register_native("map_scheduler_stop_vote", "native_stop_vote");
register_native("map_scheduler_extend_map", "native_extend_map");
register_native("is_vote_will_in_next_round", "native_vote_will_in_next_round");
register_native("get_last_round_state", "native_get_last_round_state");
Expand Down Expand Up @@ -189,11 +190,22 @@ public native_start_vote(plugin, params)

return 1;
}
public native_stop_vote(plugin, params)
{
if(!is_vote_started()) {
return 0;
}

stop_vote();

return 1;
}
public native_extend_map(plugin, params)
{
enum { arg_count = 1 };
new count = get_param(arg_count);
g_iExtendedNum += count;
// TODO: rounds support?
set_float(TIMELIMIT, get_float(TIMELIMIT) + float(get_num(EXTENDED_TIME)) * float(count));
return 1;
}
Expand Down Expand Up @@ -257,13 +269,23 @@ public concmd_startvote(id, level, cid)
}
public concmd_stopvote(id, level, cid)
{
if(!is_vote_started()) {
return PLUGIN_HANDLED;
}

if(!cmd_access(id, level, cid, 1)) {
return PLUGIN_HANDLED;
}

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

stop_vote();

return PLUGIN_HANDLED;
}
stop_vote()
{
mapm_stop_vote();

if(mapm_get_vote_type() == VOTE_BY_SCHEDULER_SECOND) {
Expand All @@ -277,8 +299,6 @@ public concmd_stopvote(id, level, cid)
set_float(TIMELIMIT, g_fOldTimeLimit);
}
}

return PLUGIN_HANDLED;
}
public clcmd_votemap()
{
Expand Down

0 comments on commit 959c5da

Please sign in to comment.