I installed weaponsync recently, so i can have weapons as items in my inventory.
I do have the weapons in my loadout when i have them in my inventory, but the problem is, that i wanted to make the guns usable with a hotbar (register usable Item) as the loadout selection wheel is Bugged with weaponsync.
So my questions is, if anyone knows how i can register an usable Item for pulling out a weapon?
If you are using ESX Framework, it is very very easy
Navigate to your server root folder
Go to resources, then esx_addons, then esx_basicneeds, then server
Now open main.lua
And add the following line of code to an open space
ESX.RegisterUsableItem('gun', function(source)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.removeInventoryItem('gun', 1)
GiveWeaponToPed(source, weapon_hash, ammo, false, true)
xPlayer.showNotification(_U('used_gun'))
end)
REMEMBER to, replace gun with the name of the gun in your database
Also, replace weapon_hash with the hash for the weapon along with ammo as the number of bullets provided
Which can be found at the below link (Copy the ID) https://vespura.com/fivem/weapons/
LAST thing, add “used_gun” to your en.locale file in localizations folder in esx_basicneeds in order to pop up a message when the gun is used
(The false, true at the end, is for two things, false is to make sure the gun is not hidden, true is to force it into the players hand upon use, feel free to change them, although I do not see a reason to change the “false”)
If you are not using ESX, then maybe you should post this somewhere else
Feel free to post a reply if you have any questions or issues