local QBCore = exports['qb-core']:GetCoreObject() local CurrentCops = 0 local closestDesk = nil local CurrentCops = 0 local doctorCount = 0 local PlayerData = QBCore.Functions.GetPlayerData() local PlayerJob = QBCore.Functions.GetPlayerData().job -- Front Desk Target Zones local function FrontDeskZones() for k, v in pairs(Config.Locations) do exports['qb-target']:AddBoxZone(v.Zone.name, v.Zone.coords, v.Zone.length, v.Zone.width, { name = v.Zone.name, debugPoly = Config.Debug, heading = v.Zone.heading, minZ = v.Zone.minZ, maxZ = v.Zone.maxZ, }, { options = { { type = "client", action = function() TriggerEvent("qb-frontdesk:client:OpenFrontDesk", closestDesk) end, icon = "fas fa-desktop", label = "Reception", }, }, distance = 2.0 }) end end -- Gets closest front desk to pass the correct data CreateThread(function() while true do Wait(100) for k in pairs(Config.Locations) do local Pos = GetEntityCoords(PlayerPedId()) local Distance = #(Pos - vector3(Config.Locations[k].Zone.coords.x,Config.Locations[k].Zone.coords.y,Config.Locations[k].Zone.coords.z)) if Distance < 5 then closestDesk = k if Config.Debug then print(closestDesk) end else Wait(100) end end end end) -- Front Desk Menu RegisterNetEvent('qb-frontdesk:client:OpenFrontDesk',function(job) if PlayerJob.name == job then local FrontDeskMenu = { { header = Config.Locations[job].Zone.name, isMenuHeader = true, }, { header = 'Gå på arbejde/Gå hjem', icon = 'fas fa-power-off', params = { event = 'qb-frontdesk:client:ToggleDuty', args = job } }, { header = 'Assistance Menu', icon = 'fas fa-hand-holding-heart', params = { event = 'qb-frontdesk:client:OpenAssistanceMenu', args = job } }, { header = 'Luk Menu', icon = 'fas fa-x', }, } exports['qb-menu']:openMenu(FrontDeskMenu) else local FrontDeskMenu = { { header = Config.Locations[job].Zone.name, isMenuHeader = true, }, { header = 'Assistance Menu', icon = 'fas fa-hand-holding-heart', params = { event = 'qb-frontdesk:client:OpenAssistanceMenu', args = job } }, { header = 'Luk Menu', icon = 'fas fa-x', }, } exports['qb-menu']:openMenu(FrontDeskMenu) end end) -- Toggle Duty Event RegisterNetEvent('qb-frontdesk:client:ToggleDuty',function(job) if job == 'police' then TriggerEvent('qb-policejob:ToggleDuty') elseif job == 'ambulance' then TriggerEvent('EMSToggle:Duty') else TriggerServerEvent("QBCore:ToggleDuty") end end) -- Assistance Menu RegisterNetEvent('qb-frontdesk:client:OpenAssistanceMenu',function(job) local AssistanceMenu = {} AssistanceMenu[#AssistanceMenu + 1] = { header = 'Assistance Menu', txt = 'Vælg en valgmulighed', icon = 'fas fa-code', isMenuHeader = true, } for r, s in pairs(Config.Locations[job].Menu) do AssistanceMenu[#AssistanceMenu + 1] = { header = s.Header, txt = s.Txt, icon = s.Icon, params = { event = s.Event, args = { type = s.Args, job = job } } } end AssistanceMenu[#AssistanceMenu + 1] = { header = 'Tilbage', icon = 'fas fa-arrow-left-long', params = { event = 'qb-frontdesk:client:OpenFrontDesk' } } exports['qb-menu']:openMenu(AssistanceMenu) end) -- Request Assistance Event RegisterNetEvent('qb-frontdesk:client:RequestAssistance',function(data) QBCore.Functions.TriggerCallback('qb-frontdesk:server:CooldownCheck', function(alert) if alert then if Config.Dispatch == "default" then if data.job == 'police' then if CurrentCops >= Config.Locations[data.job].Required then QBCore.Functions.Notify('Du vil få hjælp snarligt!', 'success') if data.type == "assistance" then TriggerServerEvent('police:server:policeAlert', 'Assistance nødvendig') elseif data.type == "weaponlicense" then TriggerServerEvent('police:server:policeAlert', 'Våben licens anmodning') elseif data.type == "interview" then TriggerServerEvent('police:server:policeAlert', 'Interview anmodning') elseif data.type == "supervisor" then TriggerServerEvent('police:server:policeAlert', 'Leder anmodning') end TriggerServerEvent('qb-frontdesk:server:AlertCooldown', data.job, true) else QBCore.Functions.Notify('Ikke nok betjente på arbejde!', 'error', 3000) end elseif data.job == 'ambulance' then if doctorCount >= Config.Locations[data.job].Required then QBCore.Functions.Notify('Du vil få hjælp snarligt!', 'success') if data.type == "assistance" then TriggerServerEvent('hospital:server:ambulanceAlert', 'Assistance nødvendig') elseif data.type == "interview" then TriggerServerEvent('hospital:server:ambulanceAlert', 'Interview anmodning') elseif data.type == "supervisor" then TriggerServerEvent('hospital:server:ambulanceAlert', 'Leder anmodning') end TriggerServerEvent('qb-frontdesk:server:AlertCooldown', data.job, true) else QBCore.Functions.Notify('Ikke nok læger på arbejde!', 'error', 3000) end end elseif Config.Dispatch == "ps-dispatch" then local PlayerData = QBCore.Functions.GetPlayerData() local coords = GetEntityCoords(PlayerPedId()) if data.job == 'police' then if CurrentCops >= Config.Locations[data.job].Required then QBCore.Functions.Notify('Du vil få hjælp snarligt!', 'success') if data.type == "assistance" then exports["ps-dispatch"]:CustomAlert({ coords = Config.Locations['police'].Zone.coords, job = { 'police' }, message = "Assistance anmodet", dispatchCode = "10-60", firstStreet = coords, name = PlayerData.charinfo.firstname:sub(1,1):upper()..PlayerData.charinfo.firstname:sub(2).. " ".. PlayerData.charinfo.lastname:sub(1,1):upper()..PlayerData.charinfo.lastname:sub(2), description = "Assistance anmodet", radius = 0, sprite = 205, color = 2, scale = 1.0, length = 3, }) elseif data.type == "weaponlicense" then exports["ps-dispatch"]:CustomAlert({ coords = Config.Locations['police'].Zone.coords, job = { 'police' }, message = "Våben licens anmodet", dispatchCode = "10-60", firstStreet = coords, name = PlayerData.charinfo.firstname:sub(1,1):upper()..PlayerData.charinfo.firstname:sub(2).. " ".. PlayerData.charinfo.lastname:sub(1,1):upper()..PlayerData.charinfo.lastname:sub(2), description = "Våben licens anmodet", radius = 0, sprite = 205, color = 2, scale = 1.0, length = 3, }) elseif data.type == "interview" then exports["ps-dispatch"]:CustomAlert({ coords = Config.Locations['police'].Zone.coords, job = { 'police' }, message = "Interview anmodet", dispatchCode = "10-60", firstStreet = coords, name = PlayerData.charinfo.firstname:sub(1,1):upper()..PlayerData.charinfo.firstname:sub(2).. " ".. PlayerData.charinfo.lastname:sub(1,1):upper()..PlayerData.charinfo.lastname:sub(2), description = "Interview anmodet", radius = 0, sprite = 205, color = 2, scale = 1.0, length = 3, }) elseif data.type == "supervisor" then exports["ps-dispatch"]:CustomAlert({ coords = Config.Locations['police'].Zone.coords, job = { 'police' }, message = "Leder anmodet", dispatchCode = "10-60", firstStreet = coords, name = PlayerData.charinfo.firstname:sub(1,1):upper()..PlayerData.charinfo.firstname:sub(2).. " ".. PlayerData.charinfo.lastname:sub(1,1):upper()..PlayerData.charinfo.lastname:sub(2), description = "Leder anmodet", radius = 0, sprite = 205, color = 2, scale = 1.0, length = 3, }) end TriggerServerEvent('qb-frontdesk:server:AlertCooldown', data.job, true) else QBCore.Functions.Notify('Ikke nok betjente på arbejde!', 'error', 3000) end elseif data.job == 'ambulance' then if doctorCount >= Config.Locations[data.job].Required then QBCore.Functions.Notify('Du vil få hjælp snarligt!', 'success') if data.type == "assistance" then exports["ps-dispatch"]:CustomAlert({ coords = Config.Locations['ambulance'].Zone.coords, job = { 'ambulance' }, message = "Assistance anmodet", dispatchCode = "10-60", firstStreet = coords, name = PlayerData.charinfo.firstname:sub(1,1):upper()..PlayerData.charinfo.firstname:sub(2).. " ".. PlayerData.charinfo.lastname:sub(1,1):upper()..PlayerData.charinfo.lastname:sub(2), description = "Assistance anmodet", radius = 0, sprite = 205, color = 2, scale = 1.0, length = 3, }) elseif data.type == "interview" then exports["ps-dispatch"]:CustomAlert({ coords = Config.Locations['ambulance'].Zone.coords, job = { 'ambulance' }, message = "Interview anmodet", dispatchCode = "10-60", firstStreet = coords, name = PlayerData.charinfo.firstname:sub(1,1):upper()..PlayerData.charinfo.firstname:sub(2).. " ".. PlayerData.charinfo.lastname:sub(1,1):upper()..PlayerData.charinfo.lastname:sub(2), description = "Interview anmodet", radius = 0, sprite = 205, color = 2, scale = 1.0, length = 3, }) elseif data.type == "supervisor" then exports["ps-dispatch"]:CustomAlert({ coords = Config.Locations['ambulance'].Zone.coords, job = { 'ambulance' }, message = "Leder anmodet", dispatchCode = "10-60", firstStreet = coords, name = PlayerData.charinfo.firstname:sub(1,1):upper()..PlayerData.charinfo.firstname:sub(2).. " ".. PlayerData.charinfo.lastname:sub(1,1):upper()..PlayerData.charinfo.lastname:sub(2), description = "Leder anmodet", radius = 0, sprite = 205, color = 2, scale = 1.0, length = 3, }) end TriggerServerEvent('qb-frontdesk:server:AlertCooldown', data.job, true) else QBCore.Functions.Notify('Ikke nok læger på arbejde!', 'error', 3000) end end elseif Config.Dispatch == "cd_dispatch" then if data.job == 'police' then if CurrentCops >= Config.Locations[data.job].Required then QBCore.Functions.Notify('Du vil få hjælp snarligt!', 'success') if data.type == "assistance" then local data = exports['cd_dispatch']:GetPlayerInfo() TriggerServerEvent('cd_dispatch:AddNotification', { job_table = { 'police' }, coords = data.coords, title = '10-60 - Assistance anmodet', message = 'Assistance anmodet i reception', flash = 0, unique_id = tostring(math.random(0000000, 9999999)), blip = { sprite = 205, scale = 1.2, colour = 3, flashes = false, text = '114 - Assistance anmodet', time = (5 * 60 * 1000), sound = 1, }, }) elseif data.type == "weaponlicense" then local data = exports['cd_dispatch']:GetPlayerInfo() TriggerServerEvent('cd_dispatch:AddNotification', { job_table = { 'police' }, coords = data.coords, title = '10-60 - Våben license anmodning', message = 'Våben license anmodning i reception', flash = 0, unique_id = tostring(math.random(0000000, 9999999)), blip = { sprite = 205, scale = 1.2, colour = 3, flashes = false, text = '114 - Våben licens anmodning', time = (5 * 60 * 1000), sound = 1, }, }) elseif data.type == "interview" then local data = exports['cd_dispatch']:GetPlayerInfo() TriggerServerEvent('cd_dispatch:AddNotification', { job_table = { 'police' }, coords = data.coords, title = '10-60 - Interview anmodning', message = 'Interview anmodning i reception', flash = 0, unique_id = tostring(math.random(0000000, 9999999)), blip = { sprite = 205, scale = 1.2, colour = 3, flashes = false, text = '114 - Interview anmodning', time = (5 * 60 * 1000), sound = 1, }, }) elseif data.type == "supervisor" then local data = exports['cd_dispatch']:GetPlayerInfo() TriggerServerEvent('cd_dispatch:AddNotification', { job_table = { 'police' }, coords = data.coords, title = '10-60 - Leder anmodning', message = 'Leder anmodning i reception', flash = 0, unique_id = tostring(math.random(0000000, 9999999)), blip = { sprite = 205, scale = 1.2, colour = 3, flashes = false, text = '114 - Leder anmodning', time = (5 * 60 * 1000), sound = 1, }, }) end TriggerServerEvent('qb-frontdesk:server:AlertCooldown', data.job, true) else QBCore.Functions.Notify('Ikke nok betjente på arbjede!', 'error', 3000) end elseif data.job == 'ambulance' then if doctorCount >= Config.Locations[data.job].Required then QBCore.Functions.Notify('Du vil få hjælp snarligt!', 'success') if data.type == "assistance" then local data = exports['cd_dispatch']:GetPlayerInfo() TriggerServerEvent('cd_dispatch:AddNotification', { job_table = { 'ambulance' }, coords = data.coords, title = '10-60 - Assistance anmodet', message = 'Assistance anmodet i reception', flash = 0, unique_id = tostring(math.random(0000000, 9999999)), blip = { sprite = 205, scale = 1.2, colour = 3, flashes = false, text = '112 - Assistance anmodet', time = (5 * 60 * 1000), sound = 1, }, }) elseif data.type == "interview" then local data = exports['cd_dispatch']:GetPlayerInfo() TriggerServerEvent('cd_dispatch:AddNotification', { job_table = { 'ambulance' }, coords = data.coords, title = '10-60 - Interview anmodning', message = 'Interview anmodning i reception', flash = 0, unique_id = tostring(math.random(0000000, 9999999)), blip = { sprite = 205, scale = 1.2, colour = 3, flashes = false, text = '112 - Interview anmodning', time = (5 * 60 * 1000), sound = 1, }, }) elseif data.type == "supervisor" then local data = exports['cd_dispatch']:GetPlayerInfo() TriggerServerEvent('cd_dispatch:AddNotification', { job_table = { 'ambulance' }, coords = data.coords, title = '10-60 - Leder anmodning', message = 'Leder anmodning i reception', flash = 0, unique_id = tostring(math.random(0000000, 9999999)), blip = { sprite = 205, scale = 1.2, colour = 3, flashes = false, text = '112 - Leder anmodning', time = (5 * 60 * 1000), sound = 1, }, }) end TriggerServerEvent('qb-frontdesk:server:AlertCooldown', data.job, true) else QBCore.Functions.Notify('Ikke nok læger på arbejde!', 'error', 3000) end end -- ADD MORE JOBS BELOW -- DON'T FORGET TO ADD THEM TO YOUR CONFIG AS WELL -- elseif data.job == 'mechanic' then -- if doctorCount >= Config.Locations[data.job].Required then -- QBCore.Functions.Notify('Du vil få hjælp snarligt!', 'success') -- if data.type == "assistance" then -- local data = exports['cd_dispatch']:GetPlayerInfo() -- TriggerServerEvent('cd_dispatch:AddNotification', { job_table = { 'mechanic' }, coords = data.coords, title = 'Assitance Required', message = 'Assistance anmodet i reception', flash = 0, unique_id = tostring(math.random(0000000, 9999999)), blip = { sprite = 205, scale = 1.2, colour = 3, flashes = false, text = '112 - Assistance anmodet', time = (5 * 60 * 1000), sound = 1, }, }) -- elseif data.type == "weaponlicense" then -- local data = exports['cd_dispatch']:GetPlayerInfo() -- TriggerServerEvent('cd_dispatch:AddNotification', { job_table = { 'mechanic' }, coords = data.coords, title = 'Upgrade' Request', message = 'Sucker at the front desk', flash = 0, unique_id = tostring(math.random(0000000, 9999999)), blip = { sprite = 205, scale = 1.2, colour = 3, flashes = false, text = 'Someone wanna go fast', time = (5 * 60 * 1000), sound = 1, }, }) -- elseif data.type == "interview" then -- local data = exports['cd_dispatch']:GetPlayerInfo() -- TriggerServerEvent('cd_dispatch:AddNotification', { job_table = { 'mechanic' }, coords = data.coords, title = '10-60 - Interview Request', message = 'Interview anmodning i reception', flash = 0, unique_id = tostring(math.random(0000000, 9999999)), blip = { sprite = 205, scale = 1.2, colour = 3, flashes = false, text = '112 - Interview anmodning', time = (5 * 60 * 1000), sound = 1, }, }) -- elseif data.type == "supervisor" then -- local data = exports['cd_dispatch']:GetPlayerInfo() -- TriggerServerEvent('cd_dispatch:AddNotification', { job_table = { 'mechanic' }, coords = data.coords, title = 'Karen Alert', message = 'Karen at the Front Desk', flash = 0, unique_id = tostring(math.random(0000000, 9999999)), blip = { sprite = 205, scale = 1.2, colour = 3, flashes = false, text = 'Supervisor Request', time = (5 * 60 * 1000), sound = 1, }, }) -- end -- TriggerServerEvent('qb-frontdesk:server:AlertCooldown', data.job, true) -- else -- QBCore.Functions.Notify('Not enough doctors on duty!', 'error', 3000) -- end -- end end else QBCore.Functions.Notify('Alarm sendt for lidt siden, vent venligst!', 'error', 7500) end end, data.job) end) RegisterNetEvent('police:SetCopCount', function(amount) CurrentCops = amount end) RegisterNetEvent('hospital:client:SetDoctorCount', function(amount) doctorCount = amount end) RegisterNetEvent('QBCore:Client:OnJobUpdate', function(JobInfo) PlayerJob = JobInfo end) RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() PlayerData = QBCore.Functions.GetPlayerData() PlayerJob = QBCore.Functions.GetPlayerData().job FrontDeskZones() end) RegisterNetEvent('QBCore:Client:OnPlayerUnload', function() PlayerData = {} end) AddEventHandler('onResourceStart', function(resource) if resource == GetCurrentResourceName() then PlayerData = QBCore.Functions.GetPlayerData() PlayerJob = QBCore.Functions.GetPlayerData().job FrontDeskZones() end end) AddEventHandler('onResourceStop', function(resource) if resource == GetCurrentResourceName() then for k, v in pairs(Config.Locations) do exports['qb-target']:RemoveZone(v.Zone.name) end end end)