ESX = nil
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj)
ESX = obj
end)
Citizen.Wait(0)
end
end)
local dolduruyor = false
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
TriggerEvent("mythic_progbar:client
rogress", {
name = "",
duration = 5000,
label = 'Mermi Dolduruyorsun...',
useWhileDead = false,
canCancel = true,
controlDisables = {
disableMovement = false,
disableCarMovement = false,
disableMouse = false,
disableCombat = false,
},
}, function(cancelled)
if not cancelled then
TriggerServerEvent('m3:inventoryhud:server:updateAmmoCount', weapon, newAmmo)
SetPedAmmo(playerPed, weapon, newAmmo)
TriggerServerEvent('disc-ammo:removeAmmoItem', ammo)
end
end)
else
exports['mythic_notify']:SendAlert('error', 'Şarjör tamamen dolu!')
end
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(5)
local player = PlayerPedId()
if IsPedArmed(player, 4) then
local currentWeapon = GetSelectedPedWeapon(player) --morpheause show ammo fix
DisplayAmmoThisFrame(currentWeapon)
local found, currentWeapon = GetCurrentPedWeapon(player, true)
if found then
if currentWeapon ~= 911657153 then --stungun fix
local pedAmmo = GetAmmoInPedWeapon(player, currentWeapon)
if pedAmmo < 2 then
DisableControlAction(0, 24, true) -- Attack
DisableControlAction(0, 257, true) -- Attack 2
if IsPedInAnyVehicle(player, true) then
SetPlayerCanDoDriveBy(player, false)
end
else
EnableControlAction(0, 24, true) -- Attack
EnableControlAction(0, 257, true) -- Attack 2
if IsPedInAnyVehicle(player, true) then
SetPlayerCanDoDriveBy(player, true)
end
end
if pedAmmo <= 0 then
SetAmmoInClip(PlayerPedId(), currentWeapon, 1)
end
end
end
end
end
end)
Alpha