# Removing and confiscating weapons in FiveM

> Remove weapons from players in FiveM the right way: natives, ox_inventory RemoveItem and ConfiscateInventory, QBCore, ESX, and disarming without deleting.

Source: https://fam-tools.com/guides/fivem-remove-weapon-from-player · FAM Tools · published 2026-09-19 · updated 2026-09-19 · about 11 min

**Short answer.** `RemoveWeaponFromPed(ped, hash)` and `RemoveAllPedWeapons(ped, true)` strip weapons from the ped and exist as server-side natives under OneSync. On an inventory server the item is the real weapon: use `exports.ox_inventory:RemoveItem`, `ConfiscateInventory` and `ReturnInventory`, QBCore's `RemoveItem`, or ESX's `xPlayer.removeWeapon`. To only holster the gun, set `WEAPON_UNARMED` or, on ox_inventory, trigger `ox_inventory:disarm` or set the `canUseWeapons` state bag to false.

## Key points

- Holster, remove from ped, and remove from inventory are three different operations.
- The natives only touch the ped; an inventory will hand the weapon back next time it is used.
- ox_inventory's `ConfiscateInventory` and `ReturnInventory` are built for jail and evidence.
- Set `canUseWeapons` to false to block weapons without taking anything away.
- Do removals on the server so a client cannot skip them.

Taking a gun away sounds like one native call, and on a bare server it is. On a roleplay server it is three different jobs that are easy to confuse: putting the weapon away, removing it from the ped, and removing it from the inventory that owns it. Get the wrong one and the weapon either comes straight back on the next equip or vanishes for good when you only meant to hold it for a jail sentence.

## Three different things called "remove"

Before writing any code, decide which of these you mean. Most bug reports about weapons "coming back" or "disappearing forever" are really about picking the wrong one.

*What each operation does*

| Goal | Example | Weapon kept? |
| --- | --- | --- |
| Put the weapon away | Entering a shop, using a phone | Yes, still owned |
| Block weapon use | Safe zone, handcuffed, knocked down | Yes, cannot be drawn |
| Remove from ped only | Standalone server, minigame loadout | Depends on who owns weapons |
| Remove from inventory | Police seizure, item destroyed | No |
| Confiscate and return later | Jail sentence | Stored, then returned |

On a standalone server without an inventory, the ped is the only place weapons live, so the natives are the whole story. On ox_inventory, qb-inventory or ESX, the inventory or loadout is the source of truth and the ped just holds a copy.

## The natives: RemoveWeaponFromPed and RemoveAllPedWeapons

`RemoveWeaponFromPed(ped, weaponHash)` removes one weapon. `RemoveAllPedWeapons(ped, p1)` removes everything; the reference notes that the second parameter is not used by the game, and scripts conventionally pass `true`. Both have server-side equivalents when OneSync is enabled, which is where they belong.

*server.lua*

```lua
local function stripPed(src, weaponName)
    local ped = GetPlayerPed(src)
    if ped == 0 then return end

    if weaponName then
        RemoveWeaponFromPed(ped, joaat(weaponName))
    else
        RemoveAllPedWeapons(ped, true)
    end
end
```

On the client the same calls work against `PlayerPedId()`, but a client-side removal is only as trustworthy as the client. A cheater can simply not run it. When removal is a punishment or a rule, do it from the server.

> **Ammo is separate** — Removing a weapon does not always clear its reserve ammunition. ESX's own removal code calls `SetPedAmmo(ped, hash, 0)` right after `RemoveWeaponFromPed` for that reason. Do the same when you strip a ped by hand.

## Holstering without removing anything

Often you do not want to take anything, you want the gun out of the player's hands: they walked into a clothing store, opened a phone, or started an animation. Switch the ped to unarmed.

*client.lua*

```lua
SetCurrentPedWeapon(PlayerPedId(), `WEAPON_UNARMED`, true)
```

On ox_inventory, do not fight the inventory with that native, because it tracks the equipped weapon and will log that the weapon was "forcibly unequipped". Ask ox_inventory to disarm instead. It exposes a client event for it that a server can trigger:

*server.lua*

```lua
TriggerClientEvent('ox_inventory:disarm', src, true) -- true skips the holster animation
```

To keep weapons unusable for a while (cuffed, in a safe zone, during a cutscene), ox_inventory reads a player state bag called `canUseWeapons`. When it turns false, the current weapon is disarmed and weapon items refuse to equip until it is true again.

