PVPSound_PaybackQueue			= { }
PVPSound_RetributionQueue		= { }
local PVPSound_NextPayUpdate 	= 0.3
local PVPSound_NextRetUpdate 	= 0.3

-- Payback
function PVPSound_AddToPaybackQueue(name)
	-- This function will check and return true if the name is already in the queue
	--[[if name then
		AlreadyInQueue = false
		for i = 1, table.getn(PVPSound_PaybackQueue), 1 do
			if string.upper(PVPSound_PaybackQueue[i].dir) == string.upper(name) then
				-- The name was already found in the queue
				AlreadyInQueue = true
			end
		end
	end]]--
	-- This function will add the name into the Payback queue
	if name then
		local paytemptable = {dir = name, uptime = GetTime()}
		table.insert(PVPSound_PaybackQueue, paytemptable)
	end
end

function PVPSound_ClearPaybackQueue()
	-- This function will clear all possible Payback names from the queue
	local i
	for i = table.getn(PVPSound_PaybackQueue), 1 do
		table.remove(PVPSound_PaybackQueue, i)
	end
end

function PVPSound_DeleteFirstPayback()
	-- This function will delete the first Payback table from the queue if its in the queue since more than the Payback kill time and return 0.3
	if PVPSound_PaybackInQueue() then
		if GetTime() - PS_pkill_time > PVPSound_PaybackQueue[1].uptime then
			table.remove(PVPSound_PaybackQueue,1)
		end
		return 0.3
	else
		return 0.3
	end
end

function PVPSound_PaybackInQueue()
	-- This function will return 1 if there is a name in the queue, nil otherwise
	if table.getn(PVPSound_PaybackQueue) > 0 then
		return 1
	else
		return nil
	end
end

function PVPSound_UpdatePaySound(self, elapsed)
	if PS_paysound == true then
		self.TimeSinceLastPayUpdate = self.TimeSinceLastPayUpdate + elapsed
		while self.TimeSinceLastPayUpdate > PVPSound_NextPayUpdate do
			self.TimeSinceLastPayUpdate = self.TimeSinceLastPayUpdate - PVPSound_NextPayUpdate
			PVPSound_NextPayUpdate = PVPSound_DeleteFirstPayback()
		end
	end
end

-- Retribution
function PVPSound_AddToRetributionQueue(name)
	-- This function will check and return true if the name is already in the queue
	--[[if name then
		AlreadyInQueue = false
		for i = 1, table.getn(PVPSound_RetributionQueue), 1 do
			if string.upper(PVPSound_RetributionQueue[i].dir) == string.upper(name) then
				-- The name was already found in the queue
				AlreadyInQueue = true
			end
		end
	end]]--
	-- This function will add the name into the Retribution queue
	if name then
		local rettemptable = {dir = name, uptime = GetTime()}
		table.insert(PVPSound_RetributionQueue, rettemptable)
	end
end

function PVPSound_ClearRetributionQueue()
	-- This function will clear all possible Retribution names from the queue
	local i
	for i = table.getn(PVPSound_RetributionQueue), 1 do
		table.remove(PVPSound_RetributionQueue, i)
	end
end

function PVPSound_DeleteFirstRetribution()
	-- This function will delete the first Retribution table from the queue if its in the queue since more than Payback kill time and return 0.3
	if PVPSound_RetributionInQueue() then
		if GetTime() - PS_pkill_time > PVPSound_RetributionQueue[1].uptime then
			table.remove(PVPSound_RetributionQueue,1)
		end
		return 0.3
	else
		return 0.3
	end
end

function PVPSound_RetributionInQueue()
	-- This function will return 1 if there is a name in the queue, nil otherwise
	if table.getn(PVPSound_RetributionQueue) > 0 then
		return 1
	else
		return nil
	end
end

function PVPSound_UpdateRetSound(self, elapsed)
	if PS_paysound == true then
		self.TimeSinceLastRetUpdate = self.TimeSinceLastRetUpdate + elapsed
		while self.TimeSinceLastRetUpdate > PVPSound_NextRetUpdate do
			self.TimeSinceLastRetUpdate = self.TimeSinceLastRetUpdate - PVPSound_NextRetUpdate
			PVPSound_NextRetUpdate = PVPSound_DeleteFirstRetribution()
		end
	end
end