HexscriptsVersion 4.0Inventory
Installation
Here you will get the full Installation guide to get this script running.
Download Asset
Login in your FiveM Portal Account
To Download our Script you must login in your Fivem Portal Account
Download the Script
If you are sucessfully logged in into your Account go to Assets and search by the script hex_4_inventory then download it.
Download Dependencies
| Dependency | Required |
|---|---|
| es_extended | |
| oxmysql |
Start Asset
To make sure the asset start and run properly, you need to add them in the correct order inside your server.cfg. Below is an example of how it should look.
Note
You can also create a folder called [hex] inside your resources folder. If you own multiple scripts from us, you won’t need to add each one separately to your server.cfg.
# 1. Start database wrapper called oxmysql
ensure oxmysql
# 2. Start the specific framework
ensure es_extended or qb-core or qbx_core
# 3. Now start our asset singularly
ensure hex_4_inventory
# Or you can start all of our assets at once into a folder called [hex]
ensure [hex]Add Ammo Event
ESX.SecureNetEvent("esx:updateWeaponAmmo", function(weaponName, ammo)
for i = 1, #ESX.PlayerData.loadout do
if ESX.PlayerData.loadout[i].name == weaponName then
ESX.PlayerData.loadout[i].ammo = ammo
break
end
end
end)Replace Player Ammo Server Handler
function self.addWeaponAmmo(weaponName, ammoCount)
local _, weapon = self.getWeapon(weaponName)
if weapon then
weapon.ammo = weapon.ammo + ammoCount
SetPedAmmo(GetPlayerPed(self.source), joaat(weaponName), weapon.ammo)
self.triggerEvent("esx:updateWeaponAmmo", weaponName, weapon.ammo)
return true
end
return false
end
function self.updateWeaponAmmo(weaponName, ammoCount)
local _, weapon = self.getWeapon(weaponName)
if not weapon then
return false
end
weapon.ammo = ammoCount
self.triggerEvent("esx:updateWeaponAmmo", weaponName, weapon.ammo)
if weapon.ammo <= 0 then
local _, weaponConfig = ESX.GetWeapon(weaponName)
if weaponConfig.throwable then
self.removeWeapon(weaponName)
end
end
return true
end
function self.removeWeaponAmmo(weaponName, ammoCount)
local _, weapon = self.getWeapon(weaponName)
if weapon then
weapon.ammo = weapon.ammo - ammoCount
SetPedAmmo(GetPlayerPed(self.source), joaat(weaponName), weapon.ammo)
self.triggerEvent("esx:updateWeaponAmmo", weaponName, weapon.ammo)
return true
end
return false
end