How to Install
FiveStar Script
Requirements
Before starting, make sure you have the latest version of qb_target Script installed on your server
You can fully customize the config file and customize the qb_target or qb_inventory or ox_invnetory scripts
Add Ammo item
#1 Make sure that all ammo item are registered in your inventory system.
Befor starting it, go to qb-core/shared/items.lua
and add the following items
Config.Ammos = {
["5.56mm"] = { Name = "5.56x45mm", Price = 10, Count = 20 },
["7.62mm"] = { Name = "7.62x39mm", Price = 10, Count = 20 },
["9mm"] = { Name = "9x19mm", Price = 10, Count = 20 },
["12_gauge"] = { Name = "12ga Rifled", Price = 10, Count = 20 },
["25_acp"] = { Name = ".25ACP Auto", Price = 10, Count = 20 },
["32_acp"] = { Name = "32ACP Auto", Price = 10, Count = 20 },
["44_magnum"] = { Name = ".357 Magnum", Price = 10, Count = 20 },
["45_acp"] = { Name = "45ACP Auto", Price = 10, Count = 20 },
["50mm_bmg"] = { Name = ".50 BMG", Price = 10, Count = 20 },
["54r"] = { Name = "7.62x39mm", Price = 10, Count = 20 },
["rocket"] = { Name = "Rocket", Price = 10, Count = 20 },
["grenade"] = { Name = "Grenade", Price = 10, Count = 20 },
["ammo_laser"] = { Name = "Laser charge", Price = 5000, Count = 250 },
}
Example:
["5.56mm"] = { name = '5.56mm', label = '5.56x45mm', weight = 4, type = 'item', image = '5.56mm.png', unique = false, useable = true, shouldClose = true, combinable = nil, description = '5.56x45mm for a weapon' },
...
Befor starting it, go to ox_inventory/data/weapons.lua
and add the following items
Config.Ammos = {
["5.56mm"] = { Name = "5.56x45mm", Price = 10, Count = 20 },
["7.62mm"] = { Name = "7.62x39mm", Price = 10, Count = 20 },
["9mm"] = { Name = "9x19mm", Price = 10, Count = 20 },
["12_gauge"] = { Name = "12ga Rifled", Price = 10, Count = 20 },
["25_acp"] = { Name = ".25ACP Auto", Price = 10, Count = 20 },
["32_acp"] = { Name = "32ACP Auto", Price = 10, Count = 20 },
["44_magnum"] = { Name = ".357 Magnum", Price = 10, Count = 20 },
["45_acp"] = { Name = "45ACP Auto", Price = 10, Count = 20 },
["50mm_bmg"] = { Name = ".50 BMG", Price = 10, Count = 20 },
["54r"] = { Name = "7.62x39mm", Price = 10, Count = 20 },
["rocket"] = { Name = "Rocket", Price = 10, Count = 20 },
["grenade"] = { Name = "Grenade", Price = 10, Count = 20 },
["ammo_laser"] = { Name = "Laser charge", Price = 5000, Count = 250 },
}
Example:
['5.56mm'] = {
label = '5.56x45mm',
weight = 4,
}
...
Those using ps-inventory should apply these changes to
Download the latest version
Go to FiveStar-WeaponShop/server/callback.lua
file, rename qb-inventory to ps-inventory
Add the ammo to the qb-core/shared/items.lua
list in order
ammo_5_56mm = { name = 'ammo_5_56mm', label = '5.56x45mm', weight = 4, type = 'item', image = '5.56mm.png', unique = false, useable = true, shouldClose = true, combinable = nil, description = '5.56x45mm ammo' }
use function xPlayer instead of exports
xPlayer.Functions.AddItem(WeaponAmmo, Config.Ammos[WeaponAmmo].Count)
Open ps-inventory/client.lua
, find register net event inventory:client:UseWeapon
and replace it with the above code
RegisterNetEvent('inventory:client:UseWeapon', function(weaponData, shootbool)
local ped = PlayerPedId()
local weaponName = tostring(weaponData.name)
local weaponHash = joaat(weaponData.name)
local weaponinhand = GetCurrentPedWeapon(PlayerPedId())
if currentWeapon == weaponName and weaponinhand then
TriggerEvent('weapons:client:DrawWeapon', nil)
SetCurrentPedWeapon(ped, `WEAPON_UNARMED`, true)
RemoveAllPedWeapons(ped, true)
TriggerEvent('weapons:client:SetCurrentWeapon', nil, shootbool)
currentWeapon = nil
elseif weaponName == "weapon_stickybomb" or weaponName == "weapon_pipebomb" or weaponName == "weapon_smokegrenade" or weaponName == "weapon_flare" or weaponName == "weapon_proxmine" or weaponName == "weapon_ball" or weaponName == "weapon_molotov" or weaponName == "weapon_grenade" or weaponName == "weapon_bzgas" then
TriggerEvent('weapons:client:DrawWeapon', weaponName)
GiveWeaponToPed(ped, weaponHash, 1, false, false)
SetPedAmmo(ped, weaponHash, 1)
SetCurrentPedWeapon(ped, weaponHash, true)
TriggerEvent('weapons:client:SetCurrentWeapon', weaponData, shootbool)
currentWeapon = weaponName
elseif weaponName == "weapon_snowball" then
TriggerEvent('weapons:client:DrawWeapon', weaponName)
GiveWeaponToPed(ped, weaponHash, 10, false, false)
SetPedAmmo(ped, weaponHash, 10)
SetCurrentPedWeapon(ped, weaponHash, true)
TriggerServerEvent('inventory:server:snowball', 'remove')
TriggerEvent('weapons:client:SetCurrentWeapon', weaponData, shootbool)
currentWeapon = weaponName
else
TriggerEvent('weapons:client:DrawWeapon', weaponName)
TriggerEvent('weapons:client:SetCurrentWeapon', weaponData, shootbool)
local ammo = tonumber(weaponData.info.ammo) or 0
if weaponName == 'weapon_petrolcan' or weaponName == 'weapon_fireextinguisher' then
ammo = 4000
end
GiveWeaponToPed(ped, weaponHash, ammo, false, false)
SetPedAmmo(ped, weaponHash, ammo)
SetCurrentPedWeapon(ped, weaponHash, true)
if weaponData.info.attachments then
for _, attachment in pairs(weaponData.info.attachments) do
GiveWeaponComponentToPed(ped, weaponHash, joaat(attachment.component))
end
end
if weaponData.info.tint then
SetPedWeaponTintIndex(ped, weaponHash, weaponData.info.tint)
end
currentWeapon = weaponName
end
end)
#2 Open qb-core/shared/items.lua
, This is qb default ammo, delete these
-- Ammo ITEMS
pistol_ammo = { name = 'pistol_ammo', label = 'Pistol ammo', weight = 200, type = 'item', image = 'pistol_ammo.png', unique = false, useable = true, shouldClose = true, combinable = nil, description = 'Ammo for Pistols' },
rifle_ammo = { name = 'rifle_ammo', label = 'Rifle ammo', weight = 1000, type = 'item', image = 'rifle_ammo.png', unique = false, useable = true, shouldClose = true, combinable = nil, description = 'Ammo for Rifles' },
smg_ammo = { name = 'smg_ammo', label = 'SMG ammo', weight = 500, type = 'item', image = 'smg_ammo.png', unique = false, useable = true, shouldClose = true, combinable = nil, description = 'Ammo for Sub Machine Guns' },
shotgun_ammo = { name = 'shotgun_ammo', label = 'Shotgun ammo', weight = 500, type = 'item', image = 'shotgun_ammo.png', unique = false, useable = true, shouldClose = true, combinable = nil, description = 'Ammo for Shotguns' },
mg_ammo = { name = 'mg_ammo', label = 'MG ammo', weight = 1000, type = 'item', image = 'mg_ammo.png', unique = false, useable = true, shouldClose = true, combinable = nil, description = 'Ammo for Machine Guns' },
snp_ammo = { name = 'snp_ammo', label = 'Sniper ammo', weight = 1000, type = 'item', image = 'rifle_ammo.png', unique = false, useable = true, shouldClose = true, combinable = nil, description = 'Ammo for Sniper Rifles' },
emp_ammo = { name = 'emp_ammo', label = 'EMP Ammo', weight = 200, type = 'item', image = 'emp_ammo.png', unique = false, useable = true, shouldClose = true, combinable = nil, description = 'Ammo for EMP Launcher' },
#3 Open qb-weapon/server/main.lua
, line 208
to 222
is the ammo register code, delete it
local AmmoTypes = {
pistol_ammo = { ammoType = 'AMMO_PISTOL', amount = 30 },
rifle_ammo = { ammoType = 'AMMO_RIFLE', amount = 30 },
smg_ammo = { ammoType = 'AMMO_SMG', amount = 30 },
shotgun_ammo = { ammoType = 'AMMO_SHOTGUN', amount = 10 },
mg_ammo = { ammoType = 'AMMO_MG', amount = 30 },
snp_ammo = { ammoType = 'AMMO_SNIPER', amount = 10 },
emp_ammo = { ammoType = 'AMMO_EMPLAUNCHER', amount = 10 }
}
for ammoItem, properties in pairs(AmmoTypes) do
QBCore.Functions.CreateUseableItem(ammoItem, function(source, item)
TriggerClientEvent('qb-weapons:client:AddAmmo', source, properties.ammoType, properties.amount, item)
end)
end
Pay attention to the photo 👇
#4 Open qb-weapons/client/main.lua
, find register net event weapons:client:AddAmmo
and replace it with the above code
RegisterNetEvent('weapons:client:AddAmmo', function(type, amount, itemData)
local ped = cache.ped
local weapon = GetSelectedPedWeapon(ped)
if CurrentWeaponData then
if QBCore.Shared.Weapons[weapon]["name"] ~= "weapon_unarmed" then
if QBCore.Shared.Weapons[weapon]["ammotype"] ~= type then
QBCore.Functions.Notify(type .." does not belong to this " .. QBCore.Shared.Weapons[weapon]["label"], "error")
return
end
local total = GetAmmoInPedWeapon(ped, weapon)
local _, maxAmmo = GetMaxAmmo(ped, weapon)
if total < maxAmmo then
QBCore.Functions.Progressbar("taking_bullets", Lang:t('info.loading_bullets'), Config.ReloadTime, false, true, {
disableMovement = false,
disableCarMovement = false,
disableMouse = false,
disableCombat = true,
}, {}, {}, {}, function() -- Done
local newweapon = GetSelectedPedWeapon(ped)
if QBCore.Shared.Weapons[weapon] or QBCore.Shared.Weapons[weapon]["name"] ~= "weapon_unarmed" or QBCore.Shared.Weapons[weapon]["ammotype"] ~= type then
AddAmmoToPed(ped,weapon,amount)
TaskReloadWeapon(ped, false)
TriggerServerEvent("weapons:server:UpdateWeaponAmmo", CurrentWeaponData, total + amount)
TriggerServerEvent('weapons:server:removeWeaponAmmoItem', itemData)
TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items[itemData.name], "remove")
TriggerEvent('QBCore:Notify', Lang:t('success.reloaded'), "success")
end
end, function()
QBCore.Functions.Notify(Lang:t('error.canceled'), "error")
end)
else
QBCore.Functions.Notify(Lang:t('error.max_ammo'), "error")
end
else
QBCore.Functions.Notify(Lang:t('error.no_weapon'), "error")
end
else
QBCore.Functions.Notify(Lang:t('error.no_weapon'), "error")
end
end)
#5 Open qb-core/shared/weapons.lua
, all weapons are there and ammotype
is written in front of it edit it
Register attachments
If you use ox_inventory, some of the weapon components are not added by the ox team and the list is not complete, the script does not encounter problems, but you cannot remove some attachments from the weapon.
Add License
Please put your license in server/license.lua
| If your script is encrypted, enter your license
Last updated
Was this helpful?