main.logging.webhook = "" if main.automaticFires.main.clockOnSystem.enabled then clockedOn = {} end usingJobCheck = main.automaticFires.main.QBCore.enabled or main.automaticFires.main.QBX.enabled or main.automaticFires.main.vRP.enabled or main.automaticFires.main.ESX.enabled or main.automaticFires.main.clockOnSystem.enabled function checkJobsForAutomaticFires() local count = 0 -- Number of players in a certain job (if using the spawning system in relation to jobs) local playerTable = {} if main.automaticFires.main.QBCore.enabled then local players = QBCore.Functions.GetQBPlayers() for k, v in pairs(players) do local playerData = v.PlayerData local jobName = playerData.job.name for k, v in pairs(main.automaticFires.main.QBCore.jobs) do if jobName == v then playerTable[playerData.source] = playerData.source count = count + 1 break end end end end if main.automaticFires.main.vRP.enabled then for k, v in pairs(main.automaticFires.main.vRP.groups) do local players = vRP.getUsersByGroup({v}) for k, v in pairs(players) do playerTable[vRP.getUserSource({v})] = vRP.getUserSource({v}) count = count + 1 end end if #(main.automaticFires.main.vRP.permissions) > 0 then for k, v in pairs(main.automaticFires.main.vRP.permissions) do local players = vRP.getUsersByPermission({v}) for k, v in pairs(players) do playerTable[vRP.getUserSource({v})] = vRP.getUserSource({v}) count = count + 1 end end end end if main.automaticFires.main.ESX.enabled then local xPlayers = ESX.GetExtendedPlayers() for k, v in pairs(xPlayers) do local xPlayer = ESX.GetPlayerFromId(v.source) local src = v.source for k, v in pairs(main.automaticFires.main.ESX.jobs) do if xPlayer.job.name == v then playerTable[src] = src count = count + 1 break end end end end if main.automaticFires.main.QBX.enabled then local players = exports.qbx_core:GetPlayersData() for k, v in pairs(players) do for y, u in pairs(main.automaticFires.main.QBX.checkJob.jobs) do if v.job.name == u then playerTable[v.source] = v.source count = count + 1 break end end end end if main.automaticFires.main.clockOnSystem.enabled then for k, v in pairs(clockedOn) do if v then playerTable[k] = k count = count + 1 end end end if not usingJobCheck then local players = GetPlayers() for k, v in pairs(players) do count = count + 1 playerTable[k] = k end end return count, playerTable end function firstToUpper(str) return (str:gsub("^%l", string.upper)) end if main.startFireCommand.enabled then -- id is either originalId, or the id of the linked fire RegisterServerEvent("Server:updateFireTableManualAdd") AddEventHandler("Server:updateFireTableManualAdd", function(eKey, coords, size, type, spreadable, original, lighter, receivedId) if eventKey == eKey then local source = source local permission = userHasPermission(source, main.startFireCommand) if permission or lighter then local id = 0 local originalId = 0 if original and receivedId ~= nil then id = receivedId else id = createFireId() originalId = receivedId end local fire = {coords = coords, size = size, type = type, active = false, spreadable = spreadable, original = original, originalId = originalId, initialSize = size, automatic = {created = false, type=""}} fires[id] = fire TriggerClientEvent("Client:updateFireTable", -1, id, fire, false, false) if original then TriggerEvent("Server:newFireEvent", id, coords, size) if main.fireAlerts.alertTypes.manualFires then if lighter then triggerFireNotification(id, firstToUpper(fires[id].type) .. " " .. translations.fireStartedByLighter) else triggerFireNotification(id, firstToUpper(fires[id].type) .. " " .. translations.fireStartedManually) end end if main.removeFiresAutomatically.manualFires then -- Remove fire automatically after x amount of time Citizen.SetTimeout(main.removeFiresAutomatically.timer * 1000, function() if fires[id] ~= nil then TriggerClientEvent("Client:updateFireTable", -1, id, fires[id], true, false) end for k, v in pairs(fires) do if not v.original and v.originalId == id then TriggerClientEvent("Client:updateFireTable", -1, k, fires[k], true, false) fires[k] = nil end end fires[id] = nil end) end end end end end) RegisterCommand(main.startFireCommand.commandName, function(source, args) local source = source local args = args local permission = userHasPermission(source, main.startFireCommand) if permission then TriggerClientEvent("Client:startFireCommand", source, args) else TriggerClientEvent("Client:fireNotify", source, translations.noPermission) end end, main.startFireCommand.acePermissions.enabled) end if main.stopFireCommand.enabled then RegisterCommand(main.stopFireCommand.commandName, function(source, args) local source = source local args = args local permission = userHasPermission(source, main.stopFireCommand) if permission then TriggerClientEvent("Client:stopFireCommand", source, args) else TriggerClientEvent("Client:fireNotify", source, translations.noPermission) end end, main.stopFireCommand.acePermissions.enabled) end local lighterCooldown = {} if main.lighterEnabled and main.lighterFramework.command.commandEnabled then RegisterCommand(main.lighterFramework.command.commandName, function(source) local source = source if main.lighterFramework.command.cooldown.enabled and lighterCooldown[source] then TriggerClientEvent("Client:fireNotify", source, translations.lighterCooldown) return nil end local permission = userHasPermission(source, main.lighterFramework.command.permissions) if permission then lighterCooldown[source] = true if main.lighterFramework.command.cooldown.enabled then Citizen.SetTimeout(main.lighterFramework.command.cooldown.duration, function() lighterCooldown[source] = nil end) end TriggerClientEvent("Client:FindNearbyDumpster", source) else TriggerClientEvent("Client:fireNotify", source, translations.noPermission) end end, main.stopFireCommand.acePermissions.enabled) end if main.stopAllFiresCommand.enabled then RegisterCommand(main.stopAllFiresCommand.commandName, function(source, args) local source = source local successful = false local count = tableLength(fires) if count > 0 then successful = true end local permission = userHasPermission(source, main.stopAllFiresCommand) if permission then TriggerClientEvent("Client:stopAllFiresCommand", source, successful, count) if successful then fires = {} TriggerClientEvent("Client:clearAllFires", -1) end else TriggerClientEvent("Client:fireNotify", source, translations.noPermission) end end, main.stopAllFiresCommand.acePermissions.enabled) end if main.startSmokeCommand.enabled then RegisterServerEvent("Server:updateSmokeTableManualAdd") AddEventHandler("Server:updateSmokeTableManualAdd", function(eKey, coords, size, type) if eKey == eventKey then local source = source local permission = userHasPermission(source, main.startSmokeCommand) if permission then local id = createFireId() local smokeHandle = {coords = coords, size = size, type = type, active = false, initialSize = size} smoke[id] = smokeHandle TriggerClientEvent("Client:updateSmokeTable", -1, id, smokeHandle, false) TriggerEvent("Server:newSmokeEvent", id, coords, size) else TriggerClientEvent("Client:fireNotify", source, translations.noPermission) end end end) RegisterCommand(main.startSmokeCommand.commandName, function(source, args) local source = source local args = args local permission = userHasPermission(source, main.startSmokeCommand) if permission then TriggerClientEvent("Client:startSmokeCommand", source, args) else TriggerClientEvent("Client:fireNotify", source, translations.noPermission) end end, main.startSmokeCommand.acePermissions.enabled) end if main.automaticFires.toggleAutomaticFiresCommand.enabled then RegisterCommand(main.automaticFires.toggleAutomaticFiresCommand.commandName, function(source, args) local source = source local permission = userHasPermission(source, main.automaticFires.toggleAutomaticFiresCommand) if permission then toggleAutoFires(source) else TriggerClientEvent("Client:fireNotify", source, translations.noPermission) end end, main.automaticFires.toggleAutomaticFiresCommand.acePermissions.enabled) end if main.automaticFires.enableAreaOfPatrolSettings.enabled and main.automaticFires.enableAreaOfPatrolSettings.setAreaOfPatrolCommand.enabled then RegisterCommand(main.automaticFires.enableAreaOfPatrolSettings.setAreaOfPatrolCommand.commandName, function(source, args) local source = source local permission = userHasPermission(source, main.automaticFires.enableAreaOfPatrolSettings.setAreaOfPatrolCommand) if permission then local areaSelected = string.lower(tostring(args[1])) if main.automaticFires.locations[areaSelected] ~= nil then if areaOfPatrol == "all" then TriggerClientEvent("Client:fireNotify", source, translations.allAreasOfPatrolOff) TriggerClientEvent("Client:fireLogAction", source, translations.updatedAreaOfPatrolToDefault) end areaOfPatrol = areaSelected TriggerClientEvent("Client:fireNotify", source, translations.areaOfPatrolUpdated..areaSelected..".") TriggerClientEvent("Client:fireLogAction", source, translations.updatedAreaOfPatrolTo..areaSelected..".") else TriggerClientEvent("Client:fireNotify", source, translations.invalidAreaOfPatrol) end else TriggerClientEvent("Client:fireNotify", source, translations.noPermission) end end, main.automaticFires.enableAreaOfPatrolSettings.setAreaOfPatrolCommand.acePermissions.enabled) end if main.automaticFires.enableAreaOfPatrolSettings.enabled and main.automaticFires.enableAreaOfPatrolSettings.toggleAllAreasOfPatrolCommand.enabled then RegisterCommand(main.automaticFires.enableAreaOfPatrolSettings.toggleAllAreasOfPatrolCommand.commandName, function(source, args) local source = source local permission = userHasPermission(source, main.automaticFires.enableAreaOfPatrolSettings.toggleAllAreasOfPatrolCommand) if permission then if areaOfPatrol == "all" then areaOfPatrol = main.automaticFires.enableAreaOfPatrolSettings.defaultAreaOfPatrol TriggerClientEvent("Client:fireNotify", source, translations.allAreasOfPatrolOff) TriggerClientEvent("Client:fireLogAction", source, translations.allAreasOfPatrolOffLog) else areaOfPatrol = "all" TriggerClientEvent("Client:fireNotify", source, translations.allAreasOfPatrolOn) TriggerClientEvent("Client:fireLogAction", source, translations.allAreasOfPatrolOnLog) end else TriggerClientEvent("Client:fireNotify", source, translations.noPermission) end end, main.automaticFires.enableAreaOfPatrolSettings.toggleAllAreasOfPatrolCommand.acePermissions.enabled) end if main.automaticFires.triggerAutomaticFireCommand.enabled then RegisterCommand(main.automaticFires.triggerAutomaticFireCommand.commandName, function(source, args) local source = source local permission = userHasPermission(source, main.automaticFires.triggerAutomaticFireCommand) if permission then triggerAutoFire(source) else TriggerClientEvent("Client:fireNotify", source, translations.noPermission) end end, main.automaticFires.toggleAutomaticFiresCommand.acePermissions.enabled) end if main.stopAllSmokeCommand.enabled then RegisterCommand(main.stopAllSmokeCommand.commandName, function(source, args) local source = source local successful = false local count = tableLength(smoke) if count > 0 then successful = true end local permission = userHasPermission(source, main.stopAllSmokeCommand) if permission then TriggerClientEvent("Client:stopAllSmokeCommand", source, successful, count) if successful then smoke = {} TriggerClientEvent("Client:clearAllSmoke", -1) end else TriggerClientEvent("Client:fireNotify", source, translations.noPermission) end end, main.stopAllSmokeCommand.acePermissions.enabled) end if main.stopSmokeCommand.enabled then RegisterCommand(main.stopSmokeCommand.commandName, function(source, args) local source = source local args = args local permission = userHasPermission(source, main.stopSmokeCommand) if permission then TriggerClientEvent("Client:stopSmokeCommand", source, args, true) else TriggerClientEvent("Client:fireNotify", source, translations.noPermission) end end, main.stopSmokeCommand.acePermissions.enabled) end if main.automaticFires.main.clockOnSystem.enabled then AddEventHandler('playerDropped', function (reason) clockedOn[source] = nil end) if main.automaticFires.main.clockOnSystem.clockOnCommand.enabled then RegisterCommand(main.automaticFires.main.clockOnSystem.clockOnCommand.commandName, function(source, args) local source = source if clockedOn[source] == nil then TriggerClientEvent("Client:fireNotify", source, translations.nowClockedOn) TriggerEvent("Server:userClockedOn", source) if main.logging.enabled then TriggerClientEvent("Client:fireLogAction", source, translations.clockedOnLog) end clockedOn[source] = true else if clockedOn[source] == true then TriggerClientEvent("Client:fireNotify", source, translations.alreadyClockedOn) else TriggerClientEvent("Client:fireNotify", source, translations.nowClockedOn) if main.logging.enabled then TriggerClientEvent("Client:fireLogAction", source, translations.clockedOnLog) end TriggerEvent("Server:userClockedOn", source) clockedOn[source] = true end end end, main.automaticFires.main.clockOnSystem.clockOnCommand.acePermissions.enabled) end if main.automaticFires.main.clockOnSystem.clockOffCommand.enabled then RegisterCommand(main.automaticFires.main.clockOnSystem.clockOffCommand.commandName, function(source, args) local source = source if clockedOn[source] == nil then TriggerClientEvent("Client:fireNotify", source, translations.alreadyClockedOff) clockedOn[source] = false else if clockedOn[source] == true then TriggerClientEvent("Client:fireNotify", source, translations.nowClockedOff) if main.logging.enabled then TriggerClientEvent("Client:fireLogAction", source, translations.clockedOffLog) end TriggerEvent("Server:userClockedOff", source) clockedOn[source] = false else TriggerClientEvent("Client:fireNotify", source, translations.alreadyClockedOff) end end end, false) end end local notificationCooldown = false function triggerFireNotification(id, message) if main.notifications.Cooldown.Enabled and notificationCooldown then return nil end local count, playerTable = checkJobsForAutomaticFires() if usingJobCheck then for k, v in pairs(playerTable) do TriggerClientEvent("Client:automaticFireAlert", k, id) end else TriggerClientEvent("Client:automaticFireAlert", -1, id) end local player = GetPlayers()[1] if player ~= nil and player ~= 0 then TriggerClientEvent("Client:fetchStreetName", player, id, fires[id].coords) local timeout = false Citizen.SetTimeout(2000, function() timeout = true end) while fires[id].streetName == nil and not timeout do Wait(0) end if fires[id].streetName == nil then fires[id].streetName = "Unknown Address" end else fires[id].streetName = "Unknown Address" end if main.fireAlerts.infernoPager.enabled then local message = {firstToUpper(fires[id].type), translations.fireDescription} if fires[id].automatic.created then message = {fires[id].automatic.type, translations.fireDescription} end TriggerClientEvent("Fire-EMS-Pager:PlayTones", -1, main.fireAlerts.infernoPager.pagersToTrigger, true, message) end if main.fireAlerts.infernoPagerReborn.enabled then local description = translations.fireDescription if fires[id].automatic.created then description = fires[id].automatic.type .. " " .. description else description = firstToUpper(fires[id].type) .. " " .. description end TriggerEvent("Inferno-Collection:Server:PagerReborn:Editable:CreatePage", { addresses = main.fireAlerts.infernoPagerReborn.addressesToPage, description = description, location = fires[id].streetName }) end if main.fireAlerts.psDispatch.enabled then local dispatchData = { coords = fires[id].coords, message = message, code = main.fireAlerts.psDispatch.code, codeName = main.fireAlerts.psDispatch.codeName, sprite = main.fireAlerts.psDispatch.sprite, color = main.fireAlerts.psDispatch.color, scale = main.fireAlerts.psDispatch.scale, length = main.fireAlerts.psDispatch.length, jobs = main.fireAlerts.psDispatch.jobs, priority = main.fireAlerts.psDispatch.priority, flash = main.fireAlerts.psDispatch.flash, icon = main.fireAlerts.psDispatch.icon, sound = main.fireAlerts.psDispatch.sound, alertTime = nil, alert = { sprite = main.fireAlerts.psDispatch.sprite, color = main.fireAlerts.psDispatch.color, scale = main.fireAlerts.psDispatch.scale, flash = main.fireAlerts.psDispatch.flash, sound = main.fireAlerts.psDispatch.sound, length = main.fireAlerts.psDispatch.length, }, } TriggerEvent('ps-dispatch:server:notify', dispatchData) end if main.fireAlerts.qsDispatch.enabled then TriggerEvent((main.fireAlerts.qsDispatch.resourceName .. ':server:CreateDispatchCall'), { job = main.fireAlerts.qsDispatch.jobs, callLocation = fires[id].coords, callCode = main.fireAlerts.qsDispatch.callCode, message = message, flashes = main.fireAlerts.qsDispatch.flashes, image = main.fireAlerts.qsDispatch.image, blip = { sprite = main.fireAlerts.qsDispatch.blipSprite, scale = main.fireAlerts.qsDispatch.blipScale, colour = main.fireAlerts.qsDispatch.blipColour, flashes = main.fireAlerts.qsDispatch.blipflash, text = main.fireAlerts.qsDispatch.blipText, time = main.fireAlerts.qsDispatch.blipTime, } }) end if main.fireAlerts.lbTablet.enabled then local dispatchId = exports["lb-tablet"]:AddDispatch({ priority = main.fireAlerts.lbTablet.priority, code = main.fireAlerts.lbTablet.code, title = main.fireAlerts.lbTablet.title, description = message, location = { label="", coords = {x = fires[id].coords.x, y = fires[id].coords.y}}, time = main.fireAlerts.lbTablet.time, image = main.fireAlerts.lbTablet.image, job = main.fireAlerts.lbTablet.job, sound = main.fireAlerts.lbTablet.sound, }) end if main.fireAlerts.tkDispatch.enabled then exports.tk_dispatch:addCall({ title = main.fireAlerts.tkDispatch.title, code = main.fireAlerts.tkDispatch.code, priority = main.fireAlerts.tkDispatch.priority, message = message, coords = fires[id].coords, location = fires[id].streetName, removeTime = main.fireAlerts.tkDispatch.removeTime, showTime = main.fireAlerts.tkDispatch.showTime, color = main.fireAlerts.tkDispatch.color, flash = main.fireAlerts.tkDispatch.flash, playSound = main.fireAlerts.tkDispatch.playSound, jobs = main.fireAlerts.tkDispatch.jobs, blip = { sprite = main.fireAlerts.tkDispatch.blip.sprite, scale = main.fireAlerts.tkDispatch.blip.scale, color = main.fireAlerts.tkDispatch.blip.color, }, }) end if main.fireAlerts.tkMdt.enabled then exports.tk_mdt:addCall({ title = main.fireAlerts.tkMdt.title, type = main.fireAlerts.tkMdt.type, time = main.fireAlerts.tkMdt.time, callsign = main.fireAlerts.tkMdt.callsign, location = fires[id].streetName, coords = fires[id].coords, }) end if main.fireAlerts.coreDispatch.enabled then for k, v in pairs(main.fireAlerts.coreDispatch.jobs) do exports['core_dispatch']:addCall(main.fireAlerts.coreDispatch.code, message, {}, {fires[id].coords.x, fires[id].coords.y, fires[id].coords.z}, v, main.fireAlerts.coreDispatch.notificationTime, main.fireAlerts.coreDispatch.blipSprite, main.fireAlerts.coreDispatch.blipColour, main.fireAlerts.coreDispatch.priority) end end if main.fireAlerts.emergencyDispatch.enabled then TriggerEvent('emergencydispatch:emergencycall:new', main.fireAlerts.emergencyDispatch.job, message, fires[id].coords, true) end if main.fireAlerts.rcoreDispatch.enabled then local data = { code = main.fireAlerts.rcoreDispatch.displayCode, default_priority = main.fireAlerts.rcoreDispatch.priority, coords = fires[id].coords, job = main.fireAlerts.rcoreDispatch.jobs, text = main.fireAlerts.rcoreDispatch.blipName, type = 'alerts', blip_time = main.fireAlerts.rcoreDispatch.blipTime, image = main.fireAlerts.rcoreDispatch.imageUrl, custom_sound = main.fireAlerts.rcoreDispatch.soundUrl, blip = { -- Blip table - optional, remove this table to disable blips sprite = main.fireAlerts.rcoreDispatch.blipSprite, colour = main.fireAlerts.rcoreDispatch.blipColour, scale = main.fireAlerts.rcoreDispatch.blipScale, text = main.fireAlerts.rcoreDispatch.blipName, flashes = main.fireAlerts.rcoreDispatch.blipFlash, radius = main.fireAlerts.rcoreDispatch.radius, } } TriggerEvent(main.fireAlerts.rcoreDispatch.resourceName .. ':server:sendAlert', data) end if main.fireAlerts.cdDispatch.enabled then TriggerClientEvent('cd_dispatch:AddNotification', -1, { job_table = main.fireAlerts.cdDispatch.jobs, coords = fires[id].coords, title = main.fireAlerts.cdDispatch.title, message = message, flash = 0, unique_id = tostring(math.random(0000000,9999999)), blip = { sprite = 431, scale = 1.2, colour = 3, flashes = false, text = message, time = (5*60*1000), sound = 1, } }) end if main.fireAlerts.cdDispatch3D.enabled then TriggerEvent('cd_dispatch:AddNotification', { job_table = main.fireAlerts.cdDispatch3D.jobs, coords = fires[id].coords, title = main.fireAlerts.cdDispatch3D.title, message = message, flash = main.fireAlerts.cdDispatch3D.flash, sound = main.fireAlerts.cdDispatch3D.sound, blip = main.fireAlerts.cdDispatch3D.blip }) end if main.fireAlerts.origenPolice.enabled then exports['origen_police']:SendAlert({ coords = fires[id].coords, title = main.fireAlerts.origenPolice.title, type = 'GENERAL', message = message, job = main.fireAlerts.origenPolice.job, }) end if main.fireAlerts.infernoStationAlert.enabled then exports["inferno-station-alert"]:newAlertNearestStationWithPlayers(fires[id].coords, { ["message"] = "-station-, " .. fires[id].streetName .. ", " .. "reported fire", ["unitColors"] = main.fireAlerts.infernoStationAlert.unitIndicatorColors, ["tone"] = main.fireAlerts.infernoStationAlert.tone }) end if main.fireAlerts.imperialCAD.enabled then local postal = "" if main.fireAlerts.imperialCAD.useNearestPostal then local postalCoords = {fires[id].coords.x, fires[id].coords.y, fires[id].coords.z} postal = exports['nearest-postal']:getPostalServer(postalCoords) end exports["ImperialCAD"]:CreateCall({ users_discordID = "", -- Not required street = fires[id].streetName, cross_street = fires[id].streetName, postal = postal, city = "", county = "", info = message, nature = "Fire", status = fires[id].status, priority = fires[id].priority }, function(success, resultData) -- you could manage the response here if needed end) end if main.fireAlerts.sonoranCAD.enabled then -- Fetch the street name from first client in players table local postal = "" if main.fireAlerts.sonoranCAD.useNearestPostal then local postalCoords = {fires[id].coords.x, fires[id].coords.y, fires[id].coords.z} postal = exports['nearest-postal']:getPostalServer(postalCoords) end exports.sonorancad.call911("Fire", fires[id].coords, message, postal) end if main.fireAlerts.nightsSoftwareMdt.enabled then exports.night_shifts:CreateEmergencyCallViaServer(true --[[isEmergency]], false --[[isPoliceRequired]], false --[[isAmbulanceRequired]], true --[[isFireRequired]], false --[[isTowRequired]], message, fires[id].streetName, "" --[[string]], "Fire Department" --[[string]], fires[id].coords --[[vector3]], "Fire Department" --[[string]]) end if main.fireAlerts.codeMDispatch.enabled then TriggerClientEvent("Client:fireNotificationCodeM", -1, fires[id].coords, message) end if main.notifications.Cooldown.Enabled and not notificationCooldown then notificationCooldown = true Citizen.SetTimeout(main.notifications.Cooldown.Duration, function() notificationCooldown = false end) end end function handleAutomaticFireCreation(playerTable) local firesCreated = {} local id = createFireId() local originalId = id local fire, autoFireDetails = generateRandomFire() fire.automatic.originalId = id fire.originalId = id if autoFireDetails.numberOfFlames ~= nil then local firesToCreate = autoFireDetails.numberOfFlames - 1 local radius = 2.0 if autoFireDetails.numberOfFlames > 4 then radius = 4.0 end for i=1,firesToCreate do local fire = generateNewFireFromExisting(fire, radius) local id = createFireId() fires[id] = fire TriggerClientEvent("Client:updateFireTable", -1, id, fire, false, false) table.insert(firesCreated, id) end end table.insert(firesCreated, id) fires[id] = fire TriggerClientEvent("Client:updateFireTable", -1, id, fire, false, false) local description = fire.automatic.type.." "..translations.fireDescription if main.fireAlerts.alertTypes.automaticFires then triggerFireNotification(id, description) end normalLog("", translations.automaticFireCreated, translations.idAutomatic..id..translations.typeAutomatic .. fires[id].automatic.type ..translations.descriptionAutomatic..description) TriggerEvent("Server:newAutomaticFire", id, fires[id].coords, description, fires[id].size) TriggerEvent("Server:newFireEvent", id, fires[id].coords, fires[id].size) if main.removeFiresAutomatically.automaticFires then -- Remove fire automatically after x amount of time Citizen.SetTimeout(main.removeFiresAutomatically.timer * 1000, function() -- for k, v in pairs(firesCreated) do -- if fires[v] ~= nil then -- TriggerClientEvent("Client:updateFireTable", -1, v, fires[v], true, false) -- fires[v] = nil -- end -- end if fires[id] ~= nil then TriggerClientEvent("Client:updateFireTable", -1, id, fires[id], true, false) end for k, v in pairs(fires) do if not v.original and v.originalId == id then TriggerClientEvent("Client:updateFireTable", -1, k, fires[k], true, false) fires[k] = nil end end fires[id] = nil end) end return id end if main.lighterFramework.QBCore then if main.lighterEnabled then Citizen.CreateThread(function() QBCore.Functions.CreateUseableItem("lighter", function(source, item) local src = source local Player = QBCore.Functions.GetPlayer(src) if Player.Functions.GetItemByName(item.name) then TriggerClientEvent("Client:FindNearbyDumpster", source) end end) end) end elseif main.lighterFramework.ESX then if main.lighterEnabled then Citizen.CreateThread(function() while ESX == nil do Wait(0) end ESX.RegisterUsableItem("lighter", function(source) TriggerClientEvent("Client:FindNearbyDumpster", source) end) end) end end if main.lighterFramework.oxInventory then if main.lighterEnabled then exports('useLighter', function(event, item, inventory, slot, data) if event == 'usingItem' then TriggerClientEvent("Client:FindNearbyDumpster", inventory.player.source) end end) end end Citizen.CreateThread(function() Wait(10000) while true do if automaticFiresEnabled then local count, playerTable = checkJobsForAutomaticFires() local numberOfFires = 0 if usingJobCheck then local newCount = math.floor((count / main.automaticFires.main.playersPerFire) + 0.5) if newCount < 1 then if count == main.automaticFires.main.playersPerFire then newCount = 1 else if count >= main.automaticFires.main.minimumNumberOfPlayers then newCount = 1 else newCount = 0 end end end numberOfFires = newCount if count == 0 then numberOfFires = 0 end else if count > 0 then numberOfFires = 1 else numberOfFires = 0 end end if numberOfFires > 0 then for i=0, numberOfFires do if automaticFiresEnabled then local count, playerTable = checkJobsForAutomaticFires() handleAutomaticFireCreation(playerTable) end interval = math.random(main.automaticFires.main.frequencyOfFires.min, main.automaticFires.main.frequencyOfFires.max) Wait((interval * 1000) / numberOfFires) end end if numberOfFires == 0 then interval = math.random(main.automaticFires.main.frequencyOfFires.min, main.automaticFires.main.frequencyOfFires.max) Wait(interval * 1000) else Wait(0) end else Wait(100) end end end) function userHasPermission(source, location) local permission = false local usingPermissions = false -- Ace Permissions if location.acePermissions.enabled then usingPermissions = true -- Ace Permission Validation (if enabled in config) if IsPlayerAceAllowed(source, "command."..location.commandName) then permission = true end end -- ESX Permissions if location.ESX.enabled then local xPlayer = ESX.GetPlayerFromId(source) if location.ESX.checkJob.enabled then usingPermissions = true for k, v in pairs(location.ESX.checkJob.jobs) do if xPlayer.job.name == v then permission = true end end end end -- vRP Permission if location.vRP.enabled then if location.vRP.checkPermission.enabled then usingPermissions = true for k, v in pairs(location.vRP.checkPermission.permissions) do if vRP.hasPermission({vRP.getUserId({source}),v}) then permission = true end end end if location.vRP.checkGroup.enabled then usingPermissions = true for k, v in pairs(location.vRP.checkGroup.groups) do if vRP.hasGroup({vRP.getUserId({source}),v}) then permission = true end end end end -- QBCore Permission if location.QBCore.enabled then local player = QBCore.Functions.GetPlayer(source) if location.QBCore.checkJob.enabled then usingPermissions = true for k, v in pairs(location.QBCore.checkJob.jobs) do if player.PlayerData.job.name == v then permission = true end end end if location.QBCore.checkPermission.enabled then usingPermissions = true for k, v in pairs(location.QBCore.checkPermission.permissions) do if QBCore.Functions.HasPermission(source, v) then permission = true end end end end if location.QBX.enabled then local player = exports.qbx_core:GetPlayer(source) usingPermissions = true for k, v in pairs(location.QBX.checkJob.jobs) do if player.PlayerData.job.name == v then permission = true end end end if not usingPermissions then permission = true end return permission end RegisterServerEvent("Server:newFireLog") AddEventHandler("Server:newFireLog", function(eKey, action, data) if eventKey == eKey then local source = source normalLog(source, action, data) end end) -- This handles the Discord logging system function normalLog(source, action, data) if not main.logging.enabled then return nil end local embed = {} if source == "" then embed = { { ["fields"] = { { ["name"] = "**Event:**", ["value"] = action, ["inline"] = false }, { ["name"] = "**Data:**", ["value"] = tostring(data), ["inline"] = false }, }, ["color"] = main.logging.colour, ["title"] = main.logging.title, ["description"] = "", ["footer"] = { ["text"] = "Timestamp: "..os.date(main.logging.dateFormat), ["icon_url"] = main.logging.footerIcon, }, ["thumbnail"] = { ["url"] = main.logging.icon, }, } } else embed = { { ["fields"] = { { ["name"] = "**Player:**", ["value"] = GetPlayerName(source).." ("..source..")", ["inline"] = true }, { ["name"] = "**Action:**", ["value"] = action, ["inline"] = false }, { ["name"] = "**Data:**", ["value"] = tostring(data), ["inline"] = false }, }, ["color"] = main.logging.colour, ["title"] = main.logging.title, ["description"] = "", ["footer"] = { ["text"] = "Timestamp: "..os.date(main.logging.dateFormat), ["icon_url"] = main.logging.footerIcon, }, ["thumbnail"] = { ["url"] = main.logging.icon, }, } } end PerformHttpRequest(main.logging.webhook, function(err, text, headers) end, 'POST', json.encode({username = main.logging.displayName, embeds = embed}), { ['Content-Type'] = 'application/json' }) end -- These setup the foundations for ESX / vRP / QBCore permissions if main.startFireCommand.ESX.enabled or main.stopFireCommand.ESX.enabled or main.stopAllFiresCommand.ESX.enabled or main.startSmokeCommand.ESX.enabled or main.stopSmokeCommand.ESX.enabled or main.stopAllSmokeCommand.ESX.enabled or main.automaticFires.main.ESX.enabled or main.lighterFramework.ESX then ESX = nil ESX = exports["es_extended"]:getSharedObject() end if main.startFireCommand.vRP.enabled or main.stopFireCommand.vRP.enabled or main.stopAllFiresCommand.vRP.enabled or main.startSmokeCommand.vRP.enabled or main.stopSmokeCommand.vRP.enabled or main.stopAllSmokeCommand.vRP.enabled or main.automaticFires.main.vRP.enabled then Proxy = module("vrp", "lib/Proxy") vRP = Proxy.getInterface("vRP") end if main.startFireCommand.QBCore.enabled or main.stopFireCommand.QBCore.enabled or main.stopAllFiresCommand.QBCore.enabled or main.startSmokeCommand.QBCore.enabled or main.stopSmokeCommand.QBCore.enabled or main.stopAllSmokeCommand.QBCore.enabled or main.automaticFires.main.QBCore.enabled or main.lighterFramework.QBCore then QBCore = exports["qb-core"]:GetCoreObject() end -- End of permissions setup function addMoneyToSociety() local amount = math.random(main.societyPayments.amountPerFire[1], main.societyPayments.amountPerFire[2]) if main.societyPayments.esxAddonAccount then TriggerEvent('esx_addonaccount:getSharedAccount', main.societyPayments.societyName, function(account) if account ~= nil then account.addMoney(amount) else print("ERROR: " .. main.societyPayments.societyName .. " requires a society in order to receive money!") end end) elseif main.societyPayments.qbBossMenu then TriggerEvent('qb-bossmenu:server:addAccountMoney', main.societyPayments.societyName, amount) elseif main.societyPayments.qbBanking then exports['qb-banking']:AddMoney(main.societyPayments.societyName, amount, "Smart Fires Society Payment") elseif main.societyPayments.okok then exports['okokBanking']:AddMoney(main.societyPayments.societyName, amount) elseif main.societyPayments.renewedBanking then exports['Renewed-Banking']:addAccountMoney(main.societyPayments.societyName, amount) elseif main.societyPayments.qsBanking then exports['qs-banking']:AddMoney(main.societyPayments.societyName, amount, "Smart Fires Society Payment") end end RegisterNetEvent("Server:returnStreetName", function(fireId, streetName) fires[fireId].streetName = streetName or nil end)