Okay so I’m using a plugin called esx_weaponsync, the developer of the plugin asked me to add the following to my main.lua file in the client folder in es_extended:
RegisterNetEvent('esx:removeInventoryItem')
AddEventHandler('esx:removeInventoryItem', function(item, count, silent)
for i=1, #ESX.PlayerData.inventory, 1 do
if ESX.PlayerData.inventory[i].name == item.name then
ESX.PlayerData.inventory[i] = item
end
end
if not silent then
ESX.UI.ShowInventoryItemNotification(false, item, count)
end
if ESX.UI.Menu.IsOpen('default', 'es_extended', 'inventory') then
ESX.ShowInventory()
end
end)
This is the part that the script does to request a silent item removal, but for some reason it’s isn’t working:
RegisterServerEvent('esx:discardInventoryItem')
AddEventHandler('esx:discardInventoryItem', function(item, count)
local _source = source
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.removeInventoryItem(item, count, true)
end)
I’m sure something is going wrong with the script, normally I would see the issue but I just can’t find the issue in this script. I hope anyone is able to help me solve the issue. Any suggestion or tip is welcome.
I would love to share anything but for some reason others are not. I’ve to keep the scripts for our own. I’m very sorry, but if you need help with anything I’m happy to help. I just don’t really know how the script is working since I didn’t use it for a while.
for k,v in ipairs(ESX.PlayerData.inventory) do
if v.name == item.name then
ESX.PlayerData.inventory[k] = item
break
end
end
if not silent then
ESX.UI.ShowInventoryItemNotification(true, item, count)
end
if ESX.UI.Menu.IsOpen('default', 'es_extended', 'inventory') then
ESX.ShowInventory()
end
for k,v in ipairs(ESX.PlayerData.inventory) do
if v.name == item.name then
ESX.PlayerData.inventory[k] = item
break
end
end
if not silent then
ESX.UI.ShowInventoryItemNotification(false, item, count)
end
if ESX.UI.Menu.IsOpen('default', 'es_extended', 'inventory') then
ESX.ShowInventory()
end