Round system?

Anyone out with a round system. It should not be Fretta because Fretta 13 sucks and you cant do that much with Fretta.

I tried this i have no idea if it would work ofc it need some functions but i also need a hook and i cant seem to find a hook i think fits.


local RoundTime = 300

function RoundStart()
	timer.Create("Round_Start", RoundTime, 1, function()
	        print(Round_Start)
end
end)


function RoundEnd()
	timer.Destroy("Round_Start")
end


[lua]
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)
[/lua]

Was that so hard to google?

A little help?


round = {}

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

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

-- Custom
winamount = math.random( 100, 250 )
loseamount = math.random( 20, 50 )
winner = -- how to detect winner
loser = -- how to detect loser

-- Be aware that i use 2 teams only. 

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()

	round.Broadcast("Round starting! Round ends in " .. round.Time .. " seconds!")
	round.TimeLeft = round.Time
	
end

function round.End()

	round.Broadcast("Team"..winner.."won the round. Restarting.")
	round.TimeLeft = round.Break
	
	if ply = winner then
	ply:PrintMessage( HUD_PRINTTALK, "You won"..winamount".."$ for winning the round" )
	ply:KWEPS_SetCash(winner, winamount)
	elseif ply = loser then
	ply:PrintMessage( HUD_PRINTTALK, "You lost the round but still got"..loseamount".."$" )
	ply:KWEPS_SetCash(loser, loseamount)
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)

Help on what exactly?

Look at locals. How can I find out what team are winners and what team is loser

http://forum.facepunch.com/showthread.php?t=992668&p=24395386&viewfull=1#post24395386

Can you please google before you ask questions?

The code supplied only deals with time based rounds.
Change “if (round.TimeLeft == 0) then” to “if (round.TimeLeft == 0 or round.ShouldEnd()) then”
and define a function round.ShouldEnd to return true for false depending on what you need to happen.

You should try solving these problems for your self first. Think like a computer, but break points in to find out what is happening.