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.
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
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.
[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)