Round Restart Script?

Can somone please help me with a Round restart script for a gamemode like Freezetag or tag?

i know KingOfBeast made this a while back :


round = {}

-- Variables
round.Break	= 30	-- 30 second breaks
round.Time	= 300	-- 5 minute rounds

-- Read Variables
round.TimeLeft = -1
round.Breaking = false

function round.Broadcast(Text)
	for k, v in pairs(player.GetAll()) do
		v:ConCommand("play buttons/button17.wav")
		v:ChatPrint(Text)
	end
end

function round.Begin()
	-- Your code
	-- (Anything that may need to happen when the round begins)
	
	round.Broadcast("Round starting! Round ends in " .. round.Time .. " seconds!")
	round.TimeLeft = round.Time
end

function round.End()
	-- Your code
	-- (Anything that may need to happen when the round ends)
	
	round.Broadcast("Round over! Next round in " .. round.Break .. " seconds!")
	round.TimeLeft = round.Break
end

function round.Handle()
	if (round.TimeLeft == -1) then -- Start the first round
		round.Begin()
		return
	end
	
	round.TimeLeft = round.TimeLeft - 1
	
	if (round.TimeLeft == 0) then
		if (round.Breaking) then
			round.Begin()
			round.Breaking = false
		else
			round.End()
			round.Breaking = true
		end
	end
end
timer.Create("round.Handle", 1, 0, round.Handle)



but i don’t know the function to restart round itself, the code is just a round timer, but i need a function to restart.

thanks in advance

Call the round begin function inside the round end function

the thing is there is no function to call, i need to add my own code .

Huh?



function round.Begin()
	-- Your code
	-- (Anything that may need to happen when the round begins)
	
	round.Broadcast("Round starting! Round ends in " .. round.Time .. " seconds!")
	round.TimeLeft = round.Time
end

function round.End()
	-- Your code
	-- (Anything that may need to happen when the round ends)
	
	round.Broadcast("Round over! Next round in " .. round.Break .. " seconds!")
	round.TimeLeft = round.Break
end


it clearly says --Your code And as i said I do not have any code

Well, that’s up to you to write what happens on round start and round end - this script is just a set up/skeleton to give you an idea of the format.

To answer your question though, this would cause a restart on round end:



function round.End()
	round.Broadcast("Round over! Next round in " .. round.Break .. " seconds!")
	round.TimeLeft = round.Break

round.Begin()

end


i’ve tried it, it didnt work, also considering theres no function in that code that can cause a restart

It already does restart…
It restarts after a 30 seconds break, you don’t need to modify the code to make it restart as that has already been done.



if (round.Breaking) then
			round.Begin()
			round.Breaking = false
		else
			


See right here, that’s where it is restarting.

Your attitude towards someone helping you is irritating me

Yeah, OP, what do you think this script is actually doing and what do you want it to do?

The script actually does restart the round after it ends, no idea what OP wants to do?

why doesnt it restart though, as far as i can see its just calling other functions in the same code Round.Begin() does nothing else than restart the timer.

[editline]9th January 2016[/editline]

chill bro, no need to be mad

IT DOES RESTART! Have you even, lets say, tried to run the code? It may seem a radical idea but it might just prove my point?

i think i have been explaining it wrong, im very sorry, what im looking for is for the round to reset.

[lua]
function tagendround()
round.TimeLeft = 1
end
[/lua]
add to end of file

you can call this function to make the round end within 1 second (dont set to 0 or it looks like it will “start first round” bc it -1 from time left AND THEN checks if it == 0 instead of <= 0
to call it put tagendround() where you want the round to end (and then bc it ended it will restart)