Choose qb-inventory or ox_inventory, follow the common fix, then jump to your branch. No comment lines, straight to the point 🏃♂️💨
Ox Inventory
✅ It should be true in server.cfg
setr inventory:weaponanims false
[Recommended] Go inside Ox Inventory and replace with (Pre-configured setup)
You do not need to make any changes. Just copy and paste the code.
Manual Edit (If you've already made the above file change, this part is not necessary)
🔁 Line: ~1222
In the ox_inventory:setPlayerInventory event, replace the block starting with if currentWeapon then with:
if currentWeapon then
if weaponHash ~= currentWeapon.hash and currentWeapon.timer then
local weaponCount = Items[currentWeapon.name]?.count
if weaponCount > 0 then
SetAmmoInClip(playerPed, currentWeapon.hash, currentWeapon.metadata.ammo)
SetPedCurrentWeaponVisible(playerPed, true, false, false, false)
weaponHash = GetSelectedPedWeapon(playerPed)
end
end
elseif client.weaponmismatch and not client.ignoreweapons[weaponHash] then
local weaponType = GetWeapontypeGroup(weaponHash)
if weaponType ~= 0 and weaponType ~= `GROUP_UNARMED` then
Weapon.Disarm(currentWeapon, true)
end
end
🔁 Line: 584
Inside the useSlot function, replace the useItem(data, function(result) block afterRemoveWeaponFromPed(cache.ped, data.hash) with:
useItem(data, function(result)
if result then
local sleep
currentWeapon, sleep = Weapon.Equip(item, data, noAnim)
if sleep then Wait(sleep) end
SetTimeout(WEAPON_SWITCH_COOLDOWN, function()
weaponCooldown = false
end)
else
weaponCooldown = false
end
end, noAnim)
🔁 Line: 554
In the same useSlot function, replace the block if CurrentWeapon thenaboveRemoveWeaponFromPed(cache.ped, data.hash) with:
if currentWeapon then
if data.slot == currentWeapon.slot then
currentWeapon = Weapon.Disarm(currentWeapon)
return
end
return lib.notify({ type = 'error', description = 'You already have a gun in your hand.' })
end
weaponCooldown = true
➕ Line: 524
At the start of the useSlot function, add this block:
if weaponCooldown or (currentWeapon and currentWeapon.timer and currentWeapon.timer - GetGameTimer() > 0) then
if not notifyCooldown then
notifyCooldown = true
lib.notify({ type = 'error', description = 'Please wait before switching weapons' })
SetTimeout(NOTIFY_COOLDOWN, function()
notifyCooldown = false
end)
end
return
end
➕ Line: 472
Above the useSlot function, add these local variables:
local weaponCooldown = false
local notifyCooldown = false
local WEAPON_SWITCH_COOLDOWN = 3000
local NOTIFY_COOLDOWN = 2000