Skip to content

[Suggestion] Reset map extended timelimit and count on new round after game commence or sv_restart #53

Description

@di57inct

If server gets empty or players join after plugin auto extends map because of no votes based on the settings, they will play a 45 or 60 instead of the regular 30 minute map for example.
Adding the following in map_manager_scheduler should do the trick(tested and working):
In plugin_init(), uncomment already existing code:
register_event("TextMsg", "event_restart", "a", "2=#Game_Commencing", "2=#Game_will_restart_in");
Add in the triggered forward:

public event_restart()
{
/*	if(get_num(RESTORE_MAP_LIMITS)) {
		restore_limits();
	}
	*/
	if (get_float(TIMELIMIT) * 60 - get_timeleft() <= 1)
		plugin_end();
}

...where plugin_end() contains restoring original values code:

public plugin_end()
{
	if(g_fOldTimeLimit > 0.0) {
		set_float(TIMELIMIT, g_fOldTimeLimit);
	}
	restore_limits();
}

restore_limits()
{
	if(g_iExtendedNum) {
		if(get_num(EXTENDED_TYPE) == EXTEND_ROUNDS) {
			new win_limit = get_num(WINLIMIT);
			if(win_limit) {
				set_pcvar_num(g_pCvars[WINLIMIT], win_limit - g_iExtendedNum * get_num(EXTENDED_ROUNDS));
			}
			new max_rounds = get_num(MAXROUNDS);
			if(max_rounds) {
				set_pcvar_num(g_pCvars[MAXROUNDS], max_rounds - g_iExtendedNum * get_num(EXTENDED_ROUNDS));
			}
		} else {
			new Float:timelimit = get_float(TIMELIMIT);
			if(timelimit) {
				new Float:restored_value = timelimit - float(g_iExtendedNum * get_num(EXTENDED_TIME));
				set_float(TIMELIMIT, restored_value);
			}
		}
		g_iExtendedNum = 0;
	}
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions