# Dropping weapons when a player dies

> Make players drop weapons on death in FiveM: server-side detection, ox_inventory CustomDrop keeping serials and ammo, job exceptions and abuse prevention.

Source: https://fam-tools.com/guides/fivem-drop-weapons-on-death · FAM Tools · published 2026-09-11 · updated 2026-09-11 · about 9 min

**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.

## Key points

- Do it on the server, from a trustworthy death event.
- Keep item metadata (serial, ammo, components).
- `CustomDrop` for selected items, `CreateDropFromPlayer` for everything.
- Exceptions: police, events, safe zones.
- baseevents are client-reported — validate.

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 only weapons

*server.lua*

```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](https://fam-tools.com/guides/fivem-weapon-serial-numbers) and [item metadata](https://fam-tools.com/guides/ox-inventory-metadata).

## When to call it

| Source | Notes |
| --- | --- |
| Your ambulance/death resource | Best — it already decides when someone is “dead” vs “downed” |
| Framework death events | ESX and QBCore ambulance jobs expose their own events |
| `baseevents:onPlayerDied` / `onPlayerKilled` | Sent by the client; validate (ped health, cooldown) |

*server.lua — with baseevents*

```lua
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.

## 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.

## Related

- https://fam-tools.com/guides/fivem-weapon-serial-numbers
- https://fam-tools.com/guides/ox-inventory-metadata
- https://fam-tools.com/guides/fivem-redzone-pvp-weapon-setup
- https://fam-tools.com/guides/fivem-weapon-anticheat-validation
