• 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!

check cap in player

theduck

Member
Joined
Dec 6, 2018
Messages
246
Reaction score
20
Code:
local function scanContainer(cid, position)
    local player = Player(cid)
    if not player then
        return
    end

    local corpse = Tile(position):getTopDownItem()
    if not corpse or not corpse:isContainer() then
        return
    end

    local playerId = player:getId()
    if AutoLootList.players[playerId] == nil then
        AutoLootList:save(playerId)
    end
    
 

    if AutoLootList.players[playerId] ~= nil then
 
 
        local lootList = AutoLootList.players[playerId].lootList
           
        if lootList ~= nil then
            if corpse:getType():isCorpse()    then
                for a = corpse:getSize() - 1, 0, -1 do
                    local containerItem = corpse:getItem(a)
                    if containerItem then
                        local containerItemId = containerItem:getId()
                        for i=1, #lootList do
                            local lootItemId = lootList[i] 
                               
                            if lootItemId == containerItemId   then 
                     
                            containerItem:moveTo(bag) 
 
                            end
                        end  
                    end
                end
            end
        end  
     end    
end


I'm trying to check this script
if you don't have cap you get a warning msg
but it turns out that even with or without cap only appears the warning msg
 
Solution
I think that he is trying to tell you that:
Lua:
local item = ItemType(2494) --Demon Armor
local weight = item:getWeight()
if player:getFreeCapacity() < weight then
    player:sendCancelMessage('You have no capacity.')
else
    player:sendCancelMessage('You have capacity.')
end
You must need to compare:

player:getCapacity() with itemType:getCapacity()
 
I think that he is trying to tell you that:
Lua:
local item = ItemType(2494) --Demon Armor
local weight = item:getWeight()
if player:getFreeCapacity() < weight then
    player:sendCancelMessage('You have no capacity.')
else
    player:sendCancelMessage('You have capacity.')
end
 
Solution
Back
Top