*server.lua*

```lua
local function setWeaponsAllowed(src, allowed)
    Player(src).state:set('canUseWeapons', allowed, true)
end
```

The ox documentation shows the client-side form, `LocalPlayer.state.canUseWeapons = false`. Setting it from the server is better for anything a player should not be able to undo.

## ox_inventory: RemoveItem, ClearInventory and confiscation

With ox_inventory, a weapon is an item named after the weapon (`WEAPON_PISTOL`). Removing the item removes the weapon; if it happens to be equipped, ox_inventory disarms it.

*server.lua*

```lua
local ox = exports.ox_inventory

-- one specific weapon
ox:RemoveItem(src, 'WEAPON_PISTOL', 1)

-- a specific serial only, for evidence
ox:RemoveItem(src, 'WEAPON_PISTOL', 1, { serial = 'POL482913' })

-- everything except a few items
ox:ClearInventory(src, { 'phone', 'id_card' })
```

The export signatures from the ox documentation are `RemoveItem(inv, item, count, metadata, slot, ignoreTotal, strict)` and `ClearInventory(inv, keep)`. Passing metadata lets you remove the exact gun an officer is booking into evidence rather than whichever pistol comes first.

For jail and hospital flows use the pair that exists for it. `ConfiscateInventory(source)` takes the whole inventory and stores it; `ReturnInventory(source)` gives it back.

*server.lua*

```lua
RegisterNetEvent('jail:sentence', function(target, minutes)
    local src = source
    if not IsPlayerAceAllowed(src, 'jail.sentence') then return end

    exports.ox_inventory:ConfiscateInventory(target)
    SetTimeout(minutes * 60000, function()
        if GetPlayerName(target) then
            exports.ox_inventory:ReturnInventory(target)
        end
    end)
end)
```

In a real jail script the sentence should be stored, so a player who relogs mid-sentence is handled; the timeout above is only there to show the two calls.

## QBCore and qb-inventory

QBCore weapons are lowercase items (`weapon_pistol`) with `type = 'weapon'` in `shared/items.lua`. Remove them like any other item, through the player object or the inventory export whose signature is `RemoveItem(identifier, item, amount, slot, reason)`.

*server.lua*

```lua
local QBCore = exports['qb-core']:GetCoreObject()

local function removeAllWeapons(src)
    local Player = QBCore.Functions.GetPlayer(src)
    if not Player then return end

    for _, item in pairs(Player.PlayerData.items) do
        if item and item.type == 'weapon' then
            exports['qb-inventory']:RemoveItem(src, item.name, item.amount, item.slot, 'weapons-confiscated')
        end
    end
    RemoveAllPedWeapons(GetPlayerPed(src), true)
end
```

qb-inventory also has `ClearInventory(source, filterItems)`, which wipes everything except the item names you pass and removes the weapon currently in the player's hands. Item field details are in [QBCore shared items](https://fam-tools.com/guides/qbcore-shared-items).

## ESX Legacy loadout

ESX without ox_inventory keeps weapons in `xPlayer.loadout`. `xPlayer.removeWeapon(weaponName)` removes the attached components, calls `RemoveWeaponFromPed`, zeroes the ammo and deletes the entry from the loadout, which is everything you want in one call.

*server.lua*

```lua
local function stripLoadout(src)
    local xPlayer = ESX.GetPlayerFromId(src)
    if not xPlayer then return end

    local names = {}
    for _, weapon in ipairs(xPlayer.getLoadout()) do
        names[#names + 1] = weapon.name
    end
    for _, name in ipairs(names) do
        xPlayer.removeWeapon(name)
    end
end
```

The names are collected first because `getLoadout()` returns the live loadout table and `removeWeapon` removes entries from it; removing while iterating the same table skips every other weapon. If the server runs ox_inventory on top of ESX, ignore the loadout functions entirely and use the ox exports.

## Taking ammo or attachments instead of the gun

Sometimes the weapon should stay and only part of it should go: an officer unloads a seized rifle, a mechanic strips a suppressor, an event hands everyone an empty pistol. The natives for that are as simple as the removal ones.

*Partial removal natives*

