Raised This Month: $51 Target: $400
 12% 

Timeleft


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Architect
New Member
Join Date: Mar 2020
Old 03-27-2020 , 08:13   Timeleft
Reply With Quote #1

What does this code do?
Code:
void OnConfigsExecuted_TimeLimit()
{
	CreateTimer(1.0, Timer_TimeLimit, _, TIMER_REPEAT);
}

public Action Timer_TimeLimit(Handle timer)
{
	int timelimit;
	if (!GetMapTimeLimit(timelimit) || timelimit == 0)
	{
		return Plugin_Continue;
	}
	
	int timeleft;
	// Check for less than -1 in case we miss 0 - ignore -1 because that means infinite time limit
	if (GetMapTimeLeft(timeleft) && (timeleft == 0 || timeleft < -1))
	{
		CreateTimer(5.0, Timer_EndRound); // End the round after a delay or it won't end the map
		return Plugin_Stop;
	}
	
	return Plugin_Continue;
}

public Action Timer_EndRound(Handle timer)
{
	CS_TerminateRound(1.0, CSRoundEnd_Draw, true);
}
Architect is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-27-2020 , 08:37   Re: Timeleft
Reply With Quote #2

*I'm guessing.

It check every second, if cvar mp_timelimit change map timelimit (0 is unlimited).
Then check map timeleft, is it 0 or passed 0 seconds.

After this, first timer create another 5sec timer, every second. You get multiple timers. *wrong, it stop first timer (return Plugin_Stop)
And seems it try end match.
__________________
Do not Private Message @me

Last edited by Bacardi; 03-27-2020 at 08:39.
Bacardi is offline
Architect
New Member
Join Date: Mar 2020
Old 03-27-2020 , 09:12   Re: Timeleft
Reply With Quote #3

Quote:
Originally Posted by Bacardi View Post
*I'm guessing.

It check every second, if cvar mp_timelimit change map timelimit (0 is unlimited).
Then check map timeleft, is it 0 or passed 0 seconds.

After this, first timer create another 5sec timer, every second. You get multiple timers. *wrong, it stop first timer (return Plugin_Stop)
And seems it try end match.
This is the code for a separate plugin. SourceMod has its own timeleft. But if you write the command timeleft, it will be written that only after 30 rounds there will be a change. But my mode doesn't involve rounds.
Architect is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:34.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode