• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

TFS 0.X table index autoloot system

hiwyn

Member
Joined
Aug 30, 2021
Messages
69
Reaction score
7
I'm trying to use @Sarah Wesker code (My Autoloot System for TFS 0.4 (My Autoloot System for TFS 0.4 (https://otland.net/threads/my-autoloot-system-for-tfs-0-4.264702/))) with @Alpha suggestion (My Autoloot System for TFS 0.4 (My Autoloot System for TFS 0.4 (https://otland.net/threads/my-autoloot-system-for-tfs-0-4.264702/post-2688617))), but it is not working here

!autoloot (legion helmet added)

Code:
    Welcomen to Autoloot System Create by Millhiore BT Options: help, clear, add, remove You available slots: 3 Your autoloot items:  legion helmet


i kill a rotworm, drops a legion helmet

Code:
00:53 Loot of a rotworm: a legion helmet, a lump of dirt, a mace, ham, meat, 11 gold coins.

but the script didn't send it to my backpack


did i put the if in a wrong place?

Code:
    <event type="combat" name="AutolootRBTCombat" event="script">

    <![CDATA[

    local monsters = {

        ["rat"] = true,

        ["cave rat"] = true,

        ["demon"] = true,

        ["troll"] = true,

        ["rotworm"] = true,

    }

    if not monsters[getCreatureName(target):lower()] then

        registerCreatureEvent(target, "AutolootRBTDeath")

    end

    return true

    ]]>

    </event>


