Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
di57inct opened this issue Feb 19, 2024 · 0 comments

Comments

@di57inct
Copy link

di57inct commented Feb 19, 2024

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;
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant