Game Rounds

I have been trying to figure this out for quite some time now, and I have had no luck. I want to make game rounds. I want the round to end and everyone to die if a teams total number of kills is 30. Then I want a timer to start for 10 seconds, then after the 10 seconds everyone spawns. This is what I have:

[lua]function EndGame()
if team.GetScore( 1 ) or team.GetScore( 2 ) == 30 then
for k, v in pairs( player.GetAll() ) do
v:Kill()
end
timer.Simple( “Intermission”, 10, 1, function()
for k, v in pairs( player.GetAll() ) do
v:SetTeam( team.BestAutoJoinTeam() )
end
end
end[/lua]

Can someone please help me?

Well, you’re using the timer.Simple as a timer.Create for once.

**[Timer.Simple

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Timer.Simple)**
**[Timer.Create

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Timer.Create)**

[editline]01:00AM[/editline]

And you never closed your timer.

[editline]01:02AM[/editline]



function EndGame()
	if team.GetScore( 1 ) or team.GetScore( 2 ) == 30 then
		for k, v in pairs( player.GetAll() ) do 
			v:Kill()
		end
	end
	
timer.Simple( 10, function()
		for k, v in pairs( player.GetAll() ) do
			v:SetTeam( team.BestAutoJoinTeam() )
		end
	end )
end



You used timer wrong, forgot to close timer and missed an “end”.

Yeah, I found that I forgot to close my timer. I’m testing it right now.

[editline]08:31PM[/editline]

Doesn’t work… I also tried team.TotalFrags instead of team.GetScore, still nothing.

Any errors ?

Nope. It just doesn’t work. If I kill a bot I spawned from console 30 times, nothing happens.

Have you actually set up the teams in question?

[editline]12:44PM[/editline]

And applied the players to these teams?

Yes I setup teams. What I did was I was on one team, then I typed bot in console to spawn a bot. That’s the player on the other team.

Have you tried checking the score individually?

[lua]
if team.GetScore( 1 ) == 30 or team.GetScore( 2 ) == 30 then
[/lua]

That doesn’t work either.

What is calling EndGame()? Throw in a debug message see if its being called at all.