Raised This Month: $ Target: $400
 0% 

[CSGO] Timer off and on?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dinamix
SourceMod Donor
Join Date: Jan 2011
Location: Lithuanian
Old 01-12-2016 , 16:50   [CSGO] Timer off and on?
Reply With Quote #1

basicly created a timer, and as I understand return plugin_stop; or what so ever, stops the timer, so I created few timers to test, one with repeat other one without

Code:
public Action:OnRoundStart(Handle:event, const String:name[], bool:dontBroadcast) {

CreateTimer(40.0, EndRound);
}


public Action:EndRound(Handle:timer)
{
	if(CS_GetTeamScore(2) > CS_GetTeamScore(3)) 
	{ 
		PrintToChatAll("Team RED WON!");
		CS_TerminateRound(5.0, CSRoundEnd_TerroristWin, true);
	}
	else if(CS_GetTeamScore(2) < CS_GetTeamScore(3)) 
	{
		PrintToChatAll("Team BLUE WON!");
		CS_TerminateRound(5.0, CSRoundEnd_CTWin, true);
	}
	else
	{
		PrintToChatAll("RoundDraw!");
		CS_TerminateRound(5.0, CSRoundEnd_Draw, true);
	}
	return Plugin_Stop;
}
The funny part that I didint even create a repeatible timer for this one. and when I create a repeated one, basicly same stuff happens. It goes again aand again after every 40 secconds ( I guess, cant rly know, restarts and then again after short period of time. What IM doing wrong?
dinamix is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 01-12-2016 , 16:54   Re: [CSGO] Timer off and on?
Reply With Quote #2

Plugin_Stop will kill the timer.
Plus you are not protecting against the round ending and killing the timer, so the timer can continue into the next round, ending it early.
EDIT: are you asking why this timer keeps happening?? Because it creates a new timer at round start and after 40 seconds it restarts the round, creating a new timer. Basically a loop.

Last edited by Mitchell; 01-12-2016 at 16:56.
Mitchell is offline
dinamix
SourceMod Donor
Join Date: Jan 2011
Location: Lithuanian
Old 01-12-2016 , 16:56   Re: [CSGO] Timer off and on?
Reply With Quote #3

Quote:
Originally Posted by Mitchell View Post
Plugin_Stop will kill the timer.
Plus you are not protecting against the round ending and killing the timer, so the timer can continue into the next round, ending it early.
So if I add it after all the prints (every prints) it should end it correctly?
dinamix is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 01-12-2016 , 17:00   Re: [CSGO] Timer off and on?
Reply With Quote #4

Quote:
Originally Posted by dinamix View Post
So if I add it after all the prints (every prints) it should end it correctly?
No it would have the same effect.
What I'm saying is that you're ending the round and creating a timer on round_start, which fires when the round starts, so of course it's going to repeat.
Mitchell is offline
dinamix
SourceMod Donor
Join Date: Jan 2011
Location: Lithuanian
Old 01-12-2016 , 17:03   Re: [CSGO] Timer off and on?
Reply With Quote #5

Quote:
Originally Posted by Mitchell View Post
No it would have the same effect.
What I'm saying is that you're ending the round and creating a timer on round_start, which fires when the round starts, so of course it's going to repeat.
well I am aware of that, I do need that, 40 secconds is just for a fast test, though Imtrying to make so on the round start it would create the timer and after 2 mins for exemple, it would decide to end a round, on the next round it would start counting again, but the thing is, Timer acts as a total repeater, it says for exemple - Round draw, and then after 10 secconds it says Round draw after a while, the next round doesnt even start and it allready round drawns. and stuff like that.

EDIT: In other words - The timer doesnt end, it starts over again, while on round start it creates another, and its a loop that makes it even more timers in the round. I need tomake it so it would kill the timer after it decides the winner, but it starts counting again on round start

Last edited by dinamix; 01-12-2016 at 17:05.
dinamix 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 11:34.


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