gritness
Member
- Joined
- May 26, 2021
- Messages
- 33
- Reaction score
- 6
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 ?
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 ?