Scriptingintermediate9 min readupdated 11 Sept 2026

Dropping weapons when a player dies

The short answer

When the server learns a player died (from your ambulance/framework death event, or baseevents), read their inventory, remove the weapon items and create a ground drop at their position with exports.ox_inventory:CustomDrop('Weapons', items, coords) — passing each item’s metadata so serials, ammo and attachments survive. CreateDropFromPlayer drops the whole inventory instead. Skip police on duty and safe zones, and never trust a death report blindly.

Losing your gun when you go down makes fights matter: weapons become loot, police can seize evidence and gangs think twice before starting a war. With ox_inventory, dropping weapons on death is a few lines on the server — the main decisions are which weapons, for whom, and when.

Dropping weapons when a player dies — illustrated with a FiveM-compatible minimap render

#Dropping only weapons

server.lua
local function dropWeapons(src)
    local items = exports.ox_inventory:GetInventoryItems(src)
    if not items then return end

    local drop = {}
    for _, item in pairs(items) do
        if item.name:find('^WEAPON_') then
            if exports.ox_inventory:RemoveItem(src, item.name, item.count, item.metadata, item.slot) then
                drop[#drop + 1] = { item.name, item.count, item.metadata }
            end
        end
    end

    if #drop > 0 then
        local c = GetEntityCoords(GetPlayerPed(src))
        exports.ox_inventory:CustomDrop('Weapons', drop, vec3(c.x, c.y, c.z - 0.9))
    end
end

Passing item.metadata keeps the serial number, durability, loaded ammo and attachments — see serial numbers and item metadata.

#When to call it

SourceNotes
Your ambulance/death resourceBest — it already decides when someone is “dead” vs “downed”
Framework death eventsESX and QBCore ambulance jobs expose their own events
baseevents:onPlayerDied / onPlayerKilledSent by the client; validate (ped health, cooldown)
server.lua — with baseevents
local last = {}

AddEventHandler('baseevents:onPlayerDied', function()
    local src = source
    if GetEntityHealth(GetPlayerPed(src)) > 0 then return end
    if last[src] and os.time() - last[src] < 30 then return end
    last[src] = os.time()
    dropWeapons(src)
end)

#Dropping the whole inventory

exports.ox_inventory:CreateDropFromPlayer(src) creates a drop with a copy of the player’s items at their feet — clear the inventory afterwards if they should lose everything. Redzones and hardcore servers use this; most roleplay servers only drop weapons.

#Exceptions

  • On-duty police and EMS keep service weapons (check the job on the server).
  • No drops in safe zones or during events.
  • Skip if the player died from a fall or drowning, if that suits your rules.
  • Log drops of weapons with serials for police roleplay.
Share this guideXRedditFacebook

Questions

How do I make players drop weapons on death with ox_inventory?
On the server, remove the weapon items and create a drop with exports.ox_inventory:CustomDrop(prefix, items, coords), passing each item’s metadata.
Will the dropped weapon keep its serial?
Yes, if you pass the item’s metadata into the drop.
How do I drop the entire inventory?
exports.ox_inventory:CreateDropFromPlayer(playerId).
Can I trust baseevents death events?
They are sent by the client, so check the ped’s health and rate-limit before acting.

Ready to pick a map?

Twelve themes on three base map styles, $8 each, instant download.

Relevant to what you just read

The tool for this

Twenty theme pairs for ox_lib and ox_inventory From $15, built in the browser, exported as a drop-in resource.

Look it up while you work

The reference tables this guide leans on, free and without an account.

  • Every GTA 5 zone nameAll 291 popzones across 44 districts, with the ids GET_NAME_OF_ZONE and GET_ZONE_FROM_NAME_ID use.