diff --git a/client.lua b/client.lua index 8644dc4..2cad792 100644 --- a/client.lua +++ b/client.lua @@ -4,8 +4,11 @@ local CreateThread = CreateThread player = {} player.injuries = {} -local hospitals = lib.load("data.hospitals") +local hospitals = lib.load("data.hospitals") +local emsJobs = lib.load("config").emsJobs +local clothingScript = lib.load("config").clothingScript +local debug = lib.load("config").debug local function createZones() for index, hospital in pairs(hospitals) do local cfg = hospital @@ -18,14 +21,14 @@ local function createZones() name = 'ars_hospital:' .. index, coords = cfg.zone.pos, size = cfg.zone.size, - clothes = Config.ClothingScript and cfg.clothes, - debug = Config.Debug, + clothes = clothingScript and cfg.clothes, + debug = debug, rotation = 0.0, onEnter = function(self) - initGarage(cfg.garage, Config.EmsJobs) + initGarage(cfg.garage, emsJobs) if self.clothes then - initClothes(self.clothes, Config.EmsJobs) + initClothes(self.clothes, emsJobs) end initParamedic() diff --git a/config.lua b/config.lua index 2d092bd..94e88fe 100644 --- a/config.lua +++ b/config.lua @@ -1,82 +1,80 @@ -lib.locale() +local Config = {} -Config = {} +Config.debug = false -Config.Debug = false +Config.useOxInventory = GetResourceState('ox_inventory'):find('start') -Config.UseOxInventory = GetResourceState('ox_inventory'):find('start') +Config.clothingScript = 'illenium-appearance' -- 'illenium-appearance', 'fivem-appearance', 'core' or false -- to disable +Config.emsJobs = { "ambulance", "ems" } +Config.respawnTime = 0 -- in minutes +Config.waitTimeForNewCall = 5 -- minutes -Config.ClothingScript = 'illenium-appearance' -- 'illenium-appearance', 'fivem-appearance' ,'core' or false -- to disable -Config.EmsJobs = { "ambulance", "ems" } -Config.RespawnTime = 0 -- in minutes -Config.WaitTimeForNewCall = 5 -- minutes +Config.reviveCommand = "revive" +Config.reviveAreaCommand = "revivearea" +Config.healCommand = "heal" +Config.healAreaCommand = "healarea" +Config.reviveAllCommand = "reviveall" -Config.ReviveCommand = "revive" -Config.ReviveAreaCommand = "revivearea" -Config.HealCommand = "heal" -Config.HealAreaCommand = "healarea" -Config.ReviveAllCommand = "reviveall" +Config.adminGroup = "group.admin" -Config.AdminGroup = "group.admin" +Config.medicBagProp = "xm_prop_x17_bag_med_01a" +Config.medicBagItem = "medicalbag" -Config.MedicBagProp = "xm_prop_x17_bag_med_01a" -Config.MedicBagItem = "medicalbag" +Config.tabletItem = "emstablet" -Config.TabletItem = "emstablet" +Config.helpCommand = "911" +Config.removeItemsOnRespawn = true +Config.keepItemsOnRespawn = { "money", "WEAPON_PISTOL" } -- items that will not be removed when respawed (works only when Config.RemoveItemsOnRespawn is true) -Config.HelpCommand = "911" -Config.RemoveItemsOnRespawn = true -Config.KeepItemsOnRespawn = { "money", "WEAPON_PISTOL" } -- items that will not be removed when respawed (works only when Config.RemoveItemsOnRespawn is true) +Config.baseInjuryReward = 150 +Config.reviveReward = 700 -Config.BaseInjuryReward = 150 -- changes if the injury value is higher then 1 -Config.ReviveReward = 700 +Config.paramedicTreatmentPrice = 4000 +Config.allowAlways = true -- false if you want it to work only when there are only medics online -Config.ParamedicTreatmentPrice = 4000 -Config.AllowAlways = true -- false if you want it to work only when there are only medics online +Config.ambulanceStretchers = 2 -- how many stretchers should an ambulance have +Config.consumeItemPerUse = 10 -- every time you use an item it gets used by 10% -Config.AmbulanceStretchers = 2 -- how many stretchers should an ambunalce have -Config.ConsumeItemPerUse = 10 -- every time you use an item it gets used by 10% +Config.timeToWaitForCommand = 2 -- when player dies he needs to wait 2 minutes to do the ambulance command +Config.npcReviveCommand = "ambulance" -- this will work only when there are no medics online -Config.TimeToWaitForCommand = 2 -- when player dies he needs to wait 2 minutes to do the ambulance command -Config.NpcReviveCommand = "ambulance" -- this will work only when there are no medics online +Config.usePedToDepositVehicle = false -- if false the vehicle will instantly despawns +Config.extraEffects = true -- false >> disables the screen shake and the black and white screen -Config.UsePedToDepositVehicle = false -- if false the vehicle will instantly despawns -Config.ExtraEffects = true -- false >> disables the screen shake and the black and white screen - -Config.EmsVehicles = { -- vehicles that have access to the props (cones and ecc..) - 'ambulance', - 'ambulance2', +Config.emsVehicles = { -- vehicles that have access to the props (cones and ecc..) + ambulance = true, + ambulance2 = true, } -Config.Animations = { - ["death_car"] = { +Config.animations = { + ["deathCar"] = { dict = "veh@low@front_ps@idle_duck", clip = "sit" }, - ["death_normal"] = { + ["deathNormal"] = { dict = "dead", clip = "dead_a" }, - ["get_up"] = { + ["getUp"] = { dict = "get_up@directional@movement@from_knees@action", clip = "getup_r_0" } } function Config.sendDistressCall(msg) - --[--] -- Quasar + -- [--] -- Quasar -- TriggerServerEvent('qs-smartphone:server:sendJobAlert', {message = msg, location = GetEntityCoords(PlayerPedId())}, "ambulance") - --[--] -- GKS + -- [--] -- GKS -- local myPos = GetEntityCoords(PlayerPedId()) -- local GPS = 'GPS: ' .. myPos.x .. ', ' .. myPos.y -- ESX.TriggerServerCallback('gksphone:namenumber', function(Races) - -- local name = Races[2].firstname .. ' ' .. Races[2].lastname + -- local name = Races[2].firstname .. ' ' .. Races[2].lastname - -- TriggerServerEvent('gksphone:jbmessage', name, Races[1].phone_number, msg, '', GPS, "ambulance") + -- TriggerServerEvent('gksphone:jbmessage', name, Races[1].phone_number, msg, '', GPS, "ambulance") -- end) end @@ -89,3 +87,5 @@ function Config.removeVehicleKeys(vehicle, plate) -- exaple usage -- exports['youscript']:name(vehicle, plate) end + +return Config diff --git a/data/body_part.lua b/data/body_part.lua new file mode 100644 index 0000000..e69de29 diff --git a/fxmanifest.lua b/fxmanifest.lua index 8a5e958..c5aa435 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -11,9 +11,10 @@ description 'Advanced ambulance job with intergrated death system' --#--Shared Scripts--#-- -shared_scripts { - '@ox_lib/init.lua', - 'config.lua', +shared_script '@ox_lib/init.lua' + +ox_libs { + 'locale', } --#--Cliend-Side Scripts--#-- @@ -53,5 +54,6 @@ server_scripts { --#--Additions Files--#-- files { 'locales/*.json', - "data/*.lua" + "data/*.lua", + 'config.lua', } diff --git a/modules/commands/server.lua b/modules/commands/server.lua index df026f2..92cb235 100644 --- a/modules/commands/server.lua +++ b/modules/commands/server.lua @@ -1,4 +1,7 @@ -lib.addCommand(Config.ReviveCommand, { +local adminGroups = lib.load("config").adminGroup +local reviveCommand = lib.load("config").reviveCommand + +lib.addCommand(reviveCommand, { help = locale("revive_player"), params = { { @@ -8,7 +11,7 @@ lib.addCommand(Config.ReviveCommand, { optional = true, }, }, - restricted = Config.AdminGroup + restricted = adminGroups }, function(source, args, raw) if not args.target then args.target = source end @@ -25,8 +28,8 @@ lib.addCommand(Config.ReviveCommand, { end end) - -lib.addCommand(Config.ReviveAreaCommand, { +local reviveAreaCommand = lib.load("config").reviveAreaCommand +lib.addCommand(reviveAreaCommand, { help = locale("revive_area"), params = { { @@ -36,7 +39,7 @@ lib.addCommand(Config.ReviveAreaCommand, { optional = false, }, }, - restricted = Config.AdminGroup + restricted = adminGroups }, function(source, args, raw) if source <= 0 then return print("^4ars_ambulancejob > ^0", "You cant run this command from console") end @@ -58,8 +61,8 @@ lib.addCommand(Config.ReviveAreaCommand, { TriggerClientEvent("ars_ambulancejob:showNotification", source, (locale("revived_area")):format(args.radius)) end) - -lib.addCommand(Config.HealCommand, { +local healCommand = lib.load("config").healCommand +lib.addCommand(healCommand, { help = locale("heal_player"), params = { { @@ -69,7 +72,7 @@ lib.addCommand(Config.HealCommand, { optional = true, }, }, - restricted = Config.AdminGroup + restricted = adminGroups }, function(source, args, raw) if not args.target then args.target = source end @@ -84,7 +87,8 @@ lib.addCommand(Config.HealCommand, { end end) -lib.addCommand(Config.HealAreaCommand, { +local healAreaCommand = lib.load("config").healAreaCommand +lib.addCommand(healAreaCommand, { help = locale("heal_area"), params = { { @@ -94,7 +98,7 @@ lib.addCommand(Config.HealAreaCommand, { optional = false, }, }, - restricted = Config.AdminGroup + restricted = adminGroups }, function(source, args, raw) if source <= 0 then return print("^4ars_ambulancejob > ^0", "You cant run this command from console") end @@ -115,9 +119,10 @@ lib.addCommand(Config.HealAreaCommand, { TriggerClientEvent("ars_ambulancejob:showNotification", source, (locale("healed_area")):format(args.radius)) end) -lib.addCommand(Config.ReviveAllCommand, { +local reviveAllCommand = lib.load("config").reviveAllCommand +lib.addCommand(reviveAllCommand, { help = locale("revive_all"), - restricted = Config.AdminGroup + restricted = adminGroups }, function(source, args, raw) local players = GetPlayers() diff --git a/modules/compatibility/frameworks/esx/client.lua b/modules/compatibility/frameworks/esx/client.lua index 11728f5..1fd3de6 100644 --- a/modules/compatibility/frameworks/esx/client.lua +++ b/modules/compatibility/frameworks/esx/client.lua @@ -3,7 +3,8 @@ local ESX = GetResourceState('es_extended'):find('start') and exports['es_extend if not ESX then return end Framework = {} -local ox_inventory = Config.UseOxInventory and exports.ox_inventory +local useOxInventory = lib.load("config").useOxInventory +local ox_inventory = useOxInventory and exports.ox_inventory RegisterNetEvent('esx:playerLoaded') AddEventHandler('esx:playerLoaded', function(playerData) @@ -18,6 +19,7 @@ AddEventHandler('esx:onPlayerLogout', function() player.isDead = false end) +local clothingScript = lib.load("config").clothingScript function Framework.toggleClothes(toggle, clothes) if toggle then utils.debug("Putting on clothes") @@ -28,8 +30,8 @@ function Framework.toggleClothes(toggle, clothes) utils.debug("Job Grade " .. jobGrade) - if Config.ClothingScript and Config.ClothingScript ~= 'core' then - local model = exports[Config.ClothingScript]:getPedModel(playerPed) + if clothingScript and clothingScript ~= 'core' then + local model = exports[clothingScript]:getPedModel(playerPed) if model == 'mp_m_freemode_01' then data = clothes.male[jobGrade] or clothes.male[1] @@ -58,7 +60,7 @@ function Framework.toggleClothes(toggle, clothes) lib.showContext('police_outfits') while not selected do Wait(500) end - utils.debug("Using " .. Config.ClothingScript) + utils.debug("Using " .. clothingScript) lib.progressBar({ duration = 3000, @@ -77,7 +79,7 @@ function Framework.toggleClothes(toggle, clothes) }, }) - exports[Config.ClothingScript]:setPedProps(playerPed, { + exports[clothingScript]:setPedProps(playerPed, { { component_id = 0, texture = data['helmet_2'], @@ -85,7 +87,7 @@ function Framework.toggleClothes(toggle, clothes) }, }) - exports[Config.ClothingScript]:setPedComponents(playerPed, { + exports[clothingScript]:setPedComponents(playerPed, { { component_id = 1, texture = data['mask_2'], @@ -137,8 +139,8 @@ function Framework.toggleClothes(toggle, clothes) drawable = data['bag'] }, }) - elseif Config.ClothingScript == 'core' then - utils.debug("Using " .. Config.ClothingScript) + elseif clothingScript == 'core' then + utils.debug("Using " .. clothingScript) ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin) local gender = skin.sex if gender == 0 then diff --git a/modules/compatibility/frameworks/esx/server.lua b/modules/compatibility/frameworks/esx/server.lua index a86ae2f..f227090 100644 --- a/modules/compatibility/frameworks/esx/server.lua +++ b/modules/compatibility/frameworks/esx/server.lua @@ -3,7 +3,8 @@ local ESX = GetResourceState('es_extended'):find('start') and exports['es_extend if not ESX then return end Framework = {} -local ox_inventory = Config.UseOxInventory and exports.ox_inventory +local useOxInventory = lib.load("config").useOxInventory +local ox_inventory = useOxInventory and exports.ox_inventory function Framework.removeAccountMoney(target, account, amount) local xPlayer = ESX.GetPlayerFromId(target) @@ -113,14 +114,18 @@ function Framework.wipeInventory(target, keep) end end -ESX.RegisterUsableItem(Config.MedicBagItem, function(source, a, b) - if not Framework.hasJob(source, Config.EmsJobs) then return end +local medicBagItem = lib.load("config").medicBagItem +local emsJobs = lib.load("config").emsJobs +local tabletItem = lib.load("config").tabletItem + +ESX.RegisterUsableItem(medicBagItem, function(source, a, b) + if not Framework.hasJob(source, emsJobs) then return end TriggerClientEvent("ars_ambulancejob:placeMedicalBag", source) end) -ESX.RegisterUsableItem(Config.TabletItem, function(source, a, b) - if not Framework.hasJob(source, Config.EmsJobs) then return end +ESX.RegisterUsableItem(tabletItem, function(source, a, b) + if not Framework.hasJob(source, emsJobs) then return end TriggerClientEvent("ars_ambulancejob:openDistressCalls", source) end) @@ -128,7 +133,7 @@ end) if GetResourceState('esx_society'):find('start') then CreateThread(function() - for k, v in pairs(Config.EmsJobs) do + for k, v in pairs(emsJobs) do TriggerEvent('esx_society:registerSociety', v, v, 'society_' .. v, 'society_' .. v, 'society_' .. v, { type = 'public' }) end end) diff --git a/modules/compatibility/frameworks/qb/client.lua b/modules/compatibility/frameworks/qb/client.lua index 9a57dd4..fbd2945 100644 --- a/modules/compatibility/frameworks/qb/client.lua +++ b/modules/compatibility/frameworks/qb/client.lua @@ -3,7 +3,8 @@ local QBCore = GetResourceState('qb-core'):find('start') and exports['qb-core']: if not QBCore then return end Framework = {} -local ox_inventory = Config.UseOxInventory and exports.ox_inventory +local useOxInventory = lib.load("config").useOxInventory +local ox_inventory = useOxInventory and exports.ox_inventory RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() @@ -17,6 +18,7 @@ RegisterNetEvent('QBCore:Client:OnPlayerUnload', function() player.isDead = false end) +local clothingScript = lib.load("config").clothingScript function Framework.toggleClothes(toggle, clothes) if toggle then utils.debug("Putting on clothes") @@ -28,8 +30,8 @@ function Framework.toggleClothes(toggle, clothes) utils.debug("Job Grade " .. jobGrade) - if Config.ClothingScript and Config.ClothingScript ~= 'core' then - local model = exports[Config.ClothingScript]:getPedModel(playerPed) + if clothingScript and clothingScript ~= 'core' then + local model = exports[clothingScript]:getPedModel(playerPed) if model == 'mp_m_freemode_01' then data = clothes.male[jobGrade] or clothes.male[1] @@ -58,7 +60,7 @@ function Framework.toggleClothes(toggle, clothes) lib.showContext('police_outfits') while not selected do Wait(500) end - utils.debug("Using " .. Config.ClothingScript) + utils.debug("Using " .. clothingScript) lib.progressBar({ duration = 3000, @@ -77,9 +79,9 @@ function Framework.toggleClothes(toggle, clothes) }, }) - utils.debug("Using " .. Config.ClothingScript) + utils.debug("Using " .. clothingScript) - exports[Config.ClothingScript]:setPedProps(playerPed, { + exports[clothingScript]:setPedProps(playerPed, { { component_id = 0, texture = data['helmet_2'], @@ -87,7 +89,7 @@ function Framework.toggleClothes(toggle, clothes) }, }) - exports[Config.ClothingScript]:setPedComponents(playerPed, { + exports[clothingScript]:setPedComponents(playerPed, { { component_id = 1, texture = data['mask_2'], @@ -139,8 +141,8 @@ function Framework.toggleClothes(toggle, clothes) drawable = data['bag'] }, }) - elseif Config.ClothingScript == 'core' then - utils.debug("Using " .. Config.ClothingScript) + elseif clothingScript == 'core' then + utils.debug("Using " .. clothingScript) if gender == 0 then data = clothes.male[jobGrade] or clothes.male[1] diff --git a/modules/compatibility/frameworks/qb/server.lua b/modules/compatibility/frameworks/qb/server.lua index e3842ed..9dd8ff0 100644 --- a/modules/compatibility/frameworks/qb/server.lua +++ b/modules/compatibility/frameworks/qb/server.lua @@ -3,7 +3,8 @@ QBCore = GetResourceState('qb-core'):find('start') and exports['qb-core']:GetCor if not QBCore then return end Framework = {} -local ox_inventory = Config.UseOxInventory and exports.ox_inventory +local useOxInventory = lib.load("config").useOxInventory +local ox_inventory = useOxInventory and exports.ox_inventory function Framework.removeAccountMoney(target, account, amount) local xPlayer = QBCore.Functions.GetPlayer(target) @@ -107,13 +108,17 @@ function Framework.wipeInventory(target, keep) exports["qb-inventory"]:ClearInventory(target, keep) end -QBCore.Functions.CreateUseableItem(Config.MedicBagItem, function(source, item) - if not Framework.hasJob(source, Config.EmsJobs) then return end +local medicBagItem = lib.load("config").medicBagItem +local emsJobs = lib.load("config").emsJobs +local tabletItem = lib.load("config").tabletItem + +QBCore.Functions.CreateUseableItem(medicBagItem, function(source, item) + if not Framework.hasJob(source, emsJobs) then return end TriggerClientEvent("ars_ambulancejob:placeMedicalBag", source) end) -QBCore.Functions.CreateUseableItem(Config.TabletItem, function(source, item) - if not Framework.hasJob(source, Config.EmsJobs) then return end +QBCore.Functions.CreateUseableItem(tabletItem, function(source, item) + if not Framework.hasJob(source, emsJobs) then return end TriggerClientEvent("ars_ambulancejob:openDistressCalls", source) end) diff --git a/modules/compatibility/target/qb-target.lua b/modules/compatibility/target/qb-target.lua index c9d665c..6e890fa 100644 --- a/modules/compatibility/target/qb-target.lua +++ b/modules/compatibility/target/qb-target.lua @@ -1,5 +1,5 @@ -if GetResourceState('qb-target') ~= 'started' then return end -print("qb target", GetResourceState('qb-target')) +if GetResourceState('qb-target') ~= 'started' or GetResourceState('ox_target') == 'started' then return end + local qb_target = exports['qb-target'] Target = {} diff --git a/modules/death/client.lua b/modules/death/client.lua index be082c9..eb0ddc2 100644 --- a/modules/death/client.lua +++ b/modules/death/client.lua @@ -24,7 +24,7 @@ local IsPedAPlayer = IsPedAPlayer local IsPedDeadOrDying = IsPedDeadOrDying local IsPedFatallyInjured = IsPedFatallyInjured - +local animations = lib.load("config").animations function stopPlayerDeath() player.isDead = false -- player.injuries = {} @@ -56,7 +56,7 @@ function stopPlayerDeath() AnimpostfxStopAll() DoScreenFadeIn(700) - TaskPlayAnim(playerPed, Config.Animations["get_up"].dict, Config.Animations["get_up"].clip, 8.0, -8.0, -1, 0, 0, 0, 0, 0) + TaskPlayAnim(playerPed, animations["get_up"].dict, animations["get_up"].clip, 8.0, -8.0, -1, 0, 0, 0, 0, 0) -- LocalPlayer.state:set("injuries", {}, true) LocalPlayer.state:set("dead", false, true) @@ -84,10 +84,11 @@ RegisterNetEvent("ars_ambulancejob:healPlayer", function(data) end end) +local removeItemsOnRespawn = lib.load("config").removeItemsOnRespawn local function respawnPlayer() local playerPed = cache.ped or PlayerPedId() - if Config.RemoveItemsOnRespawn then + if removeItemsOnRespawn then TriggerServerEvent("ars_ambulancejob:removeInventory") end @@ -134,19 +135,21 @@ local function respawnPlayer() player.respawning = false end +local useExtraEffects = lib.load("config").extraEffects +local respawnTime = lib.load("config").respawnTime local function initPlayerDeath(logged_dead) if player.isDead then return end player.isDead = true startCommandTimer() - for _, anim in pairs(Config.Animations) do + for _, anim in pairs(animations) do lib.requestAnimDict(anim.dict) end if logged_dead then goto logged_dead end - if Config.ExtraEffects then + if useExtraEffects then ShakeGameplayCam('DEATH_FAIL_IN_EFFECT_SHAKE', 1.0) AnimpostfxPlay('DeathFailOut', 0, true) @@ -180,7 +183,7 @@ local function initPlayerDeath(logged_dead) SetEntityHealth(cache.ped, 100) SetEveryoneIgnorePlayer(cache.playerId, true) - local time = 60000 * Config.RespawnTime + local time = 60000 * respawnTime local deathTime = GetGameTimer() CreateThread(function() @@ -189,7 +192,7 @@ local function initPlayerDeath(logged_dead) if not player.gettingRevived and not player.respawning then sleep = 0 - local anim = cache.vehicle and Config.Animations["death_car"] or Config.Animations["death_normal"] + local anim = cache.vehicle and animations["death_car"] or animations["death_normal"] if not IsEntityPlayingAnim(playerPed, anim.dict, anim.clip, 3) then TaskPlayAnim(playerPed, anim.dict, anim.clip, 50.0, 8.0, -1, 1, 1.0, false, false, false) diff --git a/modules/injuries/client.lua b/modules/injuries/client.lua index 6783dc9..a8092be 100644 --- a/modules/injuries/client.lua +++ b/modules/injuries/client.lua @@ -1,6 +1,8 @@ local TriggerServerEvent = TriggerServerEvent local GetPedLastDamageBone = GetPedLastDamageBone +local useOxInventory = lib.load("config").useOxInventory +local consumeItemPerUse = lib.load("config").consumeItemPerUse local function checkInjuryCause(cause) local item = "bandage" @@ -20,18 +22,18 @@ local function checkInjuryCause(cause) local hasItem = Framework.hasItem(item) if not hasItem then return utils.showNotification(locale("not_enough_" .. item)) end - if Config.UseOxInventory then + if useOxInventory then local itemDurability = utils.getItem(item)?.metadata?.durability if itemDurability then - if itemDurability < Config.ConsumeItemPerUse then + if itemDurability < consumeItemPerUse then utils.showNotification(locale("no_durability")) return false end end end - utils.useItem(item, Config.ConsumeItemPerUse) + utils.useItem(item, consumeItemPerUse) return true end diff --git a/modules/job/client/bossmenu.lua b/modules/job/client/bossmenu.lua index 1726fcc..cc1d73a 100644 --- a/modules/job/client/bossmenu.lua +++ b/modules/job/client/bossmenu.lua @@ -1,12 +1,12 @@ local hospitals = lib.load("data.hospitals") - +local emsJobs = lib.load("config").emsJobs for index, hospital in pairs(hospitals) do Target.addBoxZone(hospital.bossmenu.pos, { { name = "open_bossmenu" .. index, icon = 'fa-solid fa-road', label = locale("bossmenu_label"), - groups = Config.EmsJobs, + groups = emsJobs, fn = function(data) if Framework.getPlayerJobGrade() >= hospital.bossmenu.min_grade then Framework.openBossMenu(Framework.playerJob()) diff --git a/modules/job/client/clothing.lua b/modules/job/client/clothing.lua index 1a76ef0..b5e3191 100644 --- a/modules/job/client/clothing.lua +++ b/modules/job/client/clothing.lua @@ -1,4 +1,5 @@ -if not Config.ClothingScript then return end +local useInternalClothing = lib.load("config").clothingScript +if not useInternalClothing then return end local FreezeEntityPosition = FreezeEntityPosition local SetEntityInvincible = SetEntityInvincible diff --git a/modules/job/client/garage.lua b/modules/job/client/garage.lua index 7f29789..f96609e 100644 --- a/modules/job/client/garage.lua +++ b/modules/job/client/garage.lua @@ -15,6 +15,8 @@ local TaskVehicleDriveWander = TaskVehicleDriveWander local DeletePed = DeletePed local depositPositions = {} +local giveVehicleKeys = lib.load("config").giveVehicleKeys +local removeVehicleKeys = lib.load("config").removeVehicleKeys local function openCarList(garage) local vehicles = {} @@ -40,7 +42,7 @@ local function openCarList(garage) lib.setVehicleProperties(vehicle, v.modifications) local plate = lib.getVehicleProperties(vehicle).plate - Config.giveVehicleKeys(vehicle, plate) + giveVehicleKeys(vehicle, plate) TaskEnterVehicle(playerPed, vehicle, -1, -1, 1.0, 1, 0) end @@ -56,6 +58,7 @@ local function openCarList(garage) lib.showContext('vehicleList') end +local usePedToDepositVehicle = lib.load("config").usePedToDepositVehicle local function depositVehicle(data) if Framework.hasJob(data.jobs) then @@ -73,11 +76,11 @@ local function depositVehicle(data) local vehicleToDelete = playerVehicle local plate = lib.getVehicleProperties(playerVehicle).plate - Config.removeVehicleKeys(playerVehicle, plate) + removeVehicleKeys(playerVehicle, plate) lib.hideTextUI() - if Config.UsePedToDepositVehicle then + if usePedToDepositVehicle then local emsDriver = utils.createPed(data.model, data.driverSpawnCoords) FreezeEntityPosition(emsDriver, false) diff --git a/modules/job/client/main.lua b/modules/job/client/main.lua index e4281d8..0936335 100644 --- a/modules/job/client/main.lua +++ b/modules/job/client/main.lua @@ -22,6 +22,8 @@ local TriggerEvent = TriggerEvent local SetCurrentPedWeapon = SetCurrentPedWeapon local weapons = lib.load("data.weapons") +local useOxInventory = lib.load("config").useOxInventory +local consumeItemPerUse = lib.load("config").consumeItemPerUse local function checkPatient(target) local targetServerId = GetPlayerServerId(NetworkGetPlayerIndexFromPed(target)) @@ -73,11 +75,11 @@ local function checkPatient(target) local hasItem = Framework.hasItem("defibrillator") if not hasItem then return utils.showNotification(locale("not_enough_defibrillator")) end - if Config.UseOxInventory then + if useOxInventory then local itemDurability = utils.getItem("defibrillator")?.metadata?.durability if itemDurability then - if itemDurability < Config.ConsumeItemPerUse then return utils.showNotification(locale("no_durability")) end + if itemDurability < consumeItemPerUse then return utils.showNotification(locale("no_durability")) end end end @@ -112,12 +114,13 @@ local function checkPatient(target) lib.showContext('check_patient') end - +local timeForNewCall = lib.load("config").waitTimeForNewCall +local sendDistressCall = lib.load("config").sendDistressCall function createDistressCall() if player.distressCallTime then local currentTime = GetGameTimer() - utils.debug(currentTime - player.distressCallTime, 60000 * Config.WaitTimeForNewCall) - if currentTime - player.distressCallTime < 60000 * Config.WaitTimeForNewCall then + utils.debug(currentTime - player.distressCallTime, 60000 * timeForNewCall) + if currentTime - player.distressCallTime < 60000 * timeForNewCall then return utils.showNotification( locale("distress_call_in_cooldown")) end @@ -131,7 +134,7 @@ function createDistressCall() local msg = input[1] - Config.sendDistressCall(msg) + sendDistressCall(msg) local data = {} local playerCoords = cache.coords or GetEntityCoords(cache.ped) @@ -149,11 +152,15 @@ function createDistressCall() player.distressCallTime = GetGameTimer() end +local helpCommandName = lib.load("config").helpCommand + exports("createDistressCall", createDistressCall) -RegisterCommand(Config.HelpCommand, createDistressCall) +RegisterCommand(helpCommandName, createDistressCall) + +local emsJobs = lib.load("config").emsJobs function openDistressCalls() - if not Framework.hasJob(Config.EmsJobs) then return end + if not Framework.hasJob(emsJobs) then return end local playerPed = cache.ped or PlayerPedId() local playerCoords = cache.coords or GetEntityCoords(playerPed) @@ -257,7 +264,7 @@ Target.addGlobalPlayer({ name = 'check_suspect', icon = 'fas fa-magnifying-glass', label = locale('check_patient'), - groups = Config.EmsJobs, + groups = emsJobs, distance = 3, fn = function(data) checkPatient(type(data) == "number" and data or data.entity) @@ -267,7 +274,7 @@ Target.addGlobalPlayer({ name = 'put_on_stretcher', icon = 'fas fa-magnifying-glass', label = locale('put_on_stretcher'), - groups = Config.EmsJobs, + groups = emsJobs, distance = 3, cn = function(entity, distance, coords, name, bone) local _coords = GetEntityCoords(entity) @@ -281,7 +288,8 @@ Target.addGlobalPlayer({ }, }) - +local animations = lib.load("config").animations +local reviveReward = lib.load("config").reviveReward RegisterNetEvent("ars_ambulancejob:playHealAnim", function(data) local playerPed = cache.ped or PlayerPedId() local coords = GetEntityCoords(playerPed) @@ -316,11 +324,11 @@ RegisterNetEvent("ars_ambulancejob:playHealAnim", function(data) Wait(1000) - TaskPlayAnim(playerPed, Config.Animations["get_up"].dict, Config.Animations["get_up"].clip, 10.0, -10.0, -1, 0, 0, 0, 0, 0) + TaskPlayAnim(playerPed, animations["get_up"].dict, animations["get_up"].clip, 10.0, -10.0, -1, 0, 0, 0, 0, 0) - utils.useItem("defibrillator", Config.ConsumeItemPerUse) - utils.addRemoveItem("add", "money", Config.ReviveReward) + utils.useItem("defibrillator", consumeItemPerUse) + utils.addRemoveItem("add", "money", reviveReward) elseif data.anim == "dead" then utils.showNotification(locale("action_revived_notification")) @@ -362,7 +370,7 @@ end) RegisterNetEvent("ars_ambulancejob:createDistressCall", function(name) - if not Framework.hasJob(Config.EmsJobs) then return end + if not Framework.hasJob(emsJobs) then return end lib.notify({ title = locale("notification_new_call_title"), diff --git a/modules/job/client/medical_bag.lua b/modules/job/client/medical_bag.lua index b87783d..7b62338 100644 --- a/modules/job/client/medical_bag.lua +++ b/modules/job/client/medical_bag.lua @@ -8,6 +8,9 @@ local DeleteEntity = DeleteEntity local ClearPedTasks = ClearPedTasks local RegisterNetEvent = RegisterNetEvent +local medicBagProp = lib.load("config").medicBagProp +local useOxInventory = lib.load("config").useOxInventory + local function openMedicalBag() local playerPed = cache.ped or PlayerPedId() @@ -20,7 +23,7 @@ end local function placeMedicalBag() lib.requestAnimDict("pickup_object") - lib.requestModel(Config.MedicBagProp) + lib.requestModel(medicBagProp) local playerPed = cache.ped or PlayerPedId() local coords = GetOffsetFromEntityInWorldCoords(playerPed, 0.0, 0.5, 0.0) @@ -29,7 +32,7 @@ local function placeMedicalBag() Wait(900) - medicBag = CreateObjectNoOffset(Config.MedicBagProp, coords.x, coords.y, coords.z, true, false) + medicBag = CreateObjectNoOffset(medicBagProp, coords.x, coords.y, coords.z, true, false) PlaceObjectOnGroundProperly(medicBag) utils.addRemoveItem("remove", "medicalbag", 1) @@ -40,7 +43,7 @@ local function placeMedicalBag() icon = 'fa-solid fa-suitcase', groups = false, fn = function() - if not Config.UseOxInventory then + if not useOxInventory then return print("ONLY AVAILABLE FOR OX INVENTORY FOR NOW") end @@ -64,8 +67,10 @@ local function placeMedicalBag() }) end +local emsJobs = lib.load("config").emsJobs + RegisterNetEvent("ars_ambulancejob:placeMedicalBag", function() - if not Framework.hasJob(Config.EmsJobs) then return end + if not Framework.hasJob(emsJobs) then return end placeMedicalBag() end) diff --git a/modules/job/client/shops.lua b/modules/job/client/shops.lua index 5b22cd8..d6fe34f 100644 --- a/modules/job/client/shops.lua +++ b/modules/job/client/shops.lua @@ -1,8 +1,10 @@ local DrawMarker = DrawMarker local IsControlJustReleased = IsControlJustReleased local CreateThread = CreateThread -local ox_inventory = Config.UseOxInventory and exports.ox_inventory +local useOxInventory = lib.load("config").useOxInventory +local ox_inventory = useOxInventory and exports.ox_inventory local hospitals = lib.load("data.hospitals") +local emsJobs = lib.load("config").emsJobs local function createShops() for _, hospital in pairs(hospitals) do @@ -16,7 +18,7 @@ local function createShops() distance = 3, onEnter = function(self) if pharmacy.job then - if Framework.hasJob(Config.EmsJobs) and Framework.getPlayerJobGrade() >= pharmacy.grade then + if Framework.hasJob(emsJobs) and Framework.getPlayerJobGrade() >= pharmacy.grade then self.access = true lib.showTextUI(locale('control_to_open_shop')) else diff --git a/modules/job/client/stashes.lua b/modules/job/client/stashes.lua index 919d0c9..63dfdef 100644 --- a/modules/job/client/stashes.lua +++ b/modules/job/client/stashes.lua @@ -1,10 +1,12 @@ -if not Config.UseOxInventory then return end +local useOxInventory = lib.load("config").useOxInventory +if not useOxInventory then return end local DrawMarker = DrawMarker local IsControlJustReleased = IsControlJustReleased local CreateThread = CreateThread local hospitals = lib.load("data.hospitals") +local emsJobs = lib.load("config").emsJobs local function createStashes() for index, hospital in pairs(hospitals) do @@ -13,7 +15,7 @@ local function createStashes() coords = stash.pos, distance = 3, onEnter = function(self) - if Framework.hasJob(Config.EmsJobs) then + if Framework.hasJob(emsJobs) then lib.showTextUI(locale('control_to_open_stash')) end end, @@ -21,7 +23,7 @@ local function createStashes() lib.hideTextUI() end, nearby = function(self) - if Framework.hasJob(Config.EmsJobs) then + if Framework.hasJob(emsJobs) then DrawMarker(2, self.coords.x, self.coords.y, self.coords.z, 0.0, 0.0, 0.0, 180.0, 0.0, 0.0, 0.2, 0.2, 0.2, 199, 208, 209, 100, true, true, 2, nil, nil, false) diff --git a/modules/paramedic/client.lua b/modules/paramedic/client.lua index 5db67a6..c8489e7 100644 --- a/modules/paramedic/client.lua +++ b/modules/paramedic/client.lua @@ -1,14 +1,15 @@ -local DoScreenFadeOut = DoScreenFadeOut -local DoScreenFadeIn = DoScreenFadeIn -local GetEntityCoords = GetEntityCoords -local GetEntityMaxHealth = GetEntityMaxHealth -local IsScreenFadedOut = IsScreenFadedOut -local SetEntityCoords = SetEntityCoords -local SetEntityHeading = SetEntityHeading -local SetEntityHealth = SetEntityHealth -local TaskPlayAnim = TaskPlayAnim -local Wait = Wait - +local DoScreenFadeOut = DoScreenFadeOut +local DoScreenFadeIn = DoScreenFadeIn +local GetEntityCoords = GetEntityCoords +local GetEntityMaxHealth = GetEntityMaxHealth +local IsScreenFadedOut = IsScreenFadedOut +local SetEntityCoords = SetEntityCoords +local SetEntityHeading = SetEntityHeading +local SetEntityHealth = SetEntityHealth +local TaskPlayAnim = TaskPlayAnim +local Wait = Wait + +local paramedicTreatmentPrice = lib.load("config").paramedicTreatmentPrice local function openParamedicMenu(ped, hospital) lib.registerContext({ @@ -18,11 +19,11 @@ local function openParamedicMenu(ped, hospital) { title = locale("get_treated_paramedic"), onSelect = function() - local hasMoney = Framework.hasItem("money", Config.ParamedicTreatmentPrice) + local hasMoney = Framework.hasItem("money", paramedicTreatmentPrice) if not hasMoney then return utils.showNotification(locale("not_enough_money")) end - utils.addRemoveItem("remove", "money", Config.ParamedicTreatmentPrice) + utils.addRemoveItem("remove", "money", paramedicTreatmentPrice) local dict = lib.requestAnimDict("anim@gangops@morgue@table@") local playerPed = cache.ped or PlayerPedId() @@ -116,6 +117,7 @@ local function createAmbulanceDriver(vehicle) end local hospitals = lib.load("data.hospitals") +local allowAlwaysTreatment = lib.load("config").allowAlways function initParamedic() for index, hospital in pairs(hospitals) do @@ -131,7 +133,7 @@ function initParamedic() icon = 'fa-solid fa-ambulance', groups = false, fn = function() - if not Config.AllowAlways then + if not allowAlwaysTreatment then local medicsOnline = lib.callback.await('ars_ambulancejob:getMedicsOniline', false) if medicsOnline <= 0 then openParamedicMenu(ped, hospital) @@ -227,15 +229,15 @@ local function offlineRevive() DeleteEntity(ambulanceDriver) end +local timeToWaitForCommand = lib.load("config").timeToWaitForCommand * 60000 function startCommandTimer() CreateThread(function() local deathTime = GetGameTimer() - local TimeToWaitForCommand = Config.TimeToWaitForCommand * 60000 while player.isDead do local currentTime = GetGameTimer() local timePassed = currentTime - deathTime - player.timePassedForCommand = math.ceil((TimeToWaitForCommand - timePassed) / 1000) + player.timePassedForCommand = math.ceil((timeToWaitForCommand - timePassed) / 1000) utils.debug(player.timePassedForCommand) Wait(1000) @@ -243,4 +245,5 @@ function startCommandTimer() end) end -RegisterCommand(Config.NpcReviveCommand, offlineRevive) +local npcReviveCommand = lib.load("config").npcReviveCommand +RegisterCommand(npcReviveCommand, offlineRevive) diff --git a/modules/stretcher/client.lua b/modules/stretcher/client.lua index 83eede0..92d1579 100644 --- a/modules/stretcher/client.lua +++ b/modules/stretcher/client.lua @@ -28,12 +28,12 @@ local Wait = Wait local usingStretcher = false local currentStretcher = nil local patientOnStretcher = nil - +local emsJobs = lib.load("config").emsJobs local function isEmsVehicle(vehicle) local vehicleModel = GetEntityModel(vehicle) local vehicleClass = GetVehicleClass(vehicle) - for index, model in pairs(Config.EmsVehicles) do + for index, model in pairs(emsJobs) do if joaat(model) == vehicleModel or GetVehicleClassFromName(model) == vehicleClass then return true end end @@ -151,19 +151,21 @@ RegisterNetEvent("ars_ambulancejob:putOnStretcher", function(toggle) ClearPedTasks(playerPed) end end) +local ambulanceStretchers = lib.load("config").ambulanceStretchers + local function vehicleInteractions() local options = { { name = 'ars_ambulancejob_take_stretcher', icon = 'fa-solid fa-car-side', label = locale('take_stretcher'), - groups = Config.EmsJobs, + groups = emsJobs, cn = function(entity, distance, coords, name) return isEmsVehicle(entity) and not usingStretcher end, fn = function(data) local vehicle = type(data) == "number" and data or data.entity - if not Entity(vehicle).state.stretcher then Entity(vehicle).state.stretcher = Config.AmbulanceStretchers end + if not Entity(vehicle).state.stretcher then Entity(vehicle).state.stretcher = ambulanceStretchers end if Entity(vehicle).state.stretcher < 1 then return utils.showNotification(locale("no_stretcher_found")) end toggleStretcher(true) @@ -175,13 +177,13 @@ local function vehicleInteractions() name = 'ars_ambulancejob_put_stretcher', icon = 'fa-solid fa-car-side', label = locale('put_stretcher'), - groups = Config.EmsJobs, + groups = emsJobs, cn = function(entity, distance, coords, name) return isEmsVehicle(entity) and usingStretcher and not patientOnStretcher end, fn = function(data) local vehicle = type(data) == "number" and data or data.entity - if Entity(vehicle).state.stretcher >= Config.AmbulanceStretchers then return utils.showNotification(locale("stretcher_limit_reached")) end + if Entity(vehicle).state.stretcher >= ambulanceStretchers then return utils.showNotification(locale("stretcher_limit_reached")) end Entity(vehicle).state.stretcher += 1 @@ -192,7 +194,7 @@ local function vehicleInteractions() name = 'ars_ambulancejob_put_patient_in_vehicle', icon = 'fa-solid fa-car-side', label = locale('put_patient_in_vehicle'), - groups = Config.EmsJobs, + groups = emsJobs, cn = function(entity, distance, coords, name) return isEmsVehicle(entity) and usingStretcher and patientOnStretcher end, @@ -210,7 +212,7 @@ local function vehicleInteractions() name = 'ars_ambulancejob_take_patient_from_vehicle', icon = 'fa-solid fa-car-side', label = locale('take_patient_from_vehicle'), - groups = Config.EmsJobs, + groups = emsJobs, cn = function(entity, distance, coords, name) return isEmsVehicle(entity) and Entity(entity).state?.patient end, @@ -237,7 +239,7 @@ local function stretcherInteraction() name = 'ars_ambulancejob_stretcher_model', label = locale('take_stretcher'), icon = 'fa-solid fa-bed', - groups = Config.EmsJobs, + groups = emsJobs, distance = 3, cn = function() return not usingStretcher @@ -250,7 +252,7 @@ local function stretcherInteraction() name = 'ars_ambulancejob_remove_from_stretcher', icon = 'fa-solid fa-car-side', label = locale('remove_from_stretcher'), - groups = Config.EmsJobs, + groups = emsJobs, cn = function(entity, distance, coords, name) local playerId, playerPed, playerCoords = lib.getClosestPlayer(GetEntityCoords(entity), 2.0, false) return GetEntityAttachedTo(playerPed) == entity diff --git a/modules/utils/client/coords_debug.lua b/modules/utils/client/coords_debug.lua index f89d5ff..60cf785 100644 --- a/modules/utils/client/coords_debug.lua +++ b/modules/utils/client/coords_debug.lua @@ -1,4 +1,5 @@ -if not Config.Debug then return end +local debug = lib.load("config").debug +if not debug then return end local hospitals = lib.load("data.hospitals") for name, hospital in pairs(hospitals) do diff --git a/modules/utils/client/utils.lua b/modules/utils/client/utils.lua index ae69c79..8100002 100644 --- a/modules/utils/client/utils.lua +++ b/modules/utils/client/utils.lua @@ -28,8 +28,10 @@ function utils.showNotification(msg, type) }) end +local debug = lib.load("config").debug + function utils.debug(...) - if Config.Debug then + if debug then local args = { ... } for i = 1, #args do diff --git a/server.lua b/server.lua index 313336c..dde17a9 100644 --- a/server.lua +++ b/server.lua @@ -1,6 +1,8 @@ -player = {} -distressCalls = {} -local ox_inventory = Config.UseOxInventory and exports.ox_inventory +player = {} +distressCalls = {} +local emsJobs = lib.load("config").emsJobs +local useOxInventory = lib.load("config").useOxInventory +local ox_inventory = useOxInventory and exports.ox_inventory RegisterNetEvent("ars_ambulancejob:updateDeathStatus", function(death) local source = source @@ -14,7 +16,7 @@ end) RegisterNetEvent("ars_ambulancejob:revivePlayer", function(data) local source = source - if not Framework.hasJob(source, Config.EmsJobs) or not source or source < 1 then return end + if not Framework.hasJob(source, emsJobs) or not source or source < 1 then return end local sourcePed = GetPlayerPed(source) local targetPed = GetPlayerPed(data.targetServerId) @@ -31,7 +33,7 @@ end) RegisterNetEvent("ars_ambulancejob:healPlayer", function(data) local source = source - if not Framework.hasJob(source, Config.EmsJobs) or not source or source < 1 then return end + if not Framework.hasJob(source, emsJobs) or not source or source < 1 then return end local sourcePed = GetPlayerPed(source) @@ -70,7 +72,7 @@ RegisterNetEvent("ars_ambulancejob:createDistressCall", function(data) for i = 1, #players do local id = tonumber(players[i]) - if Framework.hasJob(id, Config.EmsJobs) then + if Framework.hasJob(id, emsJobs) then TriggerClientEvent("ars_ambulancejob:createDistressCall", id, playerName) end end @@ -94,7 +96,7 @@ RegisterNetEvent("ars_ambulancejob:removAddItem", function(data) end) RegisterNetEvent("ars_ambulancejob:useItem", function(data) - if not Framework.hasJob(source, Config.EmsJobs) then return end + if not Framework.hasJob(source, emsJobs) then return end if ox_inventory then local item = ox_inventory:GetSlotWithItem(source, data.item) @@ -105,11 +107,11 @@ RegisterNetEvent("ars_ambulancejob:useItem", function(data) Framework.removeItem(data.item) end) - +local removeItemsOnRespawn = lib.load("config").removeItemsOnRespawn RegisterNetEvent("ars_ambulancejob:removeInventory", function() local source = source - if player[source].isDead and Config.RemoveItemsOnRespawn then - Framework.wipeInventory(source, Config.KeepItemsOnRespawn) + if player[source].isDead and removeItemsOnRespawn then + Framework.wipeInventory(source, lib.load("config").keepItemsOnRespawn) end end) @@ -158,7 +160,7 @@ lib.callback.register('ars_ambulancejob:getMedicsOniline', function(source) for i = 1, #players do local id = tonumber(players[i]) - if Framework.hasJob(id, Config.EmsJobs) then + if Framework.hasJob(id, emsJobs) then count += 1 end end @@ -172,10 +174,10 @@ if ox_inventory then return item end) - + local medicBagItem = lib.load("config").medicBagItem ox_inventory:registerHook('swapItems', function(payload) if string.find(payload.toInventory, "medicalBag_") then - if payload.fromSlot.name == Config.MedicBagItem then return false end + if payload.fromSlot.name == medicBagItem then return false end end end, {})