- Katılım
- 4 yıl 3 ay 5 gün
- Mesajlar
- 212
Sadece pistol mermilerinde geçerlidir.
Server Side
Kod:
MBL = {}
MBL.Pistol = {
[GetHashKey("weapon_snspistol")] = {},
[GetHashKey("weapon_vintagepistol")] = {},
[GetHashKey("weapon_pistol")] = {},
[GetHashKey("weapon_pistol_mk2")] = {},
[GetHashKey("weapon_combatpistol")] = {},
[GetHashKey("weapon_appistol")] = {},
[GetHashKey("weapon_pistol50")] = {},
[GetHashKey("weapon_heavypistol")] = {},
[GetHashKey("weapon_marksmanpistol")] = {},
}
function yapabilir()
local ped = PlayerPedId()
local pedWeapon = GetSelectedPedWeapon(ped)
for k, v in pairs(MBL.Pistol) do
if pedWeapon == k then
return true
end
end
return false
end
RegisterCommand("mermiçıkar", function(source, args)
local weapon = GetSelectedPedWeapon(PlayerPedId())
local info = nil
local ammo = tonumber(GetAmmoInPedWeapon(PlayerPedId(), weapon))
local item = "pistol_ammo"
local task = tonumber(args[1])
if task ~= nil then
if RLCore.Shared.Weapons[weapon]["name"] ~= "weapon_unarmed" then
if ammo > 0 then
if yapabilir() then
if ammo >= task then
TriggerServerEvent('serversayd', task)
SetPedAmmo(PlayerPedId(), weapon, ammo-task)
TriggerServerEvent("weapons:server:AddWeaponAmmo", CurrentWeaponData, ammo-task)
RLCore.Functions.Notify("Mermilerini çıkardın, çıkarılan mermi sayısı: "..task)
else
RLCore.Functions.Notify("Elindeki silahta bu şuanda mümkün değil.")
end
else
RLCore.Functions.Notify("Silahin mermisi 0'dan büyük olmalı.")
end
else
RLCore.Functions.Notify("Elinde silah yok.")
end
else
RLCore.Functions.Notify("Çıkarmak istediğin miktarı yaz.")
end
end
end)
RegisterNetEvent('weapon:client:AddAmmo')
AddEventHandler('weapon:client:AddAmmo', function(type, amount, itemData, data)
local ped = PlayerPedId()
local weapon = GetSelectedPedWeapon(PlayerPedId())
if CurrentWeaponData ~= nil then
if RLCore.Shared.Weapons[weapon]["name"] ~= "weapon_unarmed" and RLCore.Shared.Weapons[weapon]["ammotype"] == type:upper() then
local total = (GetAmmoInPedWeapon(PlayerPedId(), weapon))
local f, max = GetMaxAmmo(ped, weapon)
local clipmax = tonumber(GetMaxAmmoInClip(ped, weapon, 1))
local newtotal = total + clipmax
if newtotal < max then
RLCore.Functions.Progressbar("taking_bullets", "", math.random(1000, 4000), false, true, {
disableMovement = false,
disableCarMovement = false,
disableMouse = false,
disableCombat = true,
}, {}, {}, {}, function() -- Done
if RLCore.Shared.Weapons[weapon] ~= nil then
if yapabilir() then
TaskReloadWeapon(ped)
SetPedAmmo(ped, weapon, total+itemData.info.mermi)
TriggerServerEvent("weapons:server:AddWeaponAmmo", CurrentWeaponData, total+itemData.info.mermi)
TriggerServerEvent('RLCore:Server:RemoveItem', itemData.name, 1, itemData.slot)
TriggerEvent('inventory:client:ItemBox', RLCore.Shared.Items[itemData.name], "remove")
TriggerEvent('RLCore:Notify', itemData.info.mermi .." mermi dolduruldu!", "success")
TriggerEvent("debug", 'Weapons: Bullets Loaded', 'success')
else
if weapon ~= nil then
TaskReloadWeapon(ped)
SetPedAmmo(ped, weapon, newtotal)
TriggerServerEvent("weapons:server:AddWeaponAmmo", CurrentWeaponData, newtotal)
TriggerServerEvent('RLCore:Server:RemoveItem', itemData.name, 1, itemData.slot)
TriggerEvent('inventory:client:ItemBox', RLCore.Shared.Items[itemData.name], "remove")
TriggerEvent('RLCore:Notify', newtotal .." mermi dolduruldu!", "success")
TriggerEvent("debug", 'Weapons: Bullets Loaded', 'success')
end
end
end
end, function()
RLCore.Functions.Notify("İptal edildi..", "error")
TriggerEvent("debug", 'Weapons: Canceled', 'error')
end)
else
RLCore.Functions.Notify("Bu silahın mermileri dolu..", "error")
end
else
RLCore.Functions.Notify("Elinde silah yok..", "error")
end
else
RLCore.Functions.Notify("Elinde silah yok..", "error")
end
end)
Server Side
Kod:
RegisterServerEvent("serversayd")
AddEventHandler("serversayd", function (yarraminbashi)
giveAmom(source, yarraminbashi)
end)
function giveAmom(source, yarrak)
local src = source
local Player = RLCore.Functions.GetPlayer(src)
local info = {}
info.mermi = yarrak
Player.Functions.AddItem("pistol_ammo", 1, false, info)
end
RLCore.Functions.CreateUseableItem("pistol_ammo", function(source, item, info)
local Player = RLCore.Functions.GetPlayer(source)
if Player.Functions.GetItemBySlot(item.slot) ~= nil then
TriggerClientEvent("weapon:client:AddAmmo", source, "AMMO_PISTOL", 30, item, info)
else
TriggerClientEvent("RLCore:Notify", 'nil attı kanka', "error")
end
end)
Javascript;
if (itemData.name == "pistol_ammo") {
$(".item-info-title").html('<p>'+itemData.label+'</p>')
$(".item-info-description").html('<p>Mermi: ' + itemData.info.mermi + '</p>');
}
Giveitem kodunun altına;
elseif itemData["name"] == "pistol_ammo" then
info.mermi = 5
print(info.mermi)