[ESX] MSK WeaponAmmo | Clips, Components & Tints

Tebex [FREE] - Source Code
Github Repository

!!! We do not support inventories that have weapons as items !!!

Description

  • If you are using one of the clip item, it adds Ammunition to your weapon.
  • If you are using a attachment item, it adds this Component to your weapon
  • If you are using a tint item, it adds this tint to your weapon.
  • With the item attachment_remover you can remove the components and tints from your weapon
  • You can add you own clips and components [explained in server_items.lua]

Config

Config = {}
----------------------------------------------------------------
Config.Locale = 'de'
Config.VersionChecker = true
Config.Debug = true
----------------------------------------------------------------
Config.Menu = 'NativeUI' -- Set to 'ESX' if you want ESX Menu || Set to 'NativeUI' if you want NativeUI || Read the Readme.md if you want to use ESX Menu
Config.AntiWeaponPunch = true -- Set false if you don't want to use this
Config.Animation = true -- Set false if you dont want an animation

Config.SavePlayer = {
	enable = true,
	version = 'legacy' -- Set to '1.2' or 'legacy' // For ESX 1.2 set to '1.2', for ESX Legacy set 'legacy'
}

Config.enableMaxAmmo = true -- Set false to deactivate this feature
Config.checkMaxAmmo = {
	['weaclip'] = 250,
	['weabox'] = 250,

	['pistolclip'] = 80,
	['smgclip'] = 120,
	['shotgunclip'] = 80,
	['rifleclip'] = 180,
	['mgclip'] = 250,
	['sniperclip'] = 120,
	['throwableclip'] = 25,
}

Config.Hotkey = {
	enable = true, -- Set to false if you dont want to use ammo Item by pressing a Key
	key = 45, -- default: 45 = R // https://docs.fivem.net/docs/game-references/controls/
}
----------------------------------------------------------------
-- !!! This function is clientside AND serverside !!!
-- Look for type == 'client' and type == 'server'
Config.Notification = function(src, action, xPlayer, message) -- xPlayer = ESX.GetPlayerFromId(src)
    if action == 'client' then -- clientside
        MSK.Notification(message) -- replace this with your Notify
    elseif action == 'server' then -- serverside
        MSK.Notification(src, message) -- replace this with your Notify
    end
