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

Ring loot chance TFS 1.5 downgrade 8.6

Azerty

Active Member
Joined
Apr 15, 2022
Messages
307
Solutions
4
Reaction score
31
Can anyone help me with this error?

ring.JPG

Lua:
function Monster:onDropLoot(corpse)
    if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
        return
    end
    
    local player = Player(corpse:getCorpseOwner())
    local mType = self:getType()
    if not player or player:getStamina() > 840 then
        local monsterLoot = mType:getLoot()
        for i = 1, #monsterLoot do
        
            -- // NEW CODE
            local ring = player:getSlotItem(CONST_SLOT_RING)
            if ring and ring:getId() == 13825 then
                local extraPercent = 10
                local default = monsterLoot[i].chance
            
                if default < 100000 then
                    monsterLoot[i].chance = default + ((extraPercent * (default / 1000) / 100) * 1000)
                end
            end
            -- // NEW CODE

            -- // NEW CODE
            local ring = player:getSlotItem(CONST_SLOT_RING)
            if ring and ring:getId() == 2179 then
                local extraPercent = 5
                local default = monsterLoot[i].chance
            
                if default < 100000 then
                    monsterLoot[i].chance = default + ((extraPercent * (default / 1000) / 100) * 1000)
                end
            end
            -- // NEW CODE   

            -- // NEW CODE
            local ring = player:getSlotItem(CONST_SLOT_RING)
            if ring and ring:getId() == 2124 then
                local extraPercent = 2
                local default = monsterLoot[i].chance
            
                if default < 100000 then
                    monsterLoot[i].chance = default + ((extraPercent * (default / 1000) / 100) * 1000)
                end
            end
            -- // NEW CODE       
        
            local item = corpse:createLootItem(monsterLoot[i])
            if not item then
                print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
            end
        end

        if player then
            local text = ("Loot of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
            local party = player:getParty()
            if party then
                party:broadcastPartyLoot(text)
            else
                player:sendTextMessage(MESSAGE_INFO_DESCR, text)
            end
        end
    else
        local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription())
        local party = player:getParty()
        if party then
            party:broadcastPartyLoot(text)
        else
            player:sendTextMessage(MESSAGE_INFO_DESCR, text)
        end
    end
end
 
Solution
Lua:
local items = {
    [13825] = {percent = 10, slot = CONST_SLOT_RING},
    [2179] = {percent = 5, slot = CONST_SLOT_RING},
    [2124] = {percent = 2, slot = CONST_SLOT_RING}
}

function Monster:onDropLoot(corpse)
    if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
        return
    end
  
    local extraLootPercent = 0
    local player = Player(corpse:getCorpseOwner())
    local mType = self:getType()
    if not player or player:getStamina() > 840 then

        if player then
            for k, v in pairs(items) do
                local item = player:getSlotItem(v.slot)
                if (item and item:getId() == k) then
                    extraLootPercent = extraLootPercent + v.percent
                end
            end...
Lua:
local items = {
    [13825] = {percent = 10, slot = CONST_SLOT_RING},
    [2179] = {percent = 5, slot = CONST_SLOT_RING},
    [2124] = {percent = 2, slot = CONST_SLOT_RING}
}

function Monster:onDropLoot(corpse)
    if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
        return
    end
  
    local extraLootPercent = 0
    local player = Player(corpse:getCorpseOwner())
    local mType = self:getType()
    if not player or player:getStamina() > 840 then

        if player then
            for k, v in pairs(items) do
                local item = player:getSlotItem(v.slot)
                if (item and item:getId() == k) then
                    extraLootPercent = extraLootPercent + v.percent
                end
            end
        end

        local monsterLoot = mType:getLoot()
        for i = 1, #monsterLoot do
            local default = monsterLoot[i].chance
            if (extraLootPercent > 0 and default < 100000) then
                monsterLoot[i].chance = default + ((extraLootPercent * (default / 1000) / 100) * 1000)
            end
            local item = corpse:createLootItem(monsterLoot[i])
            if not item then
                print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
            end
        end

        if player then
            local text = ("Loot of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
            local party = player:getParty()
            if party then
                party:broadcastPartyLoot(text)
            else
                player:sendTextMessage(MESSAGE_INFO_DESCR, text)
            end
        end
    else
        local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription())
        local party = player:getParty()
        if party then
            party:broadcastPartyLoot(text)
        else
            player:sendTextMessage(MESSAGE_INFO_DESCR, text)
        end
    end
end
 
Last edited:
Solution
Lua:
local items = {
    [13825] = {percent = 10, slot = CONST_SLOT_RING},
    [2179] = {percent = 5, slot = CONST_SLOT_RING},
    [2124] = {percent = 2, slot = CONST_SLOT_RING}
}

function Monster:onDropLoot(corpse)
    if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
        return
    end
 
    local extraLootPercent = 0
    local player = Player(corpse:getCorpseOwner())
    local mType = self:getType()
    if not player or player:getStamina() > 840 then

        if player then
            for k, v in pairs(items) do
                local item = player:getSlotItem(v.slot)
                if (item and item:getId() == k) then
                    extraLootPercent = extraLootPercent + v.percent
                end
            end
        end

        local monsterLoot = mType:getLoot()
        for i = 1, #monsterLoot do
            local default = monsterLoot[i].chance
            if (extraLootPercent > 0 and default < 100000) then
                monsterLoot[i].chance = default + ((extraLootPercent * (default / 1000) / 100) * 1000)
            end
            local item = corpse:createLootItem(monsterLoot[i])
            if not item then
                print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
            end
        end

        if player then
            local text = ("Loot of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
            local party = player:getParty()
            if party then
                party:broadcastPartyLoot(text)
            else
                player:sendTextMessage(MESSAGE_INFO_DESCR, text)
            end
        end
    else
        local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription())
        local party = player:getParty()
        if party then
            party:broadcastPartyLoot(text)
        else
            player:sendTextMessage(MESSAGE_INFO_DESCR, text)
        end
    end
end
Thank u!
 
Back
Top