How to Stop Put Away Weapon?

Any Idea how to cancel the put away weapon event/animation that triggers upon a gun reaching 0 ammo?
Current solution is to force equip the weapon when ammo is 0, but It’s not my favorite solution.

Citizen.CreateThread(function()
        while gunCheck do
           Citizen.Wait(0)
           if GetAmmoInPedWeapon(ped, 'weapon_pistol') == 0 then
                
           end
        end
end)

Old topic, but anyone got a solution?

There wasn’t any solution other than the one I provided above about checking to see when current ammo hit’s 0 re-equip the gun. Let me go through my inventory script and see if i can grab the exact code for you.

I ended up setteling on something like this

RegisterNetEvent('UseGun')

AddEventHandler('UseGun', function(gunName,item)

currentGun = item

local ped = GetPlayerPed(-1)

SetPedDropsWeaponsWhenDead(ped,false)

RemoveAllPedWeapons(ped, true)

local gunInfo = json.decode(item.Extra)

if gunInfo.ammo ~= 0 then

    gunCheck = true

end

GiveWeaponToPed(ped, GetHashKey(gunName), gunInfo.ammo, false, true)

for k,v in pairs(gunInfo.attatchments) do --give weapon attatchments here

    GiveWeaponComponentToPed(ped, GetHashKey(gunName), GetHashKey(gunAttatchments[currentGun.name][v]))

end

Citizen.CreateThread(function()

    while gunCheck do

       if GetAmmoInPedWeapon(ped, 'weapon_'..currentGun.name) == 0 then

            DoGunSave()

            SetCurrentPedWeapon(ped, 'weapon_'..currentGun.name, true)

       end

       Citizen.Wait(200)

    end

end)

end)

forgive me for not knowing how to use fourms for posting code snippets.

Thanks for replying! I will try and see what i can do with your snippet.
Have a great day :smiley:

My question to this snippet is, when does it know that gunCheck is false and what does DoGunSave()?

Do Gun Save was to save meta data to the item in my inventory script.
Whenver a player has no gun out, guncheck can be set to false. IE player holstered the weapon.

I believe storing the previous gun in a variable, then when the ammo hits 0. You must give the gun back to the “ped” (player). Its the only way. I experimented for hours with this 1

Maybe this will help someone one day. There are now two natives, since my last reply

Citizen.CreateThread(function()
	SetWeaponsNoAutoreload(true)
	SetWeaponsNoAutoswap(true)
end)