Skip to content

Commit

Permalink
refactor(client): check if weapon can be equipped before using it
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Jun 6, 2023
1 parent 1a4d8b7 commit 9c82058
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,15 @@ local function useSlot(slot)

if IsCinematicCamRendering() then SetCinematicModeActive(false) end

GiveWeaponToPed(playerPed, data.hash, 0, false, true)
SetCurrentPedWeapon(playerPed, data.hash, true)

if data.hash ~= GetSelectedPedWeapon(playerPed) then
return lib.notify({ type = 'error', description = locale('cannot_use', data.label) })
end

RemoveAllPedWeapons(cache.ped, true)

if currentWeapon then
local weaponSlot = currentWeapon.slot
currentWeapon = Weapon.Disarm(currentWeapon)
Expand Down

0 comments on commit 9c82058

Please sign in to comment.