Can i get some gmod gamemode lua help?

can i get some help with something i cant seem to fine online that would be very help full with my gamemode and that thing is i cant seem to find any thing on how to make a function to shows what happens when the round starts and another one for round ends.

what i am wanting to do is to have a function that at a start of a round every player is set to team 0 then with my random gen i have made one player well be picked to go to team 1 after 15 secs.

now i already have the code for for players to be on them 0 and the random gen.

i just can seem to find any thing on how to make a function for round starts.

and would it be possible to make it a function for the round end .

if all players on team 0 are dead then
message “red team win”
timer 15 secs new round starts
end

if all players on team 0 are dead then
message “blue them win”
timer 15 secs new round starts
end

thanks for you time for reading this and i hope you can help me

sorry for bad english or grammar i find it hard with my disability’s.

Here is a round system that i’m using in my murder gamemode.

[lua]
util.AddNetworkString(“RoundStatus”)
util.AddNetworkString(“WhoWon”)
util.AddNetworkString(“EndOfRound”)

GM.RoundStatus = 0
GM.WhoWon = 0
–[[
0 - Not enough players
1 - Active Round
2 - Round Ended; restarting
]]–

function GM:GetRoundStatus()
return self.RoundStatus or 0
end

function GM:SetRoundStatus(roundstatus)
self.RoundStatus = roundstatus
if roundstatus == 1 then return end
self:Networking()
end

function GM:Networking(ply)
net.Start(“RoundStatus”)
net.WriteInt(self.RoundStatus, 32)
net.Broadcast()
net.Start(“WhoWon”)
net.WriteInt(self.WhoWon, 32)
net.Broadcast()
end

function GM:RoundThink()
local bystanders = team.GetPlayers(1)
local murderer = team.GetPlayers(2)
local players = player.GetAll()

RoundStatus1 = self.RoundStatus

if self.RoundStatus == 0 then 
	if #players > 1 then
		self:StartNewRound()
	end
end
if self.RoundStatus == 1 then
	self:CheckStatus()
--	print("Active Round 1")
elseif self.RoundStatus == 2 then
	if #players <=1 then 
		self:SetRoundStatus(0)
	else
		self:EndOfRound()
	end
end

end
–[[
0 - No one won
1 - Bystanders won
2 - Murder won
]]–
function GM:CheckStatus()
local bystanders = team.GetPlayers(1)
local murderer = team.GetPlayers(2)

-- print("Called")
if #bystanders <= 0 then
	self.WhoWon = 2
	self:SetRoundStatus(2)
	print("Murderer Won!")
	PrintMessage( HUD_PRINTTALK, "The murderer won! The murderer was " .. murdererselect:Nick() )
elseif #murderer <=0 then
	self.WhoWon = 1
	self:SetRoundStatus(2)
	print("Bystander Won!")
	PrintMessage( HUD_PRINTTALK, "Bystander Won! The murderer was " .. murdererselect:Nick() or "Error")
end

end

function GM:StartNewRound()
for k, v in pairs(player.GetAll()) do
v:SetTeam(1)
v:UnSpectate()
v:Spawn()
v:Give(“weapon_357”)
v:GiveAmmo( 10000, “357”, false )

end

murdererselect = Entity(math.random( 1, #player.GetAll() ) )
murdererselect:SetTeam(2)
print(murdererselect:Nick() ..  " Has been made the murderer!")
self:SetRoundStatus(1) 

for i=1,1 do
	game.CleanUpMap()
end
self:StartRound()

end

function GM:EndOfRound()
if timer.Exists(“EndOfRound”) then return end
timer.Create( “EndOfRound”, 10 , 1, function()
if !self.RoundStatus == 2 then return end
self:StartNewRound()
print(“Working…”)
end )

if timer.Exists("EndOfRoundSound") then return end
timer.Create( "EndOfRoundSound", 0, 1, function()
	if !self.RoundStatus == 2 then return end
		for k,v in pairs(player.GetAll()) do
			local pitch = math.random(80, 120)
			v:EmitSound("ambient/alarms/warningbell1.wav", 100, pitch)
		end
		net.Start("EndOfRound")
			net.WriteInt(1, 32)
		net.Broadcast()
		
end)

end
[/lua]

oh my
but am not sure how i would integrate your code with mine code

Look at the flow of it and see what happens during certain “events”… I’d recommend using PlayerDeath and PlayerDisconnected hooks to check the round-status ( to determine if it should end or not )…

A few older tuts of mine on round-systems: https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/round_system/basic_concept_of_round_systems.lua.html

https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/round_system/extended_concept_of_round_systems.lua.html

https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/round_system/class_round_system.lua.html