The Purge scripting a restart for a timer that plays audio

This is a script that we found online and i am im trying to make it work alongside another set of code to restart when the round restarts.
my problem is that when their is only one person alive the round restarts but the timer stays whre it left off and continues. id like it so that the timer would reset when the round reset(all but 1 player is alive or group is alive) any ideas?

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
PURGEMODE = true // If The Purge should be enabled [Default: true]

PurgeCountdownTimer = 275 * 1 // Time until The Purge will start [Default: 275 * 1] 4.583 Minutes
PurgeEndCountdownTimer = 60 * 5 // Time until The Purge will end [Default: 60 * 5] 5 minutes

PurgePlayPurgeSoundStart = 52 // Seconds before The Purge starts, when it should play the starting sound [Default: 52] 52 Seconds
PurgePlayPurgeSoundEnd = 1 // Seconds before The Purge ends, when it should play the end sound [Default: 1] 1 second

PurgeStartSound = “purge/thepurge.mp3” // The Sound that should play before The Purge starts [Default: “purge/thepurge.mp3”]
PurgeEndSound = “purge/thepurgeend.mp3” // The Sound that should play when The Purge ends [Default: “purge/thepurge.mp3”]
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Where is the timer itself? Those are like config values but nothing happens, you just set variables.

HI again SteppuFIN yes that was a config.lua file the othre file im looking at goes along like this and is titled the purge.lua and goes like this

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if SERVER then

resource.AddFile( “sound/purge/thepurge.mp3” )
resource.AddFile( “sound/purge/thepurgeend.mp3” )
resource.AddFile( “resource/fonts/bebasneue.ttf” )

util.AddNetworkString(“PurgeCountdown”)

IsPurge = false

SetPurgeTimer = PurgeCountdownTimer

function StartPurgeTimer()

if PURGEMODE then


	timer.Create("countdownpurge", 1, 1, function()
		if IsPurge == false then
			SetPurgeTimer = SetPurgeTimer - 1
			StartPurgeTimer()


			if SetPurgeTimer < 1 then
				IsPurge = true
				SetPurgeTimer = PurgeEndCountdownTimer
				for k, v in pairs(player.GetAll()) do
				   v:PrintMessage( HUD_PRINTTALK, "The Purge Has Started!" )
				end
			end
		else
			SetPurgeTimer = SetPurgeTimer - 1
			StartPurgeTimer()

			if SetPurgeTimer < 1 then
				IsPurge = false
				SetPurgeTimer = PurgeCountdownTimer
				for k, v in pairs(player.GetAll()) do
				   v:PrintMessage( HUD_PRINTTALK, "The Purge Has Ended!" )
				end
			end

		end
	end)

	umsg.Start("IsPurge")
		umsg.Bool(IsPurge)
	umsg.End()

	net.Start("PurgeCountdown")
			net.WriteFloat( SetPurgeTimer )
	net.Broadcast()
end

end

hook.Add("PlayerInitialSpawn", "SendPurgeTimer", function( ply )
    net.Start("PurgeCountdown")
        net.WriteFloat( SetPurgeTimer )
    net.Send( ply )

    umsg.Start("IsPurge", ply)
		umsg.Bool(IsPurge)
	umsg.End()
end)

timer.Simple(0, StartPurgeTimer)
end

[editline]14th August 2015[/editline]

I may need toget ahold of my partners actaul script for the gamemode as its round system is based off of the flood game mode

[editline]14th August 2015[/editline]

Here is the code he thinks it is its in Init.lua for Flood game mode

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
– Include and AddCSLua everything
include(“shared.lua”)
AddCSLuaFile(“shared.lua”)

