Skip to content

Commit

Permalink
fix(server): RemoveItem
Browse files Browse the repository at this point in the history
* fix: RemoveItem

* remove ITEMS constant

* Update server/main.lua

Co-authored-by: Solareon <[email protected]>

---------

Co-authored-by: Solareon <[email protected]>
  • Loading branch information
mafewtm and solareon authored Jan 1, 2024
1 parent 4f4a254 commit 7f3d395
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions server/main.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
local ITEMS = exports.ox_inventory:Items()

---@alias source number

lib.callback.register('qbx_ambulancejob:server:getPlayerStatus', function(_, targetSrc)
Expand Down Expand Up @@ -37,8 +35,7 @@ RegisterNetEvent('hospital:server:TreatWounds', function(playerId)
local patient = exports.qbx_core:GetPlayer(playerId)
if player.PlayerData.job.name ~= 'ambulance' or not patient then return end

player.Functions.RemoveItem('bandage', 1)
TriggerClientEvent('inventory:client:ItemBox', src, ITEMS['bandage'], 'remove')
exports.ox_inventory:RemoveItem(src, 'bandage', 1)
TriggerClientEvent('hospital:client:HealInjuries', patient.PlayerData.source, 'full')
end)

Expand All @@ -49,8 +46,8 @@ RegisterNetEvent('hospital:server:RevivePlayer', function(playerId)
local patient = exports.qbx_core:GetPlayer(playerId)

if not patient then return end
player.Functions.RemoveItem('firstaid', 1)
TriggerClientEvent('inventory:client:ItemBox', player.PlayerData.source, ITEMS['firstaid'], 'remove')

exports.ox_inventory:RemoveItem(player.PlayerData.source, 'firstaid', 1)
TriggerClientEvent('qbx_medical:client:playerRevived', patient.PlayerData.source)
end)

Expand Down Expand Up @@ -131,7 +128,7 @@ local function triggerItemEventOnPlayer(src, item, event)
if player.Functions.GetItemByName(item.name) == nil then return end
local removeItem = lib.callback.await(event, src)
if not removeItem then return end
player.Functions.RemoveItem(item.name, 1)
exports.ox_inventory:RemoveItem(src, item.name, 1)
end

exports.qbx_core:CreateUseableItem('ifaks', function(source, item)
Expand Down

0 comments on commit 7f3d395

Please sign in to comment.