ESX = nil
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj)
ESX = obj
end)
Citizen.Wait(0)
end
while ESX.GetPlayerData().job == nil do
Citizen.Wait(10)
end
ESX.PlayerData = ESX.GetPlayerData()
end)
RegisterNetEvent('disc-ammo:useAmmoItem')
AddEventHandler('disc-ammo:useAmmoItem', function(ammo)
local playerPed = GetPlayerPed(-1)
local weapon
local found, currentWeapon = GetCurrentPedWeapon(playerPed, true)
for _, v in pairs(ammo.weapons) do
if currentWeapon == v then
weapon = v
break
end
end
if weapon ~= nil then
local annen = exports["cylex_skillbar"]:taskBar(4500,math.random(5,15))
if annen == 100 then
local pedAmmo = GetAmmoInPedWeapon(playerPed, weapon)
local newAmmo = pedAmmo + ammo.count
ClearPedTasks(playerPed)
local found, maxAmmo = GetMaxAmmo(playerPed, weapon)
if newAmmo < maxAmmo then
TriggerServerEvent('disc-inventoryhud:updateAmmoCount', weapon, newAmmo)
TaskReloadWeapon(playerPed)
exports['mythic_notify']:SendAlert('inform', 'Mermi dolduruldu')
SetPedAmmo(playerPed, weapon, newAmmo)
TriggerServerEvent('disc-ammo:removeAmmoItem', ammo)
else
exports['mythic_notify']:SendAlert('error', 'Daha fazla mermi ekleyemezsin')
end
else
exports['mythic_notify']:SendAlert('error', 'Dolduramadın!')
end
else
exports['mythic_notify']:SendAlert('error', 'Elinde silah tutmalısın!')
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local playerPed = GetPlayerPed(-1)
local currentWeapon = GetSelectedPedWeapon(playerPed)
DisplayAmmoThisFrame(currentWeapon)
end
end)