If you're using ox_inventory, after adding the above item codes to the ox_inventory/data/items.lua file, you’ll also need to follow the additional instructions below.
Add the following code to the ox_inventory/modules/items/client.lua file. You’ll notice that similar code already exists within the file.
Important Revive Event
Config.ReviveClientEvent = 'hospital:client:Revive' --# change your revive event this is default qb-core event
OPEN FILES
The files listed below are not encrypted. If you have the NO-ESCROW version, all files will be provided as fully open source.
Item('kankart', function(data, slot)
local metadata = slot.metadata
if metadata and metadata.kankartdata then
TriggerEvent("wert-ambulancejob:use-blood-card", metadata.kankartdata)
else
print("Blood Card Not Have Data Please Buy A New Card!")
end
end)
Item('emptysyringe', function(data, slot)
TriggerEvent('wert-ambulancejob:take-blood')
end)
Item('xray', function(data, slot)
local metadata = slot.metadata
if metadata and metadata.plan and metadata.hasta then
TriggerServerEvent("wert-ambulancejob:server:ox-inventory-use-xray", metadata.plan, metadata.hasta)
else
print("Xray Display Not Have Data Please Make A New!")
end
end)
Item('mri', function(data, slot)
local metadata = slot.metadata
if metadata and metadata.plan and metadata.hasta then
TriggerServerEvent("wert-ambulancejob:server:ox-inventory-use-mri", metadata.plan, metadata.hasta)
else
print("MRI Display Not Have Data Please Make A New!")
end
end)
local myCoreObj = exports['qb-core']:GetCoreObject()
function CustomNotifyVariation(text, style, time)
if Config.OxLib then
lib.notify({ title = 'Hospital', description = text, type = style, duration = time })
else
myCoreObj.Functions.Notify(text, style, time)
end
end
function CustomTextUI(show, text)
if show then
if Config.OxLib then
lib.showTextUI(text)
else
exports['qb-core']:DrawText(text, 'left')
end
else
if Config.OxLib then
lib.hideTextUI()
else
exports['qb-core']:HideText()
end
end
end
function CustomEntityTarget(entity, options)
if Config.TargetSystem == 'qb-target' then
exports["qb-target"]:AddTargetEntity(entity, { options = options, distance = 1.5 })
elseif Config.TargetSystem == 'ox_target' then
exports.ox_target:addLocalEntity(entity, options)
end
end
function CustomTargetAddBoxZone(zoneName, row, options)
if Config.TargetSystem == 'qb-target' then
exports['qb-target']:AddBoxZone(zoneName, row.coord, row.lenght, row.width, {
name = zoneName,
heading = row.heading,
debugPoly = Config.DebugPoly,
minZ = row.minz,
maxZ = row.maxz,
}, { options = options, distance = row.distance })
elseif Config.TargetSystem == 'ox_target' then
exports.ox_target:addBoxZone({
name = zoneName,
debug = Config.DebugPoly,
coords = row.coord,
rotation = row.heading,
size = vector3(row.lenght, row.width, row.width),
options = options
})
end
end
function CustomTargetAddModel(models, options)
if Config.TargetSystem == 'qb-target' then
exports["qb-target"]:AddTargetModel(models, { options = options, distance = 1.5 })
elseif Config.TargetSystem == 'ox_target' then
exports.ox_target:addModel(models, options)
end
end
function CustomProgressbar(data, cb)
if Config.OxLib then
if lib.progressBar({
duration = data.time,
label = data.label,
useWhileDead = false,
canCancel = true,
disable = {
move = data.move,
combat = data.combat,
mouse = data.mouse,
car = data.car,
},
anim = data.anim,
prop = data.prop,
}) then
cb('true')
else
cb('false')
end
else
if data.anim then
data.anim.animDict = data.anim.dict
data.anim.anim = data.anim.clip
data.anim.flags = data.anim.flag
end
if data.prop then
data.prop.coords = data.prop.pos
data.prop.rotation = data.prop.rot
end
myCoreObj.Functions.Progressbar(data.id, data.label, data.time, false, true, {
disableMovement = data.move,
disableCarMovement = data.car,
disableMouse = data.mouse,
disableCombat = data.combat,
}, data.anim or {}, data.prop or {}, {}, function()
cb('true')
end, function()
cb('false')
end)
end
end
function CustomGiveVehicleKey(veh, plate)
-- If u use another system u can edit it
TriggerEvent('vehiclekeys:client:SetOwner', plate)
end
function SetFuelAddonExport(veh, fuel)
-- If you use another fuel system you can edit here
if GetResourceState('LegacyFuel') == 'started' then exports['LegacyFuel']:SetFuel(veh, fuel) end
end
function CustomOpenBossMenu()
TriggerEvent("qb-bossmenu:client:OpenMenu")
end
-- # Events
RegisterNetEvent('wert-ambulancejob:client:custom-notify-variation', CustomNotifyVariation)
local listenForKey = false
local createdPeds = {}
-- # Functions
local function WertCustomLoadModel(model)
if HasModelLoaded(model) then return end
RequestModel(model)
while not HasModelLoaded(model) do
Wait(0)
end
end
local function WertCreateSystemPed(model, coord)
local npc = CreatePed(2, model, coord.x, coord.y, coord.z - 1.0, coord.w, false, true)
SetBlockingOfNonTemporaryEvents(npc, true)
SetPedDiesWhenInjured(npc, false)
SetPedCanPlayAmbientAnims(npc, true)
SetPedCanRagdollFromPlayerImpact(npc, false)
SetEntityInvincible(npc, true)
FreezeEntityPosition(npc, true)
createdPeds[#createdPeds+1] = npc
return npc
end
-- # Events
RegisterNetEvent('wert-ambulancejob:client:open-custom-stash', function()
if Config.QBInventoryNew then
TriggerServerEvent('wert-ambulancejob:server:open-custom-stash')
elseif Config.OxInventory then
exports.ox_inventory:openInventory('stash', { id = "EmsStash" })
else
TriggerEvent("inventory:client:SetCurrentStash", "EmsStash")
TriggerServerEvent("inventory:server:OpenInventory", "stash", "EmsStash", { maxweight = 2000000, slots = 100 })
end
end)
RegisterNetEvent('wert-ambulancejob:client:open-custom-shop', function()
if Config.QBInventoryNew then
TriggerServerEvent('wert-ambulancejob:server:open-custom-shop')
elseif Config.OxInventory then
exports.ox_inventory:openInventory('shop', {type = "ambulance", id = 1})
else
TriggerServerEvent("inventory:server:OpenInventory", "shop", "ambulance", Config.Items)
end
end)
-- # Threads
CreateThread(function()
Wait(1000)
for i = 1, #Config.TargetInfos do
local row = Config.TargetInfos[i]
local zoneName = row.action .. '_' .. i
local targetOptions = {}
if row.action == 'managecomputer' then
targetOptions[#targetOptions+1] = {
type = "client",
event = "wert-ambulancejob:patient-save",
icon = row.patientIcon,
label = row.patientLabel,
job = "ambulance",
distance = 1.5
}
if Config.UseBillSystem then
targetOptions[#targetOptions+1] = {
type = "client",
event = "wert-ambulancejob:ambulance-bill",
icon = row.billIcon,
label = row.billLabel,
job = "ambulance",
distance = 1.5
}
end
elseif row.action == 'armoryandstash' then
targetOptions = {
{
type = "client",
event = "wert-ambulancejob:client:open-custom-shop",
icon = row.armoryIcon,
label = row.armoryLabel,
job = "ambulance",
distance = 1.5
},
{
type = "client",
event = "wert-ambulancejob:client:open-custom-stash",
icon = row.stashIcon,
label = row.stashLabel,
job = "ambulance",
distance = 1.5
}
}
elseif row.action == 'mrdesk' then
targetOptions = {
{
type = "client",
icon = "fas fa-bed",
label = "MRI Desk",
action = function(entity) TriggerEvent("wert-ambulancejob:mr", "yat") end,
onSelect = function(entity) TriggerEvent("wert-ambulancejob:mr", "yat") end,
canInteract = function(entity) if not yatakta then return true else return false end end,
distance = 1.5
},
{
type = "client",
icon = "fas fa-bed",
label = "Get Up",
action = function(entity) TriggerEvent("wert-ambulancejob:mr", "kalk") end,
onSelect = function(entity) TriggerEvent("wert-ambulancejob:mr", "kalk") end,
canInteract = function(entity) if yatakta then return true else return false end end,
distance = 1.5
}
}
elseif row.action == 'xraydesk' then
targetOptions = {
{
type = "client",
icon = "fas fa-bed",
label = "XRAY Desk",
action = function(entity) TriggerEvent("wert-ambulancejob:xray", "yat") end,
onSelect = function(entity) TriggerEvent("wert-ambulancejob:xray", "yat") end,
canInteract = function(entity) if not yatakta then return true else return false end end,
distance = 1.5
},
{
type = "client",
icon = "fas fa-bed",
label = "Get Up",
action = function(entity) TriggerEvent("wert-ambulancejob:xray", "kalk") end,
onSelect = function(entity) TriggerEvent("wert-ambulancejob:xray", "kalk") end,
canInteract = function(entity) if yatakta then return true else return false end end,
distance = 1.5
}
}
else
targetOptions[#targetOptions+1] = {
type = "client",
event = "wert-ambulancejob:client:newTarget",
icon = row.icon,
label = row.label,
job = "ambulance",
ambTTaction = row.action,
distance = 1.5
}
end
CustomTargetAddBoxZone(zoneName, row, targetOptions)
end
-- # Coffe Machine
if Config.EnableCoffeSystem then
CustomTargetAddModel(Config.CoffeMachineModels, {
{
type = "client",
event = "wert-ambulancejob:make-coffee",
icon = "fas fa-beer-mug-empty",
label = "Coffe Machine",
distance = 1.5
},
})
end
-- # Water Cooler
if Config.EnableWaterCoolerSystem then
CustomTargetAddModel(Config.WaterCoolerModels, {
{
type = "client",
event = "wert-ambulancejob:sebil",
icon = "fas fa-droplet",
label = "Water Cooler",
distance = 1.5
},
})
end
-- # Elevators
for elevatorIdentifier in pairs(Config.ElevatorInfos) do
local elevatorData = Config.ElevatorInfos[elevatorIdentifier]
for floor, isData in pairs(elevatorData) do
CustomTargetAddBoxZone(floor.."EMSElevator_" .. elevatorIdentifier, {
coord = isData.Coord,
lenght = isData.Lenght,
width = isData.Width,
heading = isData.Heading,
coord = isData.Coord,
minz = isData.Minz,
maxz = isData.Maxz,
distance = isData.Distance
}, {
{
type = "client",
place = "Hospital",
icon = "fas fa-door-open",
label = "Elevator",
action = function(entity) TriggerEvent("wert-ambulancejob:use-elevator", floor, elevatorIdentifier) end,
onSelect = function(entity) TriggerEvent("wert-ambulancejob:use-elevator", floor, elevatorIdentifier) end,
},
})
end
end
-- # Npc Doctors
for i = 1, #Config.NpcDoctors do
local row = Config.NpcDoctors[i]
WertCustomLoadModel(row.model)
local hospitalped = WertCreateSystemPed(row.model, row.coord)
Wait(100)
CustomEntityTarget(hospitalped, {
{
place = "NpcDoctor",
icon = "fas fa-stethoscope",
label = row.name .. " Doctor",
action = function() TriggerEvent('wert-ambulancejob:client:npc-doctor-menu', row.name) end,
onSelect = function() TriggerEvent('wert-ambulancejob:client:npc-doctor-menu', row.name) end,
},
})
end
-- # Blood targets
for i = 1, #Config.BloodPackageLocations do
local row = Config.BloodPackageLocations[i]
CustomTargetAddBoxZone('EMSBloodPackaged'..i, row, {
{
type = 'client',
icon = 'fa-solid fa-droplet',
label = 'Packaged blood',
item = 'bloodtube',
action = function(entity) TriggerServerEvent('wert-ambulancejob:kan-paket') end,
onSelect = function(entity) TriggerServerEvent('wert-ambulancejob:kan-paket') end,
},
})
end
for i = 1, #Config.BloodBankLocations do
local row = Config.BloodPackageLocations[i]
CustomTargetAddBoxZone('EMSBloodBank'..i, row, {
{
type = 'client',
icon = 'fa-solid fa-server',
label = 'Load blood in the bank',
item = 'bloodbag',
action = function(entity) TriggerServerEvent('wert-ambulancejob:kan-load-bank') end,
onSelect = function(entity) TriggerServerEvent('wert-ambulancejob:kan-load-bank') end,
},
{
type = 'client',
icon = 'fa-solid fa-hand-holding-heart',
label = 'Take blood in the bank',
event = 'wert-ambulancejob:take-blood-in-bank'
},
})
end
-- # Garage
if Config.GarageEnabled then
for garageIdentifier in pairs(Config.GarageNpcInfos) do
local row = Config.GarageNpcInfos[garageIdentifier]
for k,v in pairs(row) do
WertCustomLoadModel(row.hash)
local garageped = WertCreateSystemPed(row.hash, row.coord)
Wait(100)
CustomEntityTarget(garageped, {
{
place = "WertGarageAmbulance",
icon = "fas fa-warehouse",
label = "Garage attendant ",
job = "ambulance",
action = function(entity) TriggerEvent("wert-ambulancejob:client:garage-menu", garageIdentifier, k) end,
onSelect = function() TriggerEvent("wert-ambulancejob:client:garage-menu", garageIdentifier, k) end,
},
})
end
end
local storeZones = {}
for i = 1, #Config.GarageStoreVehicleCoords do
local row = Config.GarageStoreVehicleCoords[i]
storeZones[#storeZones+1] = CircleZone:Create(row.coord, row.radius, { name = 'garageStoreAmbulancejob' .. i, debugPoly = Config.DebugPoly, useZ = true })
end
if #storeZones > 0 then
local storeComboZonbe = ComboZone:Create(garageZones, { name = 'garageStoreAmbulancejobCombo', debugPoly = Config.DebugPoly })
storeComboZonbe:onPlayerInOut(function(isPointInside, _, zone)
if isPointInside then
listenForKey = true
CreateThread(function()
while listenForKey do
Wait(1)
if IsControlJustReleased(0, 38) and IsPedInAnyVehicle(PlayerPedId()) and GetPedInVehicleSeat(GetVehiclePedIsIn(PlayerPedId(), false), -1) == PlayerPedId() then
listenForKey = false
CustomTextUI(false)
TriggerEvent('wert-ambulancejob:client:store-vehicle')
break
end
end
end)
CustomTextUI(true, '[E] Store Vehicle (EMS)')
else
listenForKey = false
CustomTextUI(false)
end
end)
end
end
end)
AddEventHandler('onResourceStop', function(resource)
if resource == GetCurrentResourceName() then
for i = 1, #createdPeds do DeleteEntity(createdPeds[i]) end -- Clear npc doctor peds
end
end)
LANG = {
["en"] = {
["sendbill"] = "Bill arrived!",
["doctormenu"] = "Pillbox hospital",
["doctorquestion"] = "Do you want to be treated ?",
["doctor"] = "Doctor :",
["npcdoctorprogress1"] = "You are being treated",
["npcdoctorprogress2"] = "Resting...",
["npcdoctorfinish"] = "Doctors finished treatment",
["npcdoctorcancel"] = "Treatment cancelled",
["garagemenu"] = "Garage menu",
["vehiclestored"] = "Vehicle stored!",
["bloodprogress1"] = "Taking a blood sample...",
["closestplayererror"] = "There is no one nearby!",
["bloodprogress2"] = "Package process...",
["bloodupload"] = "Blood load",
["selectbillplayer"] = "To whom do you want to send an invoice ?",
["billheader"] = "Bill",
["confirm"] = "Confirm",
["billprice"] = "Price ($)",
["billinvalid"] = "Invalid value",
["selectplan"] = "Select plan",
["selectpatient"] = "Select patient",
["invalidplan"] = "Please select a valid plan",
["mrprogress"] = "MR...",
["xrayprogress"] = "XRAY...",
["waterprogress"] = "Drinking...",
["coffeprogress"] = "The coffee machine is running...",
["preparingcoffe"] = "Preparing coffee...",
["coffeready"] = "Your coffee is ready",
["gotcoffe"] = "You got the coffee",
["alreadycoffe"] = "You already prepare coffe",
["selectfloor"] = "Select floor",
["floornum"] = "st Floor",
["exit"] = "Exit",
["elevatorprogress"] = "Elevator call...",
["cardprogressbar"] = 'Receiving card...',
["casherror"] = 'Not enough cash!',
["billsended"] = "Bill send price : ",
["itemerror"] = "Not enough item",
["bloodbank"] = "Blood bank",
["bloodamounterror"] = "Not enough blood",
["bloodmenuamount"] = "Amount :",
["bloodtaked"] = "Blood take from bank",
["tubeerror"] = "You dont have tube",
["notenoughmoney"] = "Not enough money",
["doctorsonlnie"] = "Doctor in city!",
["noemptybagg"] = "You dont have empty blood bag!",
['bloodtubenothavedata'] = "The blood found in the tube does not belong to anyone. Please take the blood from a player.",
['takevehicledescription'] = "Take vehicle from garage",
['clickForBill'] = 'Click for create bill!',
['selectAndStartAction'] = 'Click for start with this patient!',
},
}