end
---------------------------------------------------
Config.WeaponAmmoClips = { -- Will give this many bullets to player
	-- Items are used for all types of weapons
	['weaclip'] = 30,
	['weabox'] = 150,
	-- Items are used for only that kind of weapon type
	['pistolclip'] = 12,
	['smgclip'] = 30,
	['shotgunclip'] = 25,
	['rifleclip'] = 25,
	['mgclip'] = 50,
	['sniperclip'] = 15,
	['throwableclip'] = 5,

	-- CUSTOM ITEMS // Add them in server_items.lua
	['polweaclip'] = 30, -- All Weapontypes
	['polweabox'] = 150, -- All Weapontypes
}
----------------------------------------------------------------
-- Set true if you like to remove item when used
Config.Removeables = {
	-- Weapon Clips
	['weaclip'] = true,
	['weabox'] = true,
	['pistolclip'] = true,
	['smgclip'] = true,
	['shotgunclip'] = true,
	['rifleclip'] = true,
	['mgclip'] = true,
	['sniperclip'] = true,
	['throwableclip'] = true,

	-- Weapon Attachments
	['scope'] = true,
	['grip'] = true,
	['flashlight'] = true,
	['clip_extended'] = true,
	['suppressor'] = true,
	['luxary_finish'] = true,
	['attachment_remover'] = false, -- This item removes Weapon Components and opens the Menu // recommended set to false

	-- Weapon Tints
	['tint_green'] = true,
	['tint_gold'] = true,
	['tint_pink'] = true,
	['tint_army'] = true,
	['tint_lspd'] = true,
	['tint_orange'] = true,
	['tint_platinum'] = true,

	-- CUSTOM ITEMS // Add them in server_items.lua
	['polweaclip'] = true,
	['polweabox'] = true,
}
----------------------------------------------------------------
-- Please don't TOUCH if you don't know what you are doing!!
Config.Weapons = {
	['pistolclip'] = {
		'WEAPON_PISTOL',
		'WEAPON_PISTOL_MK2',
		'WEAPON_COMBATPISTOL',
		'WEAPON_APPISTOL',
		'WEAPON_PISTOL50',
		'WEAPON_SNSPISTOL',
		'WEAPON_SNSPISTOL_MK2',
		'WEAPON_HEAVYPISTOL',
		'WEAPON_VINTAGEPISTOL',
		'WEAPON_MARKSMANPISTOL',
		'WEAPON_REVOLVER',
		'WEAPON_REVOLVER_MK2',
		'WEAPON_DOUBLEACTION',
		'WEAPON_CERAMICPISTOL',
		'WEAPON_NAVYREVOLVER',
		'WEAPON_GADGETPISTOL',
	},
	['smgclip'] = {
		'WEAPON_MICROSMG',
		'WEAPON_SMG',
		'WEAPON_SMG_MK2',
		'WEAPON_ASSAULTSMG',
		'WEAPON_COMBATPDW',
		'WEAPON_MACHINEPISTOL',
		'WEAPON_MINISMG',
	},
	['shotgunclip'] = {
		'WEAPON_PUMPSHOTGUN',
		'WEAPON_PUMPSHOTGUN_MK2',
		'WEAPON_SAWNOFFSHOTGUN',
		'WEAPON_ASSAULTSHOTGUN',
		'WEAPON_BULLPUPSHOTGUN',
		'WEAPON_MUSKET',
		'WEAPON_HEAVYSHOTGUN',
		'WEAPON_DBSHOTGUN',
		'WEAPON_AUTOSHOTGUN',
		'WEAPON_COMBATSHOTGUN',
	},
	['rifleclip'] = {
		'WEAPON_ASSAULTRIFLE',
		'WEAPON_ASSAULTRIFLE_MK2',
		'WEAPON_CARBINERIFLE',
		'WEAPON_CARBINERIFLE_MK2',
		'WEAPON_ADVANCEDRIFLE',
		'WEAPON_SPECIALCARBINE',
		'WEAPON_SPECIALCARBINE_MK2',
		'WEAPON_BULLPUPRIFLE',
		'WEAPON_BULLPUPRIFLE_MK2',
		'WEAPON_COMPACTRIFLE',
		'WEAPON_MILITARYRIFLE',
		'WEAPON_HEAVYRIFLE',
		'WEAPON_TACTICALRIFLE',
	},
	['mgclip'] = {
		'WEAPON_MG',
		'WEAPON_COMBATMG',
		'WEAPON_COMBATMG_MK2',
		'WEAPON_GUSENBERG',
	},
	['sniperclip'] = {
		'WEAPON_SNIPERRIFLE',
		'WEAPON_HEAVYSNIPER',
		'WEAPON_HEAVYSNIPER_MK2',
		'WEAPON_MARKSMANRIFLE',
		'WEAPON_MARKSMANRIFLE_MK2',
		'WEAPON_PRECISIONRIFLE',
	},
	['throwableclip'] = {
		'WEAPON_FLAREGUN',
	},
	['weaclip'] = {
		-- Pistols
		'WEAPON_PISTOL',
		'WEAPON_PISTOL_MK2',
		'WEAPON_COMBATPISTOL',
		'WEAPON_APPISTOL',
		'WEAPON_PISTOL50',
		'WEAPON_SNSPISTOL',
		'WEAPON_SNSPISTOL_MK2',
		'WEAPON_HEAVYPISTOL',
		'WEAPON_VINTAGEPISTOL',
		'WEAPON_MARKSMANPISTOL',
		'WEAPON_REVOLVER',
		'WEAPON_REVOLVER_MK2',
		'WEAPON_DOUBLEACTION',
		'WEAPON_CERAMICPISTOL',
		'WEAPON_NAVYREVOLVER',
		'WEAPON_GADGETPISTOL',

		-- SMGS
		'WEAPON_MICROSMG',
		'WEAPON_SMG',
		'WEAPON_SMG_MK2',
		'WEAPON_ASSAULTSMG',
		'WEAPON_COMBATPDW',
		'WEAPON_MACHINEPISTOL',
		'WEAPON_MINISMG',

		-- Shotguns
		'WEAPON_PUMPSHOTGUN',
		'WEAPON_PUMPSHOTGUN_MK2',
		'WEAPON_SAWNOFFSHOTGUN',
		'WEAPON_ASSAULTSHOTGUN',
		'WEAPON_BULLPUPSHOTGUN',
		'WEAPON_MUSKET',
		'WEAPON_HEAVYSHOTGUN',
		'WEAPON_DBSHOTGUN',
		'WEAPON_AUTOSHOTGUN',
		'WEAPON_COMBATSHOTGUN',

		-- Rifles
		'WEAPON_ASSAULTRIFLE',
		'WEAPON_ASSAULTRIFLE_MK2',
		'WEAPON_CARBINERIFLE',
		'WEAPON_CARBINERIFLE_MK2',
		'WEAPON_ADVANCEDRIFLE',
		'WEAPON_SPECIALCARBINE',
		'WEAPON_SPECIALCARBINE_MK2',
		'WEAPON_BULLPUPRIFLE',
		'WEAPON_BULLPUPRIFLE_MK2',
		'WEAPON_COMPACTRIFLE',
		'WEAPON_MILITARYRIFLE',
		'WEAPON_HEAVYRIFLE',
		'WEAPON_TACTICALRIFLE',

		-- MGs
		'WEAPON_MG',
		'WEAPON_COMBATMG',
		'WEAPON_COMBATMG_MK2',
		'WEAPON_GUSENBERG',

		-- Snipers
		'WEAPON_SNIPERRIFLE',
		'WEAPON_HEAVYSNIPER',
		'WEAPON_HEAVYSNIPER_MK2',
		'WEAPON_MARKSMANRIFLE',
		'WEAPON_MARKSMANRIFLE_MK2',
		'WEAPON_PRECISIONRIFLE',

		-- Throwables
		'WEAPON_FLAREGUN',
	},
	['weabox'] = {
		-- Pistols
		'WEAPON_PISTOL',
		'WEAPON_PISTOL_MK2',
		'WEAPON_COMBATPISTOL',
		'WEAPON_APPISTOL',
		'WEAPON_PISTOL50',
		'WEAPON_SNSPISTOL',
		'WEAPON_SNSPISTOL_MK2',
		'WEAPON_HEAVYPISTOL',
		'WEAPON_VINTAGEPISTOL',
		'WEAPON_MARKSMANPISTOL',
		'WEAPON_REVOLVER',
		'WEAPON_REVOLVER_MK2',
		'WEAPON_DOUBLEACTION',
		'WEAPON_CERAMICPISTOL',
		'WEAPON_NAVYREVOLVER',
		'WEAPON_GADGETPISTOL',

		-- SMGS
		'WEAPON_MICROSMG',
		'WEAPON_SMG',
		'WEAPON_SMG_MK2',
		'WEAPON_ASSAULTSMG',
		'WEAPON_COMBATPDW',
		'WEAPON_MACHINEPISTOL',
		'WEAPON_MINISMG',

		-- Shotguns
		'WEAPON_PUMPSHOTGUN',
		'WEAPON_PUMPSHOTGUN_MK2',
		'WEAPON_SAWNOFFSHOTGUN',
		'WEAPON_ASSAULTSHOTGUN',
		'WEAPON_BULLPUPSHOTGUN',
		'WEAPON_MUSKET',
		'WEAPON_HEAVYSHOTGUN',
		'WEAPON_DBSHOTGUN',
		'WEAPON_AUTOSHOTGUN',
		'WEAPON_COMBATSHOTGUN',

		-- Rifles
		'WEAPON_ASSAULTRIFLE',
		'WEAPON_ASSAULTRIFLE_MK2',
		'WEAPON_CARBINERIFLE',
		'WEAPON_CARBINERIFLE_MK2',
		'WEAPON_ADVANCEDRIFLE',
		'WEAPON_SPECIALCARBINE',
		'WEAPON_SPECIALCARBINE_MK2',
		'WEAPON_BULLPUPRIFLE',
		'WEAPON_BULLPUPRIFLE_MK2',
		'WEAPON_COMPACTRIFLE',
		'WEAPON_MILITARYRIFLE',
		'WEAPON_HEAVYRIFLE',
		'WEAPON_TACTICALRIFLE',

		-- MGs
		'WEAPON_MG',
		'WEAPON_COMBATMG',
		'WEAPON_COMBATMG_MK2',
		'WEAPON_GUSENBERG',

		-- Snipers
		'WEAPON_SNIPERRIFLE',
		'WEAPON_HEAVYSNIPER',
		'WEAPON_HEAVYSNIPER_MK2',
		'WEAPON_MARKSMANRIFLE',
		'WEAPON_MARKSMANRIFLE_MK2',
		'WEAPON_PRECISIONRIFLE',

		-- Throwables
		'WEAPON_FLAREGUN',
	},
}
Code accessible Yes
Subscription based No
Lines (approximately) ~ 700
Requirements ESX 1.2 (v1-final), ESX 1.7.5 and above, oxmysql, msk_core
Support Yes