MsgN("---- Flood Server Side ----")
MsgN(“Loading Server Files”)
for _, file in pairs (file.Find(“flood/gamemode/server/*.lua”, “LUA”)) do
MsgN("-> "…file)
include(“flood/gamemode/server/”…file)
end

MsgN(“Loading Shared Files”)
for _, file in pairs (file.Find(“flood/gamemode/shared/*.lua”, “LUA”)) do
MsgN("-> "…file)
AddCSLuaFile(“flood/gamemode/shared/”…file)
end

MsgN(“Loading Clientside Files”)
for _, file in pairs (file.Find(“flood/gamemode/client/*.lua”, “LUA”)) do
MsgN("-> "…file)
AddCSLuaFile(“flood/gamemode/client/”…file)
end

MsgN(“Loading Clientside VGUI Files”)
for _, file in pairs (file.Find(“flood/gamemode/client/vgui/*.lua”, “LUA”)) do
MsgN("-> "…file)
AddCSLuaFile(“flood/gamemode/client/vgui/”…file)
end

– Timer ConVars! Yay!
CreateConVar(“flood_build_time”, 240, FCVAR_NOTIFY, “Time allowed for building (def: 240)”)
CreateConVar(“flood_flood_time”, 20, FCVAR_NOTIFY, “Time between build phase and fight phase (def: 20)”)
CreateConVar(“flood_fight_time”, 300, FCVAR_NOTIFY, “Time allowed for fighting (def: 300)”)
CreateConVar(“flood_reset_time”, 40, FCVAR_NOTIFY, “Time after fight phase to allow water to drain and other ending tasks (def: 40 - Dont recommend changing)”)

– Cash Convars
CreateConVar(“flood_participation_cash”, 50, FCVAR_NOTIFY, “Amount of cash given to a player every 5 seconds of being alive (def: 50)”)
CreateConVar(“flood_bonus_cash”, 300, FCVAR_NOTIFY, “Amount of cash given to the winner of a round (def: 300)”)

– Water Hurt System
CreateConVar(“flood_wh_enabled”, 1, FCVAR_NOTIFY, “Does the water hurt players - 1=true 2=false (def: 1)”)
CreateConVar(“flood_wh_damage”, 1, FCVAR_NOTIFY, “How much damage a player takes per cycle (def: 1)”)

– Prop Limits
CreateConVar(“flood_max_player_props”, 20, FCVAR_NOTIFY, “How many props a player can spawn (def: 30)”)
CreateConVar(“flood_max_donator_props”, 30, FCVAR_NOTIFY, “How many props a donator can spawn (def: 30)”)
CreateConVar(“flood_max_admin_props”, 40, FCVAR_NOTIFY, “How many props an admin can spawn (def: 40)”)

function GM:Initialize()
self.ShouldHaltGamemode = false
self:InitializeRoundController()

-- Dont allow the players to noclip
RunConsoleCommand("sbox_noclip", "0")

-- We have our own prop spawning system
RunConsoleCommand("sbox_maxprops", "0")

end

function GM:InitPostEntity()
self:CheckForWaterControllers()
for k,v in pairs(ents.GetAll()) do
if v:GetClass() == “trigger_hurt” then
v:Remove()
end
end
end

function GM:Think()
self:ForcePlayerSpawn()
self:CheckForWinner()

if self.ShouldHaltGamemode == true then
	hook.Remove("Think", "Flood_TimeController")
end

end

function GM:CleanupMap()
– Refund what we can
self:RefundAllProps()

-- Cleanup the rest
game.CleanUpMap()

-- Call InitPostEntity
self:InitPostEntity()

end

function GM:ShowHelp(ply)
ply:ConCommand(“flood_helpmenu”)
end

function GM:EntityTakeDamage(ent, dmginfo)
local attacker = dmginfo:GetAttacker()
if GAMEMODE:GetGameState() ~= 2 and GAMEMODE:GetGameState() ~= 3 then
return false
else
if not ent:IsPlayer() then
if attacker:IsPlayer() then
if attacker:GetActiveWeapon() ~= NULL then
if attacker:GetActiveWeapon():GetClass() == “weapon_pistol” then
ent:SetNWInt(“CurrentPropHealth”, ent:GetNWInt(“CurrentPropHealth”) - 1)
else
for _, Weapon in pairs(Weapons) do
if attacker:GetActiveWeapon():GetClass() == Weapon.Class then
ent:SetNWInt(“CurrentPropHealth”, ent:GetNWInt(“CurrentPropHealth”) - tonumber(Weapon.Damage))
end
end
end
end
else
if attacker:GetClass() == “entityflame” then
ent:SetNWInt(“CurrentPropHealth”, ent:GetNWInt(“CurrentPropHealth”) - 0.5)
else
ent:SetNWInt(“CurrentPropHealth”, ent:GetNWInt(“CurrentPropHealth”) - 1)
end
end

		if ent:GetNWInt("CurrentPropHealth") <= 0 and IsValid(ent) then
			ent:Remove()
		end
	end
end

end

function ShouldTakeDamage(victim, attacker)
if GAMEMODE:GetGameState() ~= 3 then
return false
else
if attacker:IsPlayer() and victim:IsPlayer() then
return false
else
if attacker:GetClass() ~= “prop_*” and attacker:GetClass() ~= “entityflame” then
return true
end
end
end
end
hook.Add(“PlayerShouldTakeDamage”, “Flood_PlayerShouldTakeDamge”, ShouldTakeDamage)

function GM:KeyPress(ply, key)
if ply:Alive() ~= true then
if key == IN_ATTACK then
ply:CycleSpectator(1)
end
if key == IN_ATTACK2 then
ply:CycleSpectator(-1)
end
end
end

[editline]14th August 2015[/editline]

baisclly we want those scripts to work together and play the audio when the time is about to start the period where the script is called
– Timer ConVars! Yay!
CreateConVar(“flood_build_time”, 240, FCVAR_NOTIFY, “Time allowed for building (def: 240)”)
CreateConVar(“flood_flood_time”, 20, FCVAR_NOTIFY, “Time between build phase and fight phase (def: 20)”)
CreateConVar(“flood_fight_time”, 300, FCVAR_NOTIFY, “Time allowed for fighting (def: 300)”)
CreateConVar(“flood_reset_time”, 40, FCVAR_NOTIFY, “Time after fight phase to allow water to drain and other ending tasks (def: 40 - Dont recommend changing)”)

Use [noparse]


-code here-

[/noparse] in your post

—snip----- someone else said it at the same time

and then restart when the flood reset time convar is triggered

[editline]14th August 2015[/editline]


--- Include and AddCSLua everything
include("shared.lua")
AddCSLuaFile("shared.lua")

MsgN("_-_-_-_- Flood Server Side -_-_-_-_")
MsgN("Loading Server Files")
for _, file in pairs (file.Find("flood/gamemode/server/*.lua", "LUA")) do
	MsgN("-> "..file)
	include("flood/gamemode/server/"..file) 
end

MsgN("Loading Shared Files")
for _, file in pairs (file.Find("flood/gamemode/shared/*.lua", "LUA")) do
	MsgN("-> "..file)
	AddCSLuaFile("flood/gamemode/shared/"..file)
end

MsgN("Loading Clientside Files")
for _, file in pairs (file.Find("flood/gamemode/client/*.lua", "LUA")) do
	MsgN("-> "..file)
	AddCSLuaFile("flood/gamemode/client/"..file)
end

MsgN("Loading Clientside VGUI Files")
for _, file in pairs (file.Find("flood/gamemode/client/vgui/*.lua", "LUA")) do
	MsgN("-> "..file)
	AddCSLuaFile("flood/gamemode/client/vgui/"..file)
end

-- Timer ConVars! Yay!
CreateConVar("flood_build_time", 240, FCVAR_NOTIFY, "Time allowed for building (def: 240)")
CreateConVar("flood_flood_time", 20, FCVAR_NOTIFY, "Time between build phase and fight phase (def: 20)")
CreateConVar("flood_fight_time", 300, FCVAR_NOTIFY, "Time allowed for fighting (def: 300)")
CreateConVar("flood_reset_time", 40, FCVAR_NOTIFY, "Time after fight phase to allow water to drain and other ending tasks (def: 40 - Dont recommend changing)")

-- Cash Convars
CreateConVar("flood_participation_cash", 50, FCVAR_NOTIFY, "Amount of cash given to a player every 5 seconds of being alive (def: 50)")
CreateConVar("flood_bonus_cash", 300, FCVAR_NOTIFY, "Amount of cash given to the winner of a round (def: 300)")

-- Water Hurt System
CreateConVar("flood_wh_enabled", 1, FCVAR_NOTIFY, "Does the water hurt players - 1=true 2=false (def: 1)")
CreateConVar("flood_wh_damage", 1, FCVAR_NOTIFY, "How much damage a player takes per cycle (def: 1)")

-- Prop Limits
CreateConVar("flood_max_player_props", 20, FCVAR_NOTIFY, "How many props a player can spawn (def: 30)")
CreateConVar("flood_max_donator_props", 30, FCVAR_NOTIFY, "How many props a donator can spawn (def: 30)")
CreateConVar("flood_max_admin_props", 40, FCVAR_NOTIFY, "How many props an admin can spawn (def: 40)")

function GM:Initialize()
	self.ShouldHaltGamemode = false
	self:InitializeRoundController()

	-- Dont allow the players to noclip
	RunConsoleCommand("sbox_noclip", "0")

	-- We have our own prop spawning system
	RunConsoleCommand("sbox_maxprops", "0")
end

function GM:InitPostEntity()
	self:CheckForWaterControllers()
	for k,v in pairs(ents.GetAll()) do 
		if v:GetClass() == "trigger_hurt" then 
			v:Remove() 
		end 
	end
end

function GM:Think()
	self:ForcePlayerSpawn()
	self:CheckForWinner()

	if self.ShouldHaltGamemode == true then
		hook.Remove("Think", "Flood_TimeController")
	end
end

function GM:CleanupMap()
	-- Refund what we can
	self:RefundAllProps()

	-- Cleanup the rest
	game.CleanUpMap()

	-- Call InitPostEntity
	self:InitPostEntity()
end

function GM:ShowHelp(ply)
	ply:ConCommand("flood_helpmenu")
end

function GM:EntityTakeDamage(ent, dmginfo)
	local attacker = dmginfo:GetAttacker()
	if GAMEMODE:GetGameState() ~= 2 and GAMEMODE:GetGameState() ~= 3 then
		return false
	else
		if not ent:IsPlayer() then
			if attacker:IsPlayer() then
				if attacker:GetActiveWeapon() ~= NULL then
					if attacker:GetActiveWeapon():GetClass() == "weapon_pistol" then
						ent:SetNWInt("CurrentPropHealth", ent:GetNWInt("CurrentPropHealth") - 1)
					else
						for _, Weapon in pairs(Weapons) do
							if attacker:GetActiveWeapon():GetClass() == Weapon.Class then
								ent:SetNWInt("CurrentPropHealth", ent:GetNWInt("CurrentPropHealth") - tonumber(Weapon.Damage))
							end
						end
					end
				end
			else
				if attacker:GetClass() == "entityflame" then
					ent:SetNWInt("CurrentPropHealth", ent:GetNWInt("CurrentPropHealth") - 0.5)
				else
					ent:SetNWInt("CurrentPropHealth", ent:GetNWInt("CurrentPropHealth") - 1)
				end
			end
			
			if ent:GetNWInt("CurrentPropHealth") <= 0 and IsValid(ent) then
				ent:Remove()
			end
		end
	end
end

function ShouldTakeDamage(victim, attacker)
	if GAMEMODE:GetGameState() ~= 3 then
		return false
	else
		if attacker:IsPlayer() and victim:IsPlayer() then
			return false
		else
			if attacker:GetClass() ~= "prop_*" and attacker:GetClass() ~= "entityflame" then
				return true
			end
		end
	end
end
hook.Add("PlayerShouldTakeDamage", "Flood_PlayerShouldTakeDamge", ShouldTakeDamage)

function GM:KeyPress(ply, key)
 	if ply:Alive() ~= true then 
 		if key == IN_ATTACK then 
 			ply:CycleSpectator(1)
 		end 
 		if key == IN_ATTACK2 then 
 			ply:CycleSpectator(-1)
 		end 
 	end
end-

[editline]14th August 2015[/editline]


-if SERVER then

resource.AddFile( "sound/purge/thepurge.mp3" )
resource.AddFile( "sound/purge/thepurgeend.mp3" )	
resource.AddFile( "resource/fonts/bebasneue.ttf" )	

util.AddNetworkString("PurgeCountdown")

IsPurge = false

SetPurgeTimer = PurgeCountdownTimer

function StartPurgeTimer()

if PURGEMODE then


timer.Create("countdownpurge", 1, 1, function()
if IsPurge == false then
SetPurgeTimer = SetPurgeTimer - 1
StartPurgeTimer()


if SetPurgeTimer < 1 then
IsPurge = true
SetPurgeTimer = PurgeEndCountdownTimer
for k, v in pairs(player.GetAll()) do
v:PrintMessage( HUD_PRINTTALK, "The Purge Has Started!" )
end
end
else
SetPurgeTimer = SetPurgeTimer - 1
StartPurgeTimer()

if SetPurgeTimer < 1 then
IsPurge = false
SetPurgeTimer = PurgeCountdownTimer
for k, v in pairs(player.GetAll()) do
v:PrintMessage( HUD_PRINTTALK, "The Purge Has Ended!" )
end
end

end
end)

umsg.Start("IsPurge")
umsg.Bool(IsPurge)
umsg.End()

net.Start("PurgeCountdown")
net.WriteFloat( SetPurgeTimer )
net.Broadcast()
end

end

hook.Add("PlayerInitialSpawn", "SendPurgeTimer", function( ply )
net.Start("PurgeCountdown")
net.WriteFloat( SetPurgeTimer )
net.Send( ply )

umsg.Start("IsPurge", ply)
umsg.Bool(IsPurge)
umsg.End()
end)

timer.Simple(0, StartPurgeTimer)
end
-

[editline]14th August 2015[/editline]

top is the flood init.lua and bottom is thepurge.lua

Well you said you need help with the coding? Just add me on steam, Exautic | TerranianFox

Done and We found the check phase if we could edit this we could make it so it plays our audio file that we want to play “-
-”


-function GM:FightPhase()
if Flood_fightTime <= 0 then
-- Time to Reset
self:SetGameState(4)

-- Lower Water
self:LowerAllWaterControllers()

-- Declare winner is nobody because time ran out
self:DeclareWinner(3)
else  
Flood_fightTime = Flood_fightTime - 1
self:ParticipationBonus()
end
end

function GM:ResetPhase()
if Flood_resetTime <= 0 then
-- Time to wait for players (if players exist, should go to build phase)
self:SetGameState(0) 

-- Give people their money
self:RefundAllProps()

-- Game is over, lets tidy up the players
for _, v in pairs(player.GetAll()) do
if IsValid(v) then
v:SetCanRespawn(true)

-- Wait till they respawn
timer.Simple(0, function()
v:StripWeapons()
v:RemoveAllAmmo()
v:SetHealth(100)
v:SetArmor(0)

timer.Simple(0, function()
v:Give("gmod_tool")
v:Give("weapon_physgun")
v:Give("flood_propseller")

v:SelectWeapon("weapon_physgun")
end)
end)
end
end

-- Reset all the round timers
self:ResetAllTimers()
else  
Flood_resetTime = Flood_resetTime - 1
end
end-

[editline]14th August 2015[/editline]

we want to edit this for our purge server so that the second timer will reset along with the one that restarts the round.