| Goal | Native |
| --- | --- |
| Empty the weapon | `SetPedAmmo(ped, weaponHash, 0)` |
| Remove one attachment | `RemoveWeaponComponentFromPed(ped, weaponHash, componentHash)` |
| Check an attachment first | `HasPedGotWeaponComponent(ped, weaponHash, componentHash)` |

All three have server-side versions under OneSync. On ox_inventory, ammo and attachments are stored in the weapon item's metadata (`ammo` and `components`), so change them there or the inventory will restore them on the next equip. Find the slot with `Search`, edit the metadata and write it back with `SetMetadata(inv, slot, metadata)`.

*server.lua*

```lua
local function unloadWeapons(src, weaponName)
    local slots = exports.ox_inventory:Search(src, 'slots', weaponName)
    for _, item in pairs(slots or {}) do
        local meta = item.metadata or {}
        meta.ammo = 0
        exports.ox_inventory:SetMetadata(src, item.slot, meta)
    end
end
```

Hand the removed rounds back as ammo items if the scene calls for it; an officer who unloads a pistol should end up holding the magazine, not deleting it. [Ammo types and items](https://fam-tools.com/guides/fivem-ammo-types-and-items) lists the ox ammo item names, and [attachments](https://fam-tools.com/guides/ox-inventory-weapon-attachments) covers the component items.

## A protected disarm command

Staff need a quick way to disarm someone mid-scene. Keep the command on the server and restrict it with an ACE so a client event cannot be abused.

*server.lua*

```lua
RegisterCommand('disarm', function(source, args)
    local target = tonumber(args[1])
    if not target or not GetPlayerName(target) then
        return print('usage: /disarm <id>')
    end

    if GetResourceState('ox_inventory') == 'started' then
        TriggerClientEvent('ox_inventory:disarm', target, true)
    else
        SetCurrentPedWeapon(GetPlayerPed(target), `WEAPON_UNARMED`, true)
    end
    print(('%s disarmed %s'):format(source, target))
end, true)
```

*server.cfg*

```cfg
add_ace group.admin command.disarm allow
```

This only holsters the weapon. A separate `/confiscate` command that calls `ConfiscateInventory` is a better fit for anything that should actually take property away, and it should write to a log.

## Why removed weapons come back

- **Removed with a native on an inventory server.** The item is still in the inventory, so the next time the player uses it, it is equipped again. Remove the item.
- **Given with a native, removed by the inventory.** The mirror image: ox_inventory disarms weapons it did not equip when its `inventory:weaponmismatch` convar is on (the default). That is why a `GiveWeaponToPed` "gift" disappears. See [giving weapons](https://fam-tools.com/guides/fivem-give-weapon-to-player).
- **Removed on the client only.** Another resource or a relog restores the loadout from the database.
- **Removed before the player finished loading.** A disarm fired on join can run before the inventory has equipped anything. Trigger removals after your framework's player-loaded event.

## Questions

### How do I remove a weapon from a player in FiveM?

With a standalone setup call `RemoveWeaponFromPed(GetPlayerPed(src), joaat('WEAPON_PISTOL'))` on the server. On ox_inventory use `exports.ox_inventory:RemoveItem(src, 'WEAPON_PISTOL', 1)` so the item is removed too.

### How do I remove all weapons from a player?

`RemoveAllPedWeapons(ped, true)` clears the ped. On an inventory server also remove the weapon items, for example by looping the inventory or using ox_inventory's `ClearInventory` with a keep list.

### How do I take weapons away while a player is in jail?

Use `exports.ox_inventory:ConfiscateInventory(src)` when the sentence starts and `ReturnInventory(src)` when it ends. Store the sentence so it survives a relog.

### How do I stop a player using weapons without removing them?

On ox_inventory set the `canUseWeapons` player state bag to false. Without it, holster with `SetCurrentPedWeapon(ped, WEAPON_UNARMED, true)` and block firing with `DisablePlayerFiring` each frame.

### Why does the weapon come back after I remove it?

You removed it from the ped but not from the inventory or loadout that owns it. Remove the item or loadout entry as well.

## Related

- https://fam-tools.com/guides/fivem-give-weapon-to-player
- https://fam-tools.com/guides/ox-inventory-weapon-setup
- https://fam-tools.com/guides/fivem-drop-weapons-on-death
- https://fam-tools.com/guides/fivem-police-armory-setup
- https://fam-tools.com/guides/fivem-weapon-anticheat-validation
