This explains the small installation steps which are necessary for persistent death/armor across server restarts. You can remove qbx_ambulancejob and qbx_medical as this is a complete replacement.
ONE SYNC (WITH INFINITY) IS REQUIRED.
Metadata
Add these entries for metadata in qbx_core/server/player.lua if you do NOT have them already.
playerData.metadata.bleeding = playerData.metadata.bleeding or 0
REMOVE BANDAGE FROM OX INVENTORY.
-- REMOVE THIS FROM ox_inventory/modules/items/client.lua
Item('bandage', function(data, slot)
local maxHealth = GetEntityMaxHealth(cache.ped)
local health = GetEntityHealth(cache.ped)
ox_inventory:useItem(data, function(data)
if data then
SetEntityHealth(cache.ped, math.min(maxHealth, math.floor(health + maxHealth / 16)))
lib.notify({ description = 'You feel better already' })
end
end)
end)
-- EDIT the BANDAGE item from ox_inventory/data/items.lua (if it exists) so it looks like this
['bandage'] = {
label = 'Bandage',
weight = 115,
consume = 0,
server = {
export = 'randol_medical.bandage',
},
},
-- Add these items below if you wish to use them.
["firstaid"] = {
label = "First Aid",
weight = 2000,
stack = true,
close = true,
description = "",
consume = 0,
client = { image = "firstaid.png", },
server = {
export = 'randol_medical.firstaid',
},
},
["medicalbag"] = {
label = "Medical Bag",
weight = 500,
stack = true,
close = true,
consume = 0,
description = "A medical bag.",
client = { image = "medicalbag.png", },
server = { export = 'randol_medical.medicalbag', },
},
Adding new heal items
If adding a new heal item to the Server.HealItems table, you can simply add them to ox inventory items.lua like the following example:
local statusInterval = require 'config.client'.statusIntervalSeconds
local playerState = LocalPlayer.state
CreateThread(function()
local timeout = 1000 * statusInterval
while true do
Wait(timeout)
if QBX.IsLoggedIn then
if ((playerState.hunger or 0) <= 0 or (playerState.thirst or 0) <= 0) and not playerState.dead and not playerState.laststand then
local currentHealth = GetEntityHealth(cache.ped)
local decreaseThreshold = math.random(5, 10)
SetEntityHealth(cache.ped, currentHealth - decreaseThreshold)
end
end
end
end)