• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ how to get cap of all items from table

gritness

New Member
Joined
May 26, 2021
Messages
33
Reaction score
3
Hi Guys,

Im looking for code which check free slots from player backpack before take quest reward.
I've done capacity checking, code is below, but need to add any code with slots checking

local playerCap = player:getFreeCapacity() / 100
local weight = 0
local needed_cap =0

for i = 1, #cfgItems do
weight = weight + ItemType(cfgItems[1]):getWeight(cfgItems[2])
end

if player:getStorageValue(storage_id) == 2 then

player:sendTextMessage(MESSAGE_INFO_DESCR, "You have already chosen your reward.")

elseif player:getStorageValue(storage_id) ~= 2 then

if playerCap >= needed_cap then

-- Here i need slots checking

player:sendTextMessage(MESSAGE_INFO_DESCR, "You found some items !")
local bag = player:addItem(14330) -- Bag id

if item:getUniqueId() == unique_id then
for i = 1, #cfgItems do
bag:addItem(cfgItems[1], cfgItems[2])
end

player:setStorageValue(storage_id, 2)

end

else player:sendTextMessage(MESSAGE_INFO_DESCR, "You have to low capacity.. \n You need ".. needed_cap .. " oz .")

end


someone can help ? :)
 
Top