full code:

Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>

    <mod name="Autoloot Revolution BT" version="1.0" author="Millhiore BT" contact="none.com" enabled="yes">

    <config name="AutolootRevolutionBT">

    <![CDATA[

    [email protected] You configurations:

    autolootConfig = {}

    autolootConfig.storageItems = 27000

    autolootConfig.blockMonsters = {}

    autolootConfig.goldToBank = true

    autolootConfig.goldBankAnimation = true

    autolootConfig.distanceLooting = 7

    autolootConfig.freeSlots = 3

    autolootConfig.premiumSlots = 6

    autolootConfig.vipStorage = {0,0}

    autolootConfig.playerLevel = 8

    autolootConfig.corpseEffect = CONST_ME_NONE

    autolootConfig.golds = {2148, 2152, 2160}

    autolootConfig.tittle = "Welcomen to Autoloot System\nCreate by Millhiore BT\n\nOptions: help, clear, add, remove\n"

    autolootConfig.notHaveCapDrop = false

    [email protected] getPlayerPremiumEnabled(cid)

    --# Return boolean

    --# Create by Millhiore BT

    function getPlayerPremiumEnabled(cid)

        if getConfigValue("freePremium") then

            return true

        end

        return getPlayerPremiumDays(cid) > 0

    end

    [email protected] getPlayerAutolootVip(cid)

    --# Return boolean

    --# Create by Millhiore BT

    function getPlayerAutolootVip(cid)

        if autolootConfig.vipStorage[1] > 0 then

            if autolootConfig.vipStorage[2] > 0 then

                return getPlayerStorageValue(cid, autolootConfig.vipStorage[1]) == autolootConfig.vipStorage[2]

            else

                return getPlayerStorageValue(cid, autolootConfig.vipStorage[1]) >= os.time()

            end

        end

        return true

    end

    [email protected] getPositionDistance(position, positionEx)

    --# Return number

    --# Create by Millhiore BT

    function getPositionDistance(position, positionEx)

        return math.max(math.max(math.abs(position.x - positionEx.x), math.abs(position.y - positionEx.y)), math.abs(position.z - positionEx.z))

    end

    [email protected] getPositionCorpse(pos [, itemid])

    --# Return thing/nil

    --# Create by Millhiore BT

    function getPositionCorpse(pos, itemid)

        local tile = getTileInfo(pos)

        for index = 0, tile.things do

            pos.stackpos = index

            local corpse = getThingFromPos(pos, false)

            if corpse.itemid > 1 and isCorpse(corpse.uid) then

                local itemid = itemid or corpse.itemid

                if corpse.itemid == itemid then

                    return corpse

                end

            end

        end

    end

    [email protected] getContainerItems(uid [, array])

    --# Return array

    --# Create by Millhiore BT

    function getContainerItems(container, array, haveCap)

        array = array or {}

        haveCap = haveCap or false

        if not isContainer(container.uid) or getContainerSize(container.uid) == 0 then

            array[#array +1] = container

        else

            local size = getContainerSize(container.uid)

            haveCap = (getContainerCap(container.uid) -size) > 0

            for slot = 0, (size -1) do

                local item = getContainerItem(container.uid, slot)

                if item.itemid > 1 then

                    getContainerItems(item, array, haveCap)

                end

            end

        end

        return #array >= 1 and array, haveCap

    end

    [email protected] getContainerItemsById(array/uid, itemid)

    --# Return array

    --# Create by Millhiore BT

    function getContainerItemsById(container, itemid)

        local founds = {}

        local items = not container.uid and container or getContainerItems(container)

        for index, item in pairs(items) do

            if item.itemid == itemid then

                founds[#founds +1] = item

            end

        end

        return #founds >= 1 and founds

    end

    [email protected] doPlayerAddItemStackable(cid, itemid, count)

    --# Return boolean

    --# Create by Millhiore BT

    function doPlayerAddItemStackable(cid, itemid, count)

        local container = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK)

        if container.itemid > 1 then

            local items = getContainerItemsById(container, itemid)

            if not items then

                return doPlayerAddItem(cid, itemid, count)

            else

                local piles = #items

                for index, item in pairs(items) do

                    if item.type < 100 then

                        local sum = item.type + count

                        local result = doTransformItem(item.uid, itemid, sum)

                        if sum <= 100 then

                            return result

                        else

                            return doPlayerAddItem(cid, itemid, sum - 100)

                        end

                    else

                        piles = piles - 1

                        if piles == 0 then

                            return doPlayerAddItem(cid, itemid, count)

                        end

                    end

                end

            end

        end

        return false

    end

    [email protected] getContainerMoneys(items)

    --# Return array/false

    --# Create by Millhiore BT

    function getContainerMoneys(items)

        local moneys = {}

        for slot, item in pairs(items) do

            if isInArray(autolootConfig.golds, item.itemid) then

                moneys[#moneys +1] = item

            end

        end

        return #moneys > 0 and moneys

    end

    [email protected] doCorpseAutoloot(cid, pos itemid)

    --# Return boolean/nil

    --# Create by Millhiore BT

    function doCorpseAutoloot(cid, pos, itemid, moneys)

        if not getPlayerAutolootVip(cid) or getPositionDistance(getThingPosition(cid), pos) > autolootConfig.distanceLooting

        or getPlayerLevel(cid) < autolootConfig.playerLevel then

            return nil

        end

        local corpse = getPositionCorpse(pos, itemid)

        if corpse and isContainer(corpse.uid) then

            local items, haveCap = moneys or getContainerItems(corpse)

            local sendEffect = false

            if items then

                for slot, item in pairs(items) do

                    if isInArray(getPlayerAutolootItems(cid), item.itemid) then

                        sendEffect = true

                        local removeIt = false

                        local goldToBank = autolootConfig.goldToBank and isInArray(autolootConfig.golds, item.itemid)

                        if not goldToBank then

                            if not haveCap and autolootConfig.notHaveCapDrop then

                                return doCorpseAutoloot(cid, pos, itemid, getContainerMoneys(items))

                            end

                            if isItemStackable(item.itemid) then

                                removeIt = doPlayerAddItemStackable(cid, item.itemid, item.type)

                            else

                                removeIt = doPlayerAddItem(cid, item.itemid)

                            end

                        else

                            local add = (getItemInfo(item.itemid).worth * item.type)

                            removeIt = doPlayerSetBalance(cid, getPlayerBalance(cid) + add)

                            if autolootConfig.goldBankAnimation then

                                doSendAnimatedText(pos, string.format("+%u gps", add), TEXTCOLOR_YELLOW, cid)

                            end

                        end

                        if removeIt then

                            doRemoveItem(item.uid)

                        end

                    end

                end

                if sendEffect then

                    doSendMagicEffect(pos, autolootConfig.corpseEffect, cid)

                end

                return true

            end

        end

    end

    [email protected] getPlayerAutolootItems(cid)

    --# Return array

    --# Create by Millhiore BT

    function getPlayerAutolootItems(cid)

        local array = {}

        local content = tostring(getPlayerStorageValue(cid, autolootConfig.storageItems))

        for itemid in string.gmatch(content, "(%d+):") do

            array[#array +1] = tonumber(itemid)

        end

        return array

    end

    [email protected] getPlayerAutolootItem(cid, itemid)

    --# Return number/nil

    --# Create by Millhiore BT

    function getPlayerAutolootItem(cid, itemid)

        local autolootItems = getPlayerAutolootItems(cid)

        for index, id in pairs(autolootItems) do

            if itemid == id then

                return index

            end

        end

    end

    [email protected] setPlayerAutolootItems(cid [, array])

    --# Return boolean

    --# Create by Millhiore BT

    function setPlayerAutolootItems(cid, array)

        local array = array or {}

        local content = "&"

        for index, itemid in pairs(array) do

            content = string.format("%s%u:", content, itemid)

        end

        return setPlayerStorageValue(cid, autolootConfig.storageItems, content)

    end

    [email protected] addPlayerAutolootItem(cid, itemid)

    --# Return boolean

    --# Create by Millhiore BT

    function addPlayerAutolootItem(cid, itemid)

        local autolootItems = getPlayerAutolootItems(cid)

        local found = getPlayerAutolootItem(cid, itemid)

        if not found then

            autolootItems[#autolootItems +1] = itemid

            return setPlayerAutolootItems(cid, autolootItems)

        end

    end

    [email protected] removePlayerAutolootItem(cid, itemid)

    --# Return boolean/nil

    --# Create by Millhiore BT

    function removePlayerAutolootItem(cid, itemid)

        local autolootItems = getPlayerAutolootItems(cid)

        local found = getPlayerAutolootItem(cid, itemid)

        if found then

            table.remove(autolootItems, found)

            return setPlayerAutolootItems(cid, autolootItems)

        end

    end

    [email protected] showPlayerAutoloot(cid)

    --# Return boolean

    --# Create by Millhiore BT

    function showPlayerAutoloot(cid)

        local maxItems = getPlayerPremiumEnabled(cid) and autolootConfig.premiumSlots or autolootConfig.freeSlots

        local content = string.format("%sYou available slots: %u\n\n%s", autolootConfig.tittle, maxItems, "Your autoloot items:\n")

        local autolootItems = getPlayerAutolootItems(cid)

        for index, itemid in pairs(autolootItems) do

            local it = getItemInfo(itemid)

            content = string.format("%s %c %s\n", content, 155, it.name)

        end

        return doShowTextDialog(cid, 2529, content)

    end

    [email protected] showPlayerAutolootHelp(cid)

    --# Return boolean

    --# Create by Millhiore BT

    function showPlayerAutolootHelp(cid)

        local content = autolootConfig.tittle .. "For you info:\n"

        for key, value in pairs(autolootConfig) do

            if not isInArray({"storageItems", "blockMonsters", "vipStorage", "golds", "tittle"}, key) then

                content = string.format("%s%c %s: %s\n", content, 155, tostring(key), tostring(value))

            end

        end

        return doShowTextDialog(cid, 2529, content)

    end

    ]]>

    </config>

    <event type="login" name="AutolootRBTLogin" event="script">

    <![CDATA[

    function onLogin(cid)

        local maxItems = getPlayerPremiumEnabled(cid) and autolootConfig.premiumSlots or autolootConfig.freeSlots

        local autolootItems = getPlayerAutolootItems(cid)

        if #autolootItems > maxItems then

            for index = autolootConfig.premiumSlots, autolootConfig.freeSlots, -1 do

                table.remove(autolootItems, index)

            end

            setPlayerAutolootItems(cid, autolootItems)

            doPlayerSendCancel(cid, "Your list of items overflowed, you should check your list.")

        end

        registerCreatureEvent(cid, "AutolootRBTCombat")

        return true

    end

    ]]>

    </event>

    <event type="death" name="AutolootRBTDeath" event="script">

    <![CDATA[

    domodlib("AutolootRevolutionBT")

    function onDeath(cid, corpse, deathList)

        local killer = deathList[1]

        local position = getThingPosition(cid)

        if corpse.itemid > 1 then

            addEvent(doCorpseAutoloot, 100, killer, position, corpse.itemid)

        end

        return true

    end

    ]]>

    </event>

    <event type="combat" name="AutolootRBTCombat" event="script">

    <![CDATA[

    local monsters = {

        ["rat"] = true,

        ["cave rat"] = true,

        ["demon"] = true,

        ["troll"] = true,

        ["rotworm"] = true,

    }

    if not monsters[getCreatureName(target):lower()] then

        registerCreatureEvent(target, "AutolootRBTDeath")

    end

    return true

    ]]>

    </event>

    <talkaction words="!autoloot;/autoloot" event="buffer">

    <![CDATA[

    domodlib("AutolootRevolutionBT")

    local split = string.explode(param, ",") or {}

    local action = tostring(split[1]):lower()

    local name = tostring(split[2])

    local itemid = getItemIdByName(name, false)

    local it = getItemInfo(itemid and itemid or 0)

    local position = getThingPosition(cid)

    if action == "add" then

        if not it then

            doPlayerSendCancel(cid, string.format("This item %s does not exist.", name))

        else

            local maxItems = getPlayerPremiumEnabled(cid) and autolootConfig.premiumSlots or autolootConfig.freeSlots

            local autolootItems = getPlayerAutolootItems(cid)

            if #autolootItems > maxItems then

                for index = autolootConfig.premiumSlots, autolootConfig.freeSlots, -1 do

                    table.remove(autolootItems, index)

                end

                setPlayerAutolootItems(cid, autolootItems)

                doPlayerSendCancel(cid, "Your list of items overflowed, you should check your list.")

            elseif #autolootItems == maxItems then

                doPlayerSendCancel(cid, string.format("Your maximum limit is %u items, you must eliminate one to add another.", maxItems))

            elseif addPlayerAutolootItem(cid, itemid) then

                doPlayerSendCancel(cid, string.format("You added the item %s in the list.", name))

            else

                doSendMagicEffect(position, CONST_ME_POFF, cid)

                doPlayerSendCancel(cid, string.format("This item %s already in the list.", name))

            end

        end

    elseif action == "remove" then

        if not it then

            doPlayerSendCancel(cid, string.format("This item %s does not exist.", name))

        else

            if removePlayerAutolootItem(cid, itemid) then

                doPlayerSendCancel(cid, string.format("You removed the item %s from the list.", name))

            else

                doPlayerSendCancel(cid, string.format("This item %s is not in the list.", name))

            end

        end

    elseif action == "help" then

        showPlayerAutolootHelp(cid)

    elseif action == "clear" then

        setPlayerAutolootItems(cid)

        doPlayerSendCancel(cid, "The list of items is now empty.")

    else

        showPlayerAutoloot(cid)

    end

    return true

    ]]>

    </talkaction>

    </mod>


idk what to do? anybody does?
 

Xikini

I whore myself out for likes
Senator
Joined
Nov 17, 2010
Messages
6,245
Solutions
545
Reaction score
4,482
I'm trying to use @Sarah Wesker code (My Autoloot System for TFS 0.4 (My Autoloot System for TFS 0.4 (https://otland.net/threads/my-autoloot-system-for-tfs-0-4.264702/))) with @Alpha suggestion (My Autoloot System for TFS 0.4 (My Autoloot System for TFS 0.4 (https://otland.net/threads/my-autoloot-system-for-tfs-0-4.264702/post-2688617))), but it is not working here

!autoloot (legion helmet added)

Code:
    Welcomen to Autoloot System Create by Millhiore BT Options: help, clear, add, remove You available slots: 3 Your autoloot items:  legion helmet


i kill a rotworm, drops a legion helmet

Code:
00:53 Loot of a rotworm: a legion helmet, a lump of dirt, a mace, ham, meat, 11 gold coins.

but the script didn't send it to my backpack


did i put the if in a wrong place?

Code:
    <event type="combat" name="AutolootRBTCombat" event="script">

    <![CDATA[

    local monsters = {

        ["rat"] = true,

        ["cave rat"] = true,

        ["demon"] = true,

        ["troll"] = true,

        ["rotworm"] = true,

    }

    if not monsters[getCreatureName(target):lower()] then

        registerCreatureEvent(target, "AutolootRBTDeath")

    end

    return true

    ]]>

    </event>


full code:

Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>

    <mod name="Autoloot Revolution BT" version="1.0" author="Millhiore BT" contact="none.com" enabled="yes">

    <config name="AutolootRevolutionBT">

    <![CDATA[

    [email protected] You configurations:

    autolootConfig = {}

    autolootConfig.storageItems = 27000

    autolootConfig.blockMonsters = {}

    autolootConfig.goldToBank = true

    autolootConfig.goldBankAnimation = true

    autolootConfig.distanceLooting = 7

    autolootConfig.freeSlots = 3

    autolootConfig.premiumSlots = 6

    autolootConfig.vipStorage = {0,0}

    autolootConfig.playerLevel = 8

    autolootConfig.corpseEffect = CONST_ME_NONE

    autolootConfig.golds = {2148, 2152, 2160}

    autolootConfig.tittle = "Welcomen to Autoloot System\nCreate by Millhiore BT\n\nOptions: help, clear, add, remove\n"

    autolootConfig.notHaveCapDrop = false

    [email protected] getPlayerPremiumEnabled(cid)

    --# Return boolean

    --# Create by Millhiore BT

    function getPlayerPremiumEnabled(cid)

        if getConfigValue("freePremium") then

            return true

        end

        return getPlayerPremiumDays(cid) > 0

    end

    [email protected] getPlayerAutolootVip(cid)

    --# Return boolean

    --# Create by Millhiore BT

    function getPlayerAutolootVip(cid)

        if autolootConfig.vipStorage[1] > 0 then

            if autolootConfig.vipStorage[2] > 0 then

                return getPlayerStorageValue(cid, autolootConfig.vipStorage[1]) == autolootConfig.vipStorage[2]

            else

                return getPlayerStorageValue(cid, autolootConfig.vipStorage[1]) >= os.time()

            end

        end

        return true

    end

    [email protected] getPositionDistance(position, positionEx)

    --# Return number

    --# Create by Millhiore BT

    function getPositionDistance(position, positionEx)

        return math.max(math.max(math.abs(position.x - positionEx.x), math.abs(position.y - positionEx.y)), math.abs(position.z - positionEx.z))

    end

    [email protected] getPositionCorpse(pos [, itemid])

    --# Return thing/nil

    --# Create by Millhiore BT

    function getPositionCorpse(pos, itemid)

        local tile = getTileInfo(pos)

        for index = 0, tile.things do

            pos.stackpos = index

            local corpse = getThingFromPos(pos, false)

            if corpse.itemid > 1 and isCorpse(corpse.uid) then

                local itemid = itemid or corpse.itemid

                if corpse.itemid == itemid then

                    return corpse

                end

            end

        end

    end

    [email protected] getContainerItems(uid [, array])

    --# Return array

    --# Create by Millhiore BT

    function getContainerItems(container, array, haveCap)

        array = array or {}

        haveCap = haveCap or false

        if not isContainer(container.uid) or getContainerSize(container.uid) == 0 then

            array[#array +1] = container

        else

            local size = getContainerSize(container.uid)

            haveCap = (getContainerCap(container.uid) -size) > 0

            for slot = 0, (size -1) do

                local item = getContainerItem(container.uid, slot)

                if item.itemid > 1 then

                    getContainerItems(item, array, haveCap)

                end

            end

        end

        return #array >= 1 and array, haveCap

    end

    [email protected] getContainerItemsById(array/uid, itemid)

    --# Return array

    --# Create by Millhiore BT

    function getContainerItemsById(container, itemid)

        local founds = {}

        local items = not container.uid and container or getContainerItems(container)

        for index, item in pairs(items) do

            if item.itemid == itemid then

                founds[#founds +1] = item

            end

        end

        return #founds >= 1 and founds

    end

    [email protected] doPlayerAddItemStackable(cid, itemid, count)

    --# Return boolean

    --# Create by Millhiore BT

    function doPlayerAddItemStackable(cid, itemid, count)

        local container = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK)

        if container.itemid > 1 then

            local items = getContainerItemsById(container, itemid)

            if not items then

                return doPlayerAddItem(cid, itemid, count)

            else

                local piles = #items

                for index, item in pairs(items) do

                    if item.type < 100 then

                        local sum = item.type + count

                        local result = doTransformItem(item.uid, itemid, sum)

                        if sum <= 100 then

                            return result

                        else

                            return doPlayerAddItem(cid, itemid, sum - 100)

                        end

                    else

                        piles = piles - 1

                        if piles == 0 then

                            return doPlayerAddItem(cid, itemid, count)

                        end

                    end

                end

            end

        end

        return false

    end

    [email protected] getContainerMoneys(items)

    --# Return array/false

    --# Create by Millhiore BT

    function getContainerMoneys(items)

        local moneys = {}

        for slot, item in pairs(items) do

            if isInArray(autolootConfig.golds, item.itemid) then

                moneys[#moneys +1] = item

            end

        end

        return #moneys > 0 and moneys

    end

    [email protected] doCorpseAutoloot(cid, pos itemid)

    --# Return boolean/nil

    --# Create by Millhiore BT

    function doCorpseAutoloot(cid, pos, itemid, moneys)

        if not getPlayerAutolootVip(cid) or getPositionDistance(getThingPosition(cid), pos) > autolootConfig.distanceLooting

        or getPlayerLevel(cid) < autolootConfig.playerLevel then

            return nil

        end

        local corpse = getPositionCorpse(pos, itemid)

        if corpse and isContainer(corpse.uid) then

            local items, haveCap = moneys or getContainerItems(corpse)

            local sendEffect = false

            if items then

                for slot, item in pairs(items) do

                    if isInArray(getPlayerAutolootItems(cid), item.itemid) then

                        sendEffect = true

                        local removeIt = false

                        local goldToBank = autolootConfig.goldToBank and isInArray(autolootConfig.golds, item.itemid)

                        if not goldToBank then

                            if not haveCap and autolootConfig.notHaveCapDrop then

                                return doCorpseAutoloot(cid, pos, itemid, getContainerMoneys(items))

                            end

                            if isItemStackable(item.itemid) then

                                removeIt = doPlayerAddItemStackable(cid, item.itemid, item.type)

                            else

                                removeIt = doPlayerAddItem(cid, item.itemid)

                            end

                        else

                            local add = (getItemInfo(item.itemid).worth * item.type)

                            removeIt = doPlayerSetBalance(cid, getPlayerBalance(cid) + add)

                            if autolootConfig.goldBankAnimation then

                                doSendAnimatedText(pos, string.format("+%u gps", add), TEXTCOLOR_YELLOW, cid)

                            end

                        end

                        if removeIt then

                            doRemoveItem(item.uid)

                        end

                    end

                end

                if sendEffect then

                    doSendMagicEffect(pos, autolootConfig.corpseEffect, cid)

                end

                return true

            end

        end

    end

    [email protected] getPlayerAutolootItems(cid)

    --# Return array

    --# Create by Millhiore BT

    function getPlayerAutolootItems(cid)

        local array = {}

        local content = tostring(getPlayerStorageValue(cid, autolootConfig.storageItems))

        for itemid in string.gmatch(content, "(%d+):") do

            array[#array +1] = tonumber(itemid)

        end

        return array

    end

    [email protected] getPlayerAutolootItem(cid, itemid)

    --# Return number/nil

    --# Create by Millhiore BT

    function getPlayerAutolootItem(cid, itemid)

        local autolootItems = getPlayerAutolootItems(cid)

        for index, id in pairs(autolootItems) do

            if itemid == id then

                return index

            end

        end

    end

    [email protected] setPlayerAutolootItems(cid [, array])

    --# Return boolean

    --# Create by Millhiore BT

    function setPlayerAutolootItems(cid, array)

        local array = array or {}

        local content = "&"

        for index, itemid in pairs(array) do

            content = string.format("%s%u:", content, itemid)

        end

        return setPlayerStorageValue(cid, autolootConfig.storageItems, content)

    end

    [email protected] addPlayerAutolootItem(cid, itemid)

    --# Return boolean

    --# Create by Millhiore BT

    function addPlayerAutolootItem(cid, itemid)

        local autolootItems = getPlayerAutolootItems(cid)

        local found = getPlayerAutolootItem(cid, itemid)

        if not found then

            autolootItems[#autolootItems +1] = itemid

            return setPlayerAutolootItems(cid, autolootItems)

        end

    end

    [email protected] removePlayerAutolootItem(cid, itemid)

    --# Return boolean/nil

    --# Create by Millhiore BT

    function removePlayerAutolootItem(cid, itemid)

        local autolootItems = getPlayerAutolootItems(cid)

        local found = getPlayerAutolootItem(cid, itemid)

        if found then

            table.remove(autolootItems, found)

            return setPlayerAutolootItems(cid, autolootItems)

        end

    end

    [email protected] showPlayerAutoloot(cid)

    --# Return boolean

    --# Create by Millhiore BT

    function showPlayerAutoloot(cid)

        local maxItems = getPlayerPremiumEnabled(cid) and autolootConfig.premiumSlots or autolootConfig.freeSlots

        local content = string.format("%sYou available slots: %u\n\n%s", autolootConfig.tittle, maxItems, "Your autoloot items:\n")

        local autolootItems = getPlayerAutolootItems(cid)

        for index, itemid in pairs(autolootItems) do

            local it = getItemInfo(itemid)

            content = string.format("%s %c %s\n", content, 155, it.name)

        end

        return doShowTextDialog(cid, 2529, content)

    end

    [email protected] showPlayerAutolootHelp(cid)

    --# Return boolean

    --# Create by Millhiore BT

    function showPlayerAutolootHelp(cid)

        local content = autolootConfig.tittle .. "For you info:\n"

        for key, value in pairs(autolootConfig) do

            if not isInArray({"storageItems", "blockMonsters", "vipStorage", "golds", "tittle"}, key) then

                content = string.format("%s%c %s: %s\n", content, 155, tostring(key), tostring(value))

            end

        end

        return doShowTextDialog(cid, 2529, content)

    end

    ]]>

    </config>

    <event type="login" name="AutolootRBTLogin" event="script">

    <![CDATA[

    function onLogin(cid)

        local maxItems = getPlayerPremiumEnabled(cid) and autolootConfig.premiumSlots or autolootConfig.freeSlots

        local autolootItems = getPlayerAutolootItems(cid)

        if #autolootItems > maxItems then

            for index = autolootConfig.premiumSlots, autolootConfig.freeSlots, -1 do

                table.remove(autolootItems, index)

            end

            setPlayerAutolootItems(cid, autolootItems)

            doPlayerSendCancel(cid, "Your list of items overflowed, you should check your list.")

        end

        registerCreatureEvent(cid, "AutolootRBTCombat")

        return true

    end

    ]]>

    </event>

    <event type="death" name="AutolootRBTDeath" event="script">

    <![CDATA[

    domodlib("AutolootRevolutionBT")

    function onDeath(cid, corpse, deathList)

        local killer = deathList[1]

        local position = getThingPosition(cid)

        if corpse.itemid > 1 then

            addEvent(doCorpseAutoloot, 100, killer, position, corpse.itemid)

        end

        return true

    end

    ]]>

    </event>

    <event type="combat" name="AutolootRBTCombat" event="script">

    <![CDATA[

    local monsters = {

        ["rat"] = true,

        ["cave rat"] = true,

        ["demon"] = true,

        ["troll"] = true,

        ["rotworm"] = true,

    }

    if not monsters[getCreatureName(target):lower()] then

        registerCreatureEvent(target, "AutolootRBTDeath")

    end

    return true

    ]]>

    </event>

    <talkaction words="!autoloot;/autoloot" event="buffer">

    <![CDATA[

    domodlib("AutolootRevolutionBT")

    local split = string.explode(param, ",") or {}

    local action = tostring(split[1]):lower()

    local name = tostring(split[2])

    local itemid = getItemIdByName(name, false)

    local it = getItemInfo(itemid and itemid or 0)

    local position = getThingPosition(cid)

    if action == "add" then

        if not it then

            doPlayerSendCancel(cid, string.format("This item %s does not exist.", name))

        else

            local maxItems = getPlayerPremiumEnabled(cid) and autolootConfig.premiumSlots or autolootConfig.freeSlots

            local autolootItems = getPlayerAutolootItems(cid)

            if #autolootItems > maxItems then

                for index = autolootConfig.premiumSlots, autolootConfig.freeSlots, -1 do

                    table.remove(autolootItems, index)

                end

                setPlayerAutolootItems(cid, autolootItems)

                doPlayerSendCancel(cid, "Your list of items overflowed, you should check your list.")

            elseif #autolootItems == maxItems then

                doPlayerSendCancel(cid, string.format("Your maximum limit is %u items, you must eliminate one to add another.", maxItems))

            elseif addPlayerAutolootItem(cid, itemid) then

                doPlayerSendCancel(cid, string.format("You added the item %s in the list.", name))

            else

                doSendMagicEffect(position, CONST_ME_POFF, cid)

                doPlayerSendCancel(cid, string.format("This item %s already in the list.", name))

            end

        end

    elseif action == "remove" then

        if not it then

            doPlayerSendCancel(cid, string.format("This item %s does not exist.", name))

        else

            if removePlayerAutolootItem(cid, itemid) then

                doPlayerSendCancel(cid, string.format("You removed the item %s from the list.", name))

            else

                doPlayerSendCancel(cid, string.format("This item %s is not in the list.", name))

            end

        end

    elseif action == "help" then

        showPlayerAutolootHelp(cid)

    elseif action == "clear" then

        setPlayerAutolootItems(cid)

        doPlayerSendCancel(cid, "The list of items is now empty.")

    else

        showPlayerAutoloot(cid)

    end

    return true

    ]]>

    </talkaction>

    </mod>


idk what to do? anybody does?
The list of monsters you've put there is 'blocked creatures'. So every monster except what's on that list will be auto-looted.

So in your example, you've added rotworm to a list that specifically blocks it from being auto-looted, and thus are not auto-looting the legion helmet. xD
 
OP
OP
hiwyn

hiwyn

Member
Joined
Aug 30, 2021
Messages
69
Reaction score
7
The list of monsters you've put there is 'blocked creatures'. So every monster except what's on that list will be auto-looted.

So in your example, you've added rotworm to a list that specifically blocks it from being auto-looted, and thus are not auto-looting the legion helmet. xD

its because of the "not" on
Code:
if not monsters[getCreatureName(target):lower()] then
right?
the guys talk on topic My Autoloot System for TFS 0.4 (https://otland.net/threads/my-autoloot-system-for-tfs-0-4.264702/#post-2688617)
about not making a loop in every monster using this table index stuff to be performative, so this code check directly the monster
should i remove the not and list every monster i want to add on auto loot list so i can get it light?
 
Top