Any error in client or server console?
nothing errorā¦ is workā¦ but problem when i use ā¦ nothing add bullet in weapon
You can do a little change in client.lua
.
Replace
TriggerServerEvent('esx_weaponammo:addammo', hash)
with
local ammo = Config.WeaponClipAmmo
AddAmmoToPed(PlayerPedId(), hash, ammo)
But if you do that then it doesnāt save ammo in database. You can tryā¦
okey i try ā¦
Yes, it is true that it will not be stored in the database.
Now you are my testperson
Please try this one. Replace the client.lua with this one and try again.
On my server it doesnāt work but a friend of mine said it works for him so just try it outā¦
ESX = nil
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
end)
-- Start of Weapon Box
RegisterNetEvent('esx_weaponammo:weabox')
AddEventHandler('esx_weaponammo:weabox', function()
local playerPed = PlayerPedId()
local hash = GetSelectedPedWeapon(playerPed)
local ammo = Config.WeaponBoxAmmo
local weapon = ESX.GetWeaponFromHash(hash)
if IsPedArmed(playerPed, 4) then
if hash ~= nil then
if Config.CheckMaxAmmo then
local currentAmmo = GetAmmoInPedWeapon(playerPed, hash)
if currentAmmo + Config.WeaponBoxAmmo <= Config.MaxAmmo then
AddAmmoToPed(PlayerPedId(), hash, ammo)
TriggerServerEvent('esx:updateWeaponAmmo', weapon.name, ammo)
TriggerServerEvent('esx_weaponammo:removeweabox')
Citizen.Wait(100)
if Config.ChezzaInventory then
TriggerEvent('inventory:refresh', source) -- Chezza Inventory
end
ESX.ShowNotification(_U('used_weabox'))
else
ESX.ShowNotification(_U('check_maxammo'))
end
else
AddAmmoToPed(PlayerPedId(), hash, ammo)
TriggerServerEvent('esx:updateWeaponAmmo', weapon.name, ammo)
TriggerServerEvent('esx_weaponammo:removeweabox')
Citizen.Wait(100)
if Config.ChezzaInventory then
TriggerEvent('inventory:refresh', source) -- Chezza Inventory
end
ESX.ShowNotification(_U('used_weabox'))
end
else
ESX.ShowNotification(_U('no_weapon'))
end
else
ESX.ShowNotification(_U('not_suitable'))
end
end)
-- Start of Weapon Clip
RegisterNetEvent('esx_weaponammo:weaclip')
AddEventHandler('esx_weaponammo:weaclip', function()
local playerPed = PlayerPedId()
local hash = GetSelectedPedWeapon(playerPed)
local ammo = Config.WeaponClipAmmo
local weapon = ESX.GetWeaponFromHash(hash)
if IsPedArmed(playerPed, 4) then
if hash ~= nil then
if Config.CheckMaxAmmo then
local currentAmmo = GetAmmoInPedWeapon(playerPed, hash)
if currentAmmo + Config.WeaponClipAmmo <= Config.MaxAmmo then
AddAmmoToPed(PlayerPedId(), hash, ammo)
TriggerServerEvent('esx:updateWeaponAmmo', weapon.name, ammo)
TriggerServerEvent('esx_weaponammo:removeweaclip')
Citizen.Wait(100)
if Config.ChezzaInventory then
TriggerEvent('inventory:refresh', source) -- Chezza Inventory
end
ESX.ShowNotification(_U('used_weaclip'))
else
ESX.ShowNotification(_U('check_maxammo'))
end
else
AddAmmoToPed(PlayerPedId(), hash, ammo)
TriggerServerEvent('esx:updateWeaponAmmo', weapon.name, ammo)
TriggerServerEvent('esx_weaponammo:removeweaclip')
Citizen.Wait(100)
if Config.ChezzaInventory then
TriggerEvent('inventory:refresh', source) -- Chezza Inventory
end
ESX.ShowNotification(_U('used_weaclip'))
end
else
ESX.ShowNotification(_U('no_weapon'))
end
else
ESX.ShowNotification(_U('not_suitable'))
end
end)
okey i try back
is workā¦ but when i log out in gameā¦ then log in againā¦ ammo bullet in weapon gone back to 0
Then it doesnāt work as it should. Sorry to hear that. I donāt know how to fix that for you
nvm sirā¦ thank you so much
now is workā¦ auto save in database
Perfect !!!
thx i m looking for something like that !! thx
hey this is probs a stupid Question but will this be coming to Legacy?
You can try if it works with esx legacy. I only can test with esx 1.2
It works, only issue is the one I described in my previous post. When you have 2 same type weapons loaded and you drop one (I also use chezzaās inv), you lose ammo on both.
Hey, I donāt support the inventory, only the WeaponAmmo Script.
Hey, someone asked if it works on legacy and since I use both chezzaās inventory and esx legacy I stated my findings. You donāt support the inventory but Andy does and he reads the topic so he might come up with something in a future update.
Since I dont have a v1 final test server ready, when you have 2 pistols loaded and you drop one, does the other one loses ammo as well? For information purposes Thanks for your time.
I am using v1-final and having the same error as you describe.
But please do not ask for support for chezza inventory in this thread. Go to [Paid Release] Chezza's Inventory [ESX]
So can I add more clips?
Like I have one script that provided unmarked clips, curious if i could just add them here with out issue?
You can do that. Just copie client and server triggers an change event names.