i been working on this too and finally got it to work
client
ESX = nil
ReloadKey = 45
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
while true do
Citizen.Wait(0)
if IsControlJustReleased(1, ReloadKey) then
ESX.ShowNotification("You tried to reload1 Wooooo")
DisablePlayerFiring(GetPlayerPed(-1), true)
TriggerServerEvent('esx_clip:trigger_on_reload')
end
end
end)
RegisterNetEvent('esx_clip:clipcli')
AddEventHandler('esx_clip:clipcli', function()
ped = GetPlayerPed(-1)
if IsPedArmed(ped, 4) then
hash=GetSelectedPedWeapon(ped)
if hash~=nil then
TriggerServerEvent('esx_clip:remove')
local maxWeaponAmmo = GetMaxAmmoInClip(ped, hash, 1)
SetPedAmmo(GetPlayerPed(-1), hash, maxWeaponAmmo)
ESX.ShowNotification("You used an ammo clip")
else
ESX.ShowNotification("You aren't currently holding a weapon")
end
else
ESX.ShowNotification("This ammo clip isn't suitable for this weapon")
end
end)
RegisterNetEvent('esx_clip:reload')
AddEventHandler('esx_clip:reload', function()
MakePedReload(GetPlayerPed(-1))
end)
1 Like