Skip to content

Commit

Permalink
fix(client): reloading in vehicles
Browse files Browse the repository at this point in the history
Autoreloading would break the weapon (needed to re-equip).
Fixes #726
  • Loading branch information
thelindat committed Jun 3, 2022
1 parent c585e6a commit f13e048
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,26 @@ local function useSlot(slot)
local missingAmmo = 0
local newAmmo = 0
missingAmmo = maxAmmo - currentAmmo

if missingAmmo > data.count then newAmmo = currentAmmo + data.count else newAmmo = maxAmmo end
if newAmmo < 0 then newAmmo = 0 end

SetPedAmmo(playerPed, currentWeapon.hash, newAmmo)
MakePedReload(playerPed)

if not cache.vehicle then
MakePedReload(playerPed)
else
lib.disableControls:Add(68)
RefillAmmoInstantly(playerPed)
end

currentWeapon.metadata.ammo = newAmmo
TriggerServerEvent('ox_inventory:updateWeapon', 'load', currentWeapon.metadata.ammo)

if cache.vehicle then
Wait(300)
lib.disableControls:Remove(68)
end
end
end
end)
Expand Down Expand Up @@ -787,9 +801,9 @@ local function setStateBagHandler(id)
elseif key == 'invBusy' then
invBusy = value
if value then
lib.disableControls:Add(23, 25, 36, 263)
lib.disableControls:Add(23, 25, 36, 68, 263)
else
lib.disableControls:Remove(23, 25, 36, 263)
lib.disableControls:Remove(23, 25, 36, 68, 263)
end
elseif key == 'instance' then
currentInstance = value
Expand Down

0 comments on commit f13e048

Please sign in to comment.