RegisterNetEvent('disc-ammo:useAmmoItem')
AddEventHandler('disc-ammo:useAmmoItem', function(ammo)
local playerPed = GetPlayerPed(-1)
local weapon
local found, currentWeapon = GetCurrentPedWeapon(playerPed, true)
if found then
for _, v in pairs(ammo.weapons) do
if currentWeapon == v then
weapon = v
break
end
end
if weapon ~= nil then
local pedAmmo = GetAmmoInPedWeapon(playerPed, weapon)
local newAmmo = pedAmmo + ammo.count
ClearPedTasks(playerPed)
local found, maxAmmo = GetMaxAmmo(playerPed, weapon)
if newAmmo < maxAmmo then
if Config.EnableInventoryHUD then
TriggerServerEvent('m3:inventoryhud:server:updateAmmoCount', weapon, newAmmo)
end
TriggerEvent("c0dex:startskillbar", 1500, 10, 20, function(result)
if result then
TriggerServerEvent('disc-ammo:removeAmmoItem', ammo)
SetPedAmmo(playerPed, weapon, newAmmo)
exports['mythic_notify']:SendAlert('success', 'Mermi Dolduruldu')
else
exports["mythic_notify"]:SendAlert("error", "Mermiyi Dolduramadın",3500)
end
end)
else
exports['mythic_notify']:SendAlert('error', 'Cephane Full')
end
end
end
end)