Why oxmysql?

oxmysql is necessary because the items will be inserted automatically in your database

Optional

My other Scripts

Paid

Free

15 Likes

I would suggest you to use PlayerPedId() instead of GetPlayerPed(-1) :slight_smile:
Detail : [Question] Difference between GetPlayerPed(-1) and PlayerPedId() - #2 by TheIndra

1 Like

Thank you for the advice :slight_smile:

1 Like

You’re welcome :slight_smile:

Well done! :+1:

1 Like

Update v3.1

  • Changed GetPlayerPed(-1) to PlayerPedId() in client.lua

Download: Releases · Musiker15/weaponammo · GitHub

1 Like

Thank you, I wasn’t expecting a Chezza Studios developer to see this

2 Likes

Nice one mate, I forgot to thank you for the tip the other day :slight_smile:

The only issue that bothers me is when you have similar type weapons, for example 2 pistols on you and you drop one, then you lose all ammo from the other one. If you pick it up then you get the ammo back as well on both. I’m on esx legacy btw.

@andyxdddd give us a hand bro <3

2 Likes

Bugfix for v3.1

I made a mistake with event names so i changed it back :slight_smile:

Download new Version v3.2: Release Bug Fix for v3.1 · Musiker15/weaponammo · GitHub

1 Like

[ script:weaponammo] Error loading script server.lua in resource weaponammo: @weaponammo/server.lua:2: attempt to index a nil value (global ‘ESX’)
[ script:weaponammo] stack traceback:
[ script:weaponammo]
[ c-scripting-core] Failed to load script server.lua.

Oh sorry I forgot something.
Please go to server.lua and add following at the top.

ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)

I release an update in a few minutes!

dont forgot put in client.lua also

Yes, put in client.lua

ESX = nil
Citizen.CreateThread(function()
	while ESX == nil do
		TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
		Citizen.Wait(0)
	end
end)

Update v3.3

I forgot to add ESX = nil to client.lua and server.lua

  • Added ESX = nil to client.lua and server.lua

Download v3.3: Release Bugfix for v3.2 · Musiker15/weaponammo · GitHub

i already use …nothing add bullet in weapon

I tested it after the last Update v3.3 and it works perfect for me.
Do you use ESX v1-final or another?

i use v1.2

Works good thanks, man.

1 Like