local notifNumber = 0
local Queue = {}

RegisterNetEvent("spyoo_notif:notif")
AddEventHandler("spyoo_notif:notif", function(notif, remove)
	if notif.time == nil then
		notif.time = 3000
	end
	if (notifNumber < 3) then
		if remove then
			table.remove(Queue, 1)
			Wait(500)
		end
		notifNumber = notifNumber + 1
		SendNUIMessage({
			type = "notif",
			info = notif
		})
	else
		if remove == nil then
			table.insert(Queue, notif)
		end
	end
end)

Citizen.CreateThread(function()
	while true do
		Wait(100)
		if #Queue > 0 then
			TriggerEvent("spyoo_notif:notif", Queue[1], true)
		end
	end
end)

RegisterNUICallback("notif", function(data)
	local notif = { type = data.type, content = data.content, time = data.time, notif = data.notif }
	TriggerEvent("spyoo_notif:notif", notif)
end)

RegisterNUICallback("removeQueue", function()
	notifNumber = notifNumber - 1
end)