-- << REMOTE LIMITS / SANITY CHECKS >>

local remoteRefreshRate = 5
local remoteLimits = {
	["RemoteFunction"] = 20;
	["RemoteEvent"] = 10;
}
local sanityChecks = {}

local function checkRemoteLimit(player, remote)
	local remoteType = remote.ClassName
	local remoteLimit = remoteLimits[remoteType]
	if not sanityChecks[player] then
		sanityChecks[player] = {}
	end
	local requests = sanityChecks[player][remote]
	if not requests then
		requests = 1
		sanityChecks[player][remote] = requests
	else
		sanityChecks[player][remote] = requests + 1
	end
	if requests > remoteLimit then
		main:GetModule("cf"):FormatAndFireError(player, "RequestsLimit")
		if remoteType == "RemoteFunction" then
			wait(1)
		end
		return false
	end
	return true
end

coroutine.wrap(function()
	while true do
		wait(remoteRefreshRate)
		sanityChecks = {}
	end
end)()


