[ESX] MSK WeaponAmmo | Clips, Components & Tints

Tebex [3.00€]: https://mskscripts.tebex.io/

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.getSharedObject = 'esx:getSharedObject'
----------------------------------------------------------------
Config.Menu = 'NativeUI' -- Set to 'ESX' if you want ESX Menu || Set to 'NativeUI' if you want NativeUI
Config.AntiWeaponPunch = true -- Set false if you don't want to use this
Config.Animation = true -- Set false if you dont want the animation

Config.SavePlayer = {
	enable = true,
	version = '1.2' -- Set to '1.2' or 'legacy'
	-- !!! If you set 'version' to 'legacy' then please read the Readme.md !!!
}

Config.checkMaxAmmo = {
	enable = true, -- If set to false the Player can get more than Config.MaxAmmo bullets
 	maxAmmo = 250 -- Set the max. Ammo in Weapon
}

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/

	category = {
		enable = true, -- Set false if you want to use the weaclip item instead of category items like pistolclip
		item = 'weaclip' -- Set the item that you want to use
	}
}
----------------------------------------------------------------
-- !!! This function is clientside AND serverside !!!
-- Look for type == 'client' and type == 'server'
Config.Notification = function(src, type, xPlayer, message) -- xPlayer = ESX.GetPlayerFromId(src)
    if type == 'client' then -- clientside
        ESX.ShowNotification(message) -- replace this with your Notify
    elseif type == 'server' then -- serverside
        xPlayer.showNotification(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
	Attachments = true,
	Attachment_Remover = false, -- recommended set to false
	-- Weapon Tints
	Color = true,

	-- CUSTOM ITEMS // Add them in server_items.lua
	['polweaclip'] = true,
	['polweabox'] = true,
}
Code accessible No [config, translation and server_items are accessible]
Subscription based No
Lines (approximately) ~ 700
Requirements ESX 1.2 (v1-final) or ESX Legacy
Support Yes

Optional

My other Scripts

Changelogs

Update v7.7
  • Removed a lots of unnecessary code [from ~1140 to ~700 now]
  • Completely reworked the code
  • Added a few new option to the config
  • Added all weapons to the config
  • You can now add you own clips and components [explained in server_items.lua]
Update v7.6
  • Removed a lots of unnecessary code
  • If you have own components you can add them by yourself now
-- Add it in server_items.lua
xPlayer.triggerEvent('msk_weaponammo:addAttachment', 'itemname')

Instead of ~1900 lines now ~1140 lines

Re-download msk_weaponammo at your keymaster

Update 7.5

➥ You can edit the Notification now in config

Re-download msk_weaponammo at your keymaster

Update v7.4
  • Added SavePlayer for ESX Legacy

Re-download msk_weaponammo at your keymaster

Update v7.3
  • Fixed that you can’t use a component if it’s already attached to the weapon
Update v7.2
  • You can change the esx:getShardedObject Event yourself in config.lua
Update v7.1
  • Added Animation and ProgressBar after Weapon Reload
Update v7.0
  • Added Hotkey for using an Clip Item
  • Added AntiWeaponPunch (Antiwaffenschlag)
Update v6.3
  • Added a Check if Component can attached to the Weapon
  • Fixed some minor Bugs

Thanks to @gpScripts for helping me with that.
Check him out! https://gp-resources.tebex.io/

12 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

1 Like

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.

@Andy6666 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