RegisterNetEvent(‘deleteinv’)
AddEventHandler(‘deleteinv’, function(names, amounts)
–check
local c = playerhasitem(tostring(names))
if c == 1 then
for i,v in pairs(myinv) do
if v.Name == tostring(names) then
v.Amount = v.Amount - tonumber(amounts)
v.Amount = math.floor(v.Amount)
if v.Amount < 1 then -- **This Line**
table.remove(v, i)
end
--extableid = 1
TriggerEvent("chatMessage", "SYSTEM", { 0, 141, 155 }, names .. " was deleted in your inventory with " .. amounts .. " amount")
TriggerEvent("chatMessage", "Inv-System:", { 255,99,71 }, "^0Now you have " .. #myinv .. " item inside")
break
end
end
else
TriggerEvent("chatMessage", "NOT-FOUND[Debug]", { 255,99,71 }, "^0System try to remove non-exist item")
end
end)
my custom inventory system… everything work fine… but when i my v.amount is less than 1… why it not remove my table? can anyone help?