Skip to content

Commit

Permalink
refactored code
Browse files Browse the repository at this point in the history
  • Loading branch information
Arius-Scripts committed Jul 11, 2024
1 parent dfea8cd commit da922ed
Show file tree
Hide file tree
Showing 24 changed files with 235 additions and 175 deletions.
13 changes: 8 additions & 5 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
84 changes: 42 additions & 42 deletions config.lua
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -89,3 +87,5 @@ function Config.removeVehicleKeys(vehicle, plate)
-- exaple usage
-- exports['youscript']:name(vehicle, plate)
end

return Config
Empty file added data/body_part.lua
Empty file.
10 changes: 6 additions & 4 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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--#--
Expand Down Expand Up @@ -53,5 +54,6 @@ server_scripts {
--#--Additions Files--#--
files {
'locales/*.json',
"data/*.lua"
"data/*.lua",
'config.lua',
}
29 changes: 17 additions & 12 deletions modules/commands/server.lua
Original file line number Diff line number Diff line change
@@ -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 = {
{
Expand All @@ -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

Expand All @@ -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 = {
{
Expand All @@ -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

Expand All @@ -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 = {
{
Expand All @@ -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

Expand All @@ -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 = {
{
Expand All @@ -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

Expand All @@ -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()

Expand Down
18 changes: 10 additions & 8 deletions modules/compatibility/frameworks/esx/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
Expand All @@ -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]
Expand Down Expand Up @@ -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,
Expand All @@ -77,15 +79,15 @@ function Framework.toggleClothes(toggle, clothes)
},
})

exports[Config.ClothingScript]:setPedProps(playerPed, {
exports[clothingScript]:setPedProps(playerPed, {
{
component_id = 0,
texture = data['helmet_2'],
drawable = data['helmet_1']
},
})

exports[Config.ClothingScript]:setPedComponents(playerPed, {
exports[clothingScript]:setPedComponents(playerPed, {
{
component_id = 1,
texture = data['mask_2'],
Expand Down Expand Up @@ -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
Expand Down
17 changes: 11 additions & 6 deletions modules/compatibility/frameworks/esx/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -113,22 +114,26 @@ 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)


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)
Expand Down
Loading

0 comments on commit da922ed

Please sign in to comment.