Bazen en çok can sıkıcı nokta olan silah mermilerinin silinmesidir, bende bir arkadaşım vasıtasıyla bulduğum bir kod satırını sizlere paylaşmak istedim, kod satırının amacı silahınızda bulunan mermi sayısını "mcikar" komutu ile size geri verir.
Script client taraflı çalışsa da serverside'a ihtiyacı vardır, yukarıdaki kod satırı sadece mermiyi siler item'i size vermez.
Script client taraflı çalışsa da serverside'a ihtiyacı vardır, yukarıdaki kod satırı sadece mermiyi siler item'i size vermez.
Kod:
RegisterCommand('mcikar', function(_)
local player = PlayerPedId()
if IsPedArmed(player, 4) then
local weapon
local found, currentWeapon = GetCurrentPedWeapon(player, true)
if found then
for k, v in pairs(Config.Ammo) do
for y, z in pairs(v.weapons) do
if z == currentWeapon then
weapon = currentWeapon
local pedAmmo = GetAmmoInPedWeapon(player, weapon)
if pedAmmo >= v.count then
local magcount = math.floor(pedAmmo / v.count)
local currentAmmo = math.floor(pedAmmo - (magcount * v.count))
SetPedAmmo(player, weapon, currentAmmo)
TaskReloadWeapon(player)
TriggerServerEvent('m3:inventoryhud:server:updateAmmoCount', weapon, currentAmmo)
TriggerServerEvent('disc-ammo:addAmmoItem', {name = v.name, count = tonumber(magcount)})
else
exports['mythic_notify']:SendAlert('error', 'Silahında çıkartabileceğin kadar mermi yok!')
end
return
end
Wait(0)
end
Wait(0)
end
end
else
exports['mythic_notify']:SendAlert('error', 'Elinde herhangi bir silah yok!')
end
end)