• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

[Mod] Auto Loot

Add
Code:
if getPlayerVipDays(cid) >= 1 then
under
Code:
if info_OnlyPremium == true and not isPremium(cid) then
Don't forget to end it aswell as send a cancel message
sorry sorry what was that?? Don't forget to end it aswell as send a cancel message
:(
 
sorry sorry what was that?? Don't forget to end it aswell as send a cancel message
:(
Code:
<talkaction words="!autoloot;/autoloot" event="buffer"><![CDATA[
domodlib('Loot_func')
local t = string.explode(string.lower(param), ",")
if getPlayerVipDays(cid) <= 0 then
doPlayerSendCancel(cid, "You must be Vip to use Auto Loot.") return true
elseif info_OnlyPremium == true and not isPremium(cid) then
doPlayerSendCancel(cid, "you must be a premium account.") return true
elseif not t[1] then
ShowItemsTabble(cid) return true
elseif tonumber(t[1]) or tonumber(t[2]) then
doPlayerSendCancel(cid, "enter!autoloot add,name or !autoloot remove,name") return true
elseif isInArray({"add","remove"}, tostring(t[1])) then
local func,check = tostring(t[1]) == "add" and addItemTable or removeItemTable, tostring(t[1]) == "add" and true or false
local item = getItemIdByName(tostring(t[2]), false)
if not item then
doPlayerSendCancel(cid, "This item does not exist.") return true
elseif check == true and isInArray(info.BlockItemsList, item) then
doPlayerSendCancel(cid, "You can not add this item in the list!") return true
elseif isInTable(cid, item) == check then
doPlayerSendCancel(cid, "This Item "..(check == true and "already" or "is not").." in your list.") return true
end
func(cid, item)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,check == true and "you added the item "..t[2].." in the list" or "you removed the item "..t[2].." from the list") return true
end
return true]]></talkaction>
 
Code:
<talkaction words="!autoloot;/autoloot" event="buffer"><![CDATA[
domodlib('Loot_func')
local t = string.explode(string.lower(param), ",")
if getPlayerVipDays(cid) <= 0 then
doPlayerSendCancel(cid, "You must be Vip to use Auto Loot.") return true
elseif info_OnlyPremium == true and not isPremium(cid) then
doPlayerSendCancel(cid, "you must be a premium account.") return true
elseif not t[1] then
ShowItemsTabble(cid) return true
elseif tonumber(t[1]) or tonumber(t[2]) then
doPlayerSendCancel(cid, "enter!autoloot add,name or !autoloot remove,name") return true
elseif isInArray({"add","remove"}, tostring(t[1])) then
local func,check = tostring(t[1]) == "add" and addItemTable or removeItemTable, tostring(t[1]) == "add" and true or false
local item = getItemIdByName(tostring(t[2]), false)
if not item then
doPlayerSendCancel(cid, "This item does not exist.") return true
elseif check == true and isInArray(info.BlockItemsList, item) then
doPlayerSendCancel(cid, "You can not add this item in the list!") return true
elseif isInTable(cid, item) == check then
doPlayerSendCancel(cid, "This Item "..(check == true and "already" or "is not").." in your list.") return true
end
func(cid, item)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,check == true and "you added the item "..t[2].." in the list" or "you removed the item "..t[2].." from the list") return true
end
return true]]></talkaction>
Thanks!! :)
 
im a bit noob at this can anyone tell me whats wrong ?

[07/08/2015 14:50:35] [Error - TalkAction Interface]
[07/08/2015 14:50:35] buffer
[07/08/2015 14:50:35] Description:
[07/08/2015 14:50:35] data/lib/050-function.lua:222: attempt to index a boolean value
 
When I using this i have this:
Code:
[04/01/2016 18:20:54] [Error - TalkAction Interface]
[04/01/2016 18:20:54] buffer
[04/01/2016 18:20:54] Description:
[04/01/2016 18:20:54] data/lib/050-function.lua:231: attempt to index a boolean value

[04/01/2016 18:21:00] [Error - TalkAction Interface]
[04/01/2016 18:21:00] buffer
[04/01/2016 18:21:00] Description:
[04/01/2016 18:21:00] data/lib/050-function.lua:231: attempt to index a boolean value

[04/01/2016 18:21:09] [Error - TalkAction Interface]
[04/01/2016 18:21:09] buffer
[04/01/2016 18:21:09] Description:
[04/01/2016 18:21:09] data/lib/050-function.lua:231: attempt to index a boolean value

[04/01/2016 18:21:11] [Error - TalkAction Interface]
[04/01/2016 18:21:11] buffer
[04/01/2016 18:21:11] Description:
[04/01/2016 18:21:11] data/lib/050-function.lua:231: attempt to index a boolean value

[04/01/2016 18:21:12] [Error - TalkAction Interface]
[04/01/2016 18:21:12] buffer
[04/01/2016 18:21:12] Description:
[04/01/2016 18:21:12] data/lib/050-function.lua:231: attempt to index a boolean value

[04/01/2016 18:21:13] [Error - TalkAction Interface]
[04/01/2016 18:21:13] buffer
[04/01/2016 18:21:13] Description:
[04/01/2016 18:21:13] data/lib/050-function.lua:231: attempt to index a boolean value
[04/01/2016 18:21:25] Siwy has logged out.
[04/01/2016 18:21:26] Siwy has logged in.

[04/01/2016 18:21:27] [Error - TalkAction Interface]
[04/01/2016 18:21:27] buffer
[04/01/2016 18:21:27] Description:
[04/01/2016 18:21:27] data/lib/050-function.lua:231: attempt to index a boolean value

[04/01/2016 18:21:28] [Error - TalkAction Interface]
[04/01/2016 18:21:28] buffer
[04/01/2016 18:21:28] Description:
[04/01/2016 18:21:28] data/lib/050-function.lua:231: attempt to index a boolean value

[04/01/2016 18:21:44] [Error - TalkAction Interface]
[04/01/2016 18:21:44] buffer
[04/01/2016 18:21:44] Description:
[04/01/2016 18:21:44] data/lib/050-function.lua:231: attempt to index a boolean value

[04/01/2016 18:21:51] [Error - TalkAction Interface]
[04/01/2016 18:21:51] buffer
[04/01/2016 18:21:51] Description:
[04/01/2016 18:21:51] data/lib/050-function.lua:231: attempt to index a boolean value
 
if you recive this item does not exist. use this
Code:
function ExistItemByName(name) -- by vodka
    local item = getItemIdByName(name, false)
    if not item then
         
        return false
    else
    return true
    end
end 
[code]
and btw stacking isn't working correctly when you have 5 same items and you make it count ex. 1 then every item get same count from drop ex. you have 5 mana potions in 5 stacks you kill monster which drops mana potion and you get mana potion dropx5

for stacking problem u can use
Code:
function doPlayerAddItemStacking(cid, itemid, quant) -- by mkalo

            return doPlayerAddItem(cid, itemid, quant)

end
btw. those issues are on my TFS 0.4 idk if this apply to others distro
 
Last edited by a moderator:
> I have added a correction to the code.
Code:
<?xml version="1.0" encoding="ISO-8859-1"?> 
<mod name="Loot System" version="1.0" author="Vodkart And Mkalo, Sevu Entertainment" contact="none.com" enabled="yes"> 
<config name="Loot_func"><![CDATA[
info = {
    BlockMonsters = {},
    BlockItemsList = {2123,2515}
}
function isContainerByItemId(itemid) -- By SevuEntertainment
    return getItemInfo(itemid).group == 2 and true or false
end
function setPlayerStorageTable(cid, storage, tab)
    local tabstr = "&"
    for i,x in pairs(tab) do
            tabstr = tabstr .. i .. "," .. x .. ";"
    end
    setPlayerStorageValue(cid, storage, tabstr:sub(1, #tabstr-1))
end
function getPlayerStorageTable(cid, storage)
    local tabstr = getPlayerStorageValue(cid, storage)
    local tab = {}
    if type(tabstr) ~= "string" then
            return {}
    end
    if tabstr:sub(1,1) ~= "&" then
            return {}
    end
    local tabstr = tabstr:sub(2, #tabstr)
    local a = string.explode(tabstr, ";")
    for i,x in pairs(a) do
            local b = string.explode(x, ",")
            tab[tonumber(b[1]) or b[1]] = tonumber(b[2]) or b[2]
    end
    return tab
end
function isInTable(cid, item)
         for _,i in pairs(getPlayerStorageTable(cid, 27000))do
             if tonumber(i) == tonumber(item) then
                return true
             end
         end
return false
end
function addItemTable(cid, item)
         local x = {}
               for i = 1,#getPlayerStorageTable(cid, 27000) do
                   table.insert(x,getPlayerStorageTable(cid, 27000)[i])
               end
               if x ~= 0 then
                  table.insert(x,tonumber(item))
                  setPlayerStorageTable(cid, 27000, x)
               else
                   setPlayerStorageTable(cid, 27000, {item})
               end
end
function removeItemTable(cid, item)
         local x = {}
               for i = 1,#getPlayerStorageTable(cid, 27000) do
                   table.insert(x,getPlayerStorageTable(cid, 27000)[i])
               end
               for i,v in ipairs(x) do
                   if tonumber(v) == tonumber(item) then
                   table.remove(x,i)
               end
               end
         return setPlayerStorageTable(cid, 27000, x)
end
function ShowItemsTabble(cid)
    local str,n = "-- My Loot List --\n\n",0
    for i = 1,#getPlayerStorageTable(cid, 27000) do
        n = n + 1
        str = str..""..n.." - "..getItemNameById(getPlayerStorageTable(cid, 27000)[i]).."\n"
    end
    str = str.."\n\nADD: /autoloot add,ITEM_NAME\nREMOVE: /autoloot remove,ITEM_NAME"
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str)
    return doShowTextDialog(cid, 2529, str)
end
function getContainerItems(containeruid)
    local items = {}
    local containers = {}
    if type(getContainerSize(containeruid)) ~= "number" then
            return false
    end
    for slot = 0, getContainerSize(containeruid)-1 do
            local item = getContainerItem(containeruid, slot)
            if item.itemid == 0 then
                    break
            end
            if isContainer(item.uid) then
                    table.insert(containers, item.uid)
            end
            table.insert(items, item)
    end
    if #containers > 0 then
            for i,x in ipairs(getContainerItems(containers[1])) do
                    table.insert(items, x)
            end
            table.remove(containers, 1)
    end 
    return items
end
function getItemsInContainerById(container, itemid) -- Function By Kydrai
            local items = {}
            if isContainer(container) and getContainerSize(container) > 0 then
                            for slot=0, (getContainerSize(container)-1) do
                                            local item = getContainerItem(container, slot)
                                            if isContainer(item.uid) then
                                                            local itemsbag = getItemsInContainerById(item.uid, itemid)
                                                            for i=0, #itemsbag do
                                                                            table.insert(items, itemsbag[i])
                                                            end
                                            else
                                                            if itemid == item.itemid then
                                                                            table.insert(items, item.uid)
                                                            end
                                            end
                            end
            end
            return items
end
function doPlayerAddItemStacking(cid, itemid, quant) -- by mkalo
    local item = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid)
    local piles = 0
    if #item > 0 then
            for i,x in pairs(item) do
                    if getThing(x).type < 100 then
                            local it = getThing(x)
                            doTransformItem(it.uid, itemid, it.type+quant)
                            if it.type+quant > 100 then
                                    doPlayerAddItem(cid, itemid, it.type+quant-100)
                            end
                    else
                           piles = piles+1
                    end
            end
    else
            return doPlayerAddItem(cid, itemid, quant)
    end
    if piles == #item then
            doPlayerAddItem(cid, itemid, quant)
    end
end
    function corpseRetireItems(cid, pos)
        local check = false
        for i = 0, 255 do
        pos.stackpos = i
        tile = getTileThingByPos(pos)
        if tile.uid > 0 and isCorpse(tile.uid) then
            check = true break
        end
    end
    if check == true then
        local items = getContainerItems(tile.uid)
        if items then
            for i, x in pairs(items) do
                if isInArray(getPlayerStorageTable(cid, 27000), tonumber(x.itemid)) then
                    if isItemStackable(x.itemid) then
                        doPlayerAddItemStacking(cid, x.itemid, x.type)
                    else
                        doPlayerAddItem(cid, x.itemid)
                    end
                    doRemoveItem(x.uid)
                end
            end
        end
    end
end
]]></config>
<event type="login" name="LootLogin" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "MonsterAttack")
return true
end]]></event>
<event type="death" name="LootEventDeath" event="script"><![CDATA[
domodlib('Loot_func')
    function onDeath(cid, corpse, deathList)
    local killer,pos = deathList[1],getCreaturePosition(cid)
    local lookCorpse = getMonsterInfo(getCreatureName(cid)).lookCorpse
    if isContainerByItemId(lookCorpse) then
        addEvent(corpseRetireItems,1,killer,pos)
    end
return true
end]]></event>
<event type="combat" name="MonsterAttack" event="script"><![CDATA[
domodlib('Loot_func')
        if isPlayer(cid) and isMonster(target) and not isInArray(info.BlockMonsters,string.lower(getCreatureName(target))) then
            registerCreatureEvent(target, "LootEventDeath")
                        end
return true]]></event>
<talkaction words="!autoloot;/autoloot" event="buffer"><![CDATA[
domodlib('Loot_func')
local t = string.explode(string.lower(param), ",")
if not t[1] then
ShowItemsTabble(cid) return true
elseif tonumber(t[1]) or tonumber(t[2]) then
doPlayerSendCancel(cid, "enter!autoloot add,name or !autoloot remove,name") return true
elseif isInArray({"add","remove"}, tostring(t[1])) then
local func,check = tostring(t[1]) == "add" and addItemTable or removeItemTable, tostring(t[1]) == "add" and true or false
local item = getItemIdByName(tostring(t[2]), false)
if not item then
doPlayerSendCancel(cid, "This item does not exist.") return true
elseif check == true and isInArray(info.BlockItemsList, item) then
doPlayerSendCancel(cid, "You can not add this item in the list!") return true
elseif isInTable(cid, item) == check then
doPlayerSendCancel(cid, "This Item "..(check == true and "already" or "is not").." in your list.") return true
end
func(cid, item)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,check == true and "you added the item "..t[2].." in the list" or "you removed the item "..t[2].." from the list") return true
end
return true]]></talkaction>
</mod>

> To avoid this error
Code:
[1:10:27.952] [Error - CreatureScript Interface]
[1:10:27.952] In a timer event called from:
[1:10:27.952] domodlib('Loot_func')
[1:10:27.952] function onDeath(cid, corpse, deathList)
[1:10:27.952] local killer,pos = deathList[1],getCreaturePosition(cid)
[1:10:27.952] addEvent(corpseRetireItems,1,killer,pos)
[1:10:27.952] return true
[1:10:27.952] end:eek:nDeath
[1:10:27.952] Description:
[1:10:27.952] (luaGetContainerSize) Container not found

[1:10:27.952] [Error - CreatureScript Interface]
[1:10:27.952] In a timer event called from:
[1:10:27.952] domodlib('Loot_func')
[1:10:27.952] function onDeath(cid, corpse, deathList)
[1:10:27.952] local killer,pos = deathList[1],getCreaturePosition(cid)
[1:10:27.952] addEvent(corpseRetireItems,1,killer,pos)
[1:10:27.952] return true
[1:10:27.952] end:eek:nDeath
[1:10:27.952] Description:
[1:10:27.952] [string "info = {..."]:153: bad argument #1 to 'pairs' (table expected, got boolean)
[1:10:27.952] stack traceback:
[1:10:27.952] [C]: in function 'pairs'
[1:10:27.952] [string "info = {..."]:153: in function <[string "info = {..."]:142>
 
> I have added a correction to the code.
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Loot System" version="1.0" author="Vodkart And Mkalo, Sevu Entertainment" contact="none.com" enabled="yes">
<config name="Loot_func"><![CDATA[
info = {
    BlockMonsters = {},
    BlockItemsList = {2123,2515}
}
function isContainerByItemId(itemid) -- By SevuEntertainment
    return getItemInfo(itemid).group == 2 and true or false
end
function setPlayerStorageTable(cid, storage, tab)
    local tabstr = "&"
    for i,x in pairs(tab) do
            tabstr = tabstr .. i .. "," .. x .. ";"
    end
    setPlayerStorageValue(cid, storage, tabstr:sub(1, #tabstr-1))
end
function getPlayerStorageTable(cid, storage)
    local tabstr = getPlayerStorageValue(cid, storage)
    local tab = {}
    if type(tabstr) ~= "string" then
            return {}
    end
    if tabstr:sub(1,1) ~= "&" then
            return {}
    end
    local tabstr = tabstr:sub(2, #tabstr)
    local a = string.explode(tabstr, ";")
    for i,x in pairs(a) do
            local b = string.explode(x, ",")
            tab[tonumber(b[1]) or b[1]] = tonumber(b[2]) or b[2]
    end
    return tab
end
function isInTable(cid, item)
         for _,i in pairs(getPlayerStorageTable(cid, 27000))do
             if tonumber(i) == tonumber(item) then
                return true
             end
         end
return false
end
function addItemTable(cid, item)
         local x = {}
               for i = 1,#getPlayerStorageTable(cid, 27000) do
                   table.insert(x,getPlayerStorageTable(cid, 27000)[i])
               end
               if x ~= 0 then
                  table.insert(x,tonumber(item))
                  setPlayerStorageTable(cid, 27000, x)
               else
                   setPlayerStorageTable(cid, 27000, {item})
               end
end
function removeItemTable(cid, item)
         local x = {}
               for i = 1,#getPlayerStorageTable(cid, 27000) do
                   table.insert(x,getPlayerStorageTable(cid, 27000)[i])
               end
               for i,v in ipairs(x) do
                   if tonumber(v) == tonumber(item) then
                   table.remove(x,i)
               end
               end
         return setPlayerStorageTable(cid, 27000, x)
end
function ShowItemsTabble(cid)
    local str,n = "-- My Loot List --\n\n",0
    for i = 1,#getPlayerStorageTable(cid, 27000) do
        n = n + 1
        str = str..""..n.." - "..getItemNameById(getPlayerStorageTable(cid, 27000)[i]).."\n"
    end
    str = str.."\n\nADD: /autoloot add,ITEM_NAME\nREMOVE: /autoloot remove,ITEM_NAME"
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str)
    return doShowTextDialog(cid, 2529, str)
end
function getContainerItems(containeruid)
    local items = {}
    local containers = {}
    if type(getContainerSize(containeruid)) ~= "number" then
            return false
    end
    for slot = 0, getContainerSize(containeruid)-1 do
            local item = getContainerItem(containeruid, slot)
            if item.itemid == 0 then
                    break
            end
            if isContainer(item.uid) then
                    table.insert(containers, item.uid)
            end
            table.insert(items, item)
    end
    if #containers > 0 then
            for i,x in ipairs(getContainerItems(containers[1])) do
                    table.insert(items, x)
            end
            table.remove(containers, 1)
    end
    return items
end
function getItemsInContainerById(container, itemid) -- Function By Kydrai
            local items = {}
            if isContainer(container) and getContainerSize(container) > 0 then
                            for slot=0, (getContainerSize(container)-1) do
                                            local item = getContainerItem(container, slot)
                                            if isContainer(item.uid) then
                                                            local itemsbag = getItemsInContainerById(item.uid, itemid)
                                                            for i=0, #itemsbag do
                                                                            table.insert(items, itemsbag[i])
                                                            end
                                            else
                                                            if itemid == item.itemid then
                                                                            table.insert(items, item.uid)
                                                            end
                                            end
                            end
            end
            return items
end
function doPlayerAddItemStacking(cid, itemid, quant) -- by mkalo
    local item = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid)
    local piles = 0
    if #item > 0 then
            for i,x in pairs(item) do
                    if getThing(x).type < 100 then
                            local it = getThing(x)
                            doTransformItem(it.uid, itemid, it.type+quant)
                            if it.type+quant > 100 then
                                    doPlayerAddItem(cid, itemid, it.type+quant-100)
                            end
                    else
                           piles = piles+1
                    end
            end
    else
            return doPlayerAddItem(cid, itemid, quant)
    end
    if piles == #item then
            doPlayerAddItem(cid, itemid, quant)
    end
end
    function corpseRetireItems(cid, pos)
        local check = false
        for i = 0, 255 do
        pos.stackpos = i
        tile = getTileThingByPos(pos)
        if tile.uid > 0 and isCorpse(tile.uid) then
            check = true break
        end
    end
    if check == true then
        local items = getContainerItems(tile.uid)
        if items then
            for i, x in pairs(items) do
                if isInArray(getPlayerStorageTable(cid, 27000), tonumber(x.itemid)) then
                    if isItemStackable(x.itemid) then
                        doPlayerAddItemStacking(cid, x.itemid, x.type)
                    else
                        doPlayerAddItem(cid, x.itemid)
                    end
                    doRemoveItem(x.uid)
                end
            end
        end
    end
end
]]></config>
<event type="login" name="LootLogin" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "MonsterAttack")
return true
end]]></event>
<event type="death" name="LootEventDeath" event="script"><![CDATA[
domodlib('Loot_func')
    function onDeath(cid, corpse, deathList)
    local killer,pos = deathList[1],getCreaturePosition(cid)
    local lookCorpse = getMonsterInfo(getCreatureName(cid)).lookCorpse
    if isContainerByItemId(lookCorpse) then
        addEvent(corpseRetireItems,1,killer,pos)
    end
return true
end]]></event>
<event type="combat" name="MonsterAttack" event="script"><![CDATA[
domodlib('Loot_func')
        if isPlayer(cid) and isMonster(target) and not isInArray(info.BlockMonsters,string.lower(getCreatureName(target))) then
            registerCreatureEvent(target, "LootEventDeath")
                        end
return true]]></event>
<talkaction words="!autoloot;/autoloot" event="buffer"><![CDATA[
domodlib('Loot_func')
local t = string.explode(string.lower(param), ",")
if not t[1] then
ShowItemsTabble(cid) return true
elseif tonumber(t[1]) or tonumber(t[2]) then
doPlayerSendCancel(cid, "enter!autoloot add,name or !autoloot remove,name") return true
elseif isInArray({"add","remove"}, tostring(t[1])) then
local func,check = tostring(t[1]) == "add" and addItemTable or removeItemTable, tostring(t[1]) == "add" and true or false
local item = getItemIdByName(tostring(t[2]), false)
if not item then
doPlayerSendCancel(cid, "This item does not exist.") return true
elseif check == true and isInArray(info.BlockItemsList, item) then
doPlayerSendCancel(cid, "You can not add this item in the list!") return true
elseif isInTable(cid, item) == check then
doPlayerSendCancel(cid, "This Item "..(check == true and "already" or "is not").." in your list.") return true
end
func(cid, item)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,check == true and "you added the item "..t[2].." in the list" or "you removed the item "..t[2].." from the list") return true
end
return true]]></talkaction>
</mod>

> To avoid this error
Code:
[1:10:27.952] [Error - CreatureScript Interface]
[1:10:27.952] In a timer event called from:
[1:10:27.952] domodlib('Loot_func')
[1:10:27.952] function onDeath(cid, corpse, deathList)
[1:10:27.952] local killer,pos = deathList[1],getCreaturePosition(cid)
[1:10:27.952] addEvent(corpseRetireItems,1,killer,pos)
[1:10:27.952] return true
[1:10:27.952] end:eek:nDeath
[1:10:27.952] Description:
[1:10:27.952] (luaGetContainerSize) Container not found

[1:10:27.952] [Error - CreatureScript Interface]
[1:10:27.952] In a timer event called from:
[1:10:27.952] domodlib('Loot_func')
[1:10:27.952] function onDeath(cid, corpse, deathList)
[1:10:27.952] local killer,pos = deathList[1],getCreaturePosition(cid)
[1:10:27.952] addEvent(corpseRetireItems,1,killer,pos)
[1:10:27.952] return true
[1:10:27.952] end:eek:nDeath
[1:10:27.952] Description:
[1:10:27.952] [string "info = {..."]:153: bad argument #1 to 'pairs' (table expected, got boolean)
[1:10:27.952] stack traceback:
[1:10:27.952] [C]: in function 'pairs'
[1:10:27.952] [string "info = {..."]:153: in function <[string "info = {..."]:142>



here fix


LUA:
<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Loot System" version="1.0" author="Vodkart And Mkalo, Sevu Entertainment" contact="none.com" enabled="yes">
<config name="Loot_func"><![CDATA[
info = {
    BlockMonsters = {},
    BlockItemsList = {2123,2515}
}
function isContainerByItemId(itemid) -- By SevuEntertainment
    return getItemInfo(itemid).group == 2 and true or false
end
function setPlayerStorageTable(cid, storage, tab)
    local tabstr = "&"
    for i,x in pairs(tab) do
            tabstr = tabstr .. i .. "," .. x .. ";"
    end
    setPlayerStorageValue(cid, storage, tabstr:sub(1, #tabstr-1))
end
function getPlayerStorageTable(cid, storage)
    local tabstr = getPlayerStorageValue(cid, storage)
    local tab = {}
    if type(tabstr) ~= "string" then
            return {}
    end
    if tabstr:sub(1,1) ~= "&" then
            return {}
    end
    local tabstr = tabstr:sub(2, #tabstr)
    local a = string.explode(tabstr, ";")
    for i,x in pairs(a) do
            local b = string.explode(x, ",")
            tab[tonumber(b[1]) or b[1]] = tonumber(b[2]) or b[2]
    end
    return tab
end
function isInTable(cid, item)
         for _,i in pairs(getPlayerStorageTable(cid, 27000))do
             if tonumber(i) == tonumber(item) then
                return true
             end
         end
return false
end
function addItemTable(cid, item)
         local x = {}
               for i = 1,#getPlayerStorageTable(cid, 27000) do
                   table.insert(x,getPlayerStorageTable(cid, 27000)[i])
               end
               if x ~= 0 then
                  table.insert(x,tonumber(item))
                  setPlayerStorageTable(cid, 27000, x)
               else
                   setPlayerStorageTable(cid, 27000, {item})
               end
end
function removeItemTable(cid, item)
         local x = {}
               for i = 1,#getPlayerStorageTable(cid, 27000) do
                   table.insert(x,getPlayerStorageTable(cid, 27000)[i])
               end
               for i,v in ipairs(x) do
                   if tonumber(v) == tonumber(item) then
                   table.remove(x,i)
               end
               end
         return setPlayerStorageTable(cid, 27000, x)
end
function ShowItemsTabble(cid)
    local str,n = "-- My Loot List --\n\n",0
    for i = 1,#getPlayerStorageTable(cid, 27000) do
        n = n + 1
        str = str..""..n.." - "..getItemNameById(getPlayerStorageTable(cid, 27000)[i]).."\n"
    end
    str = str.."\n\nADD: /autoloot add,ITEM_NAME\nREMOVE: /autoloot remove,ITEM_NAME"
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str)
    return doShowTextDialog(cid, 2529, str)
end
function getContainerItems(containeruid)
    local items = {}
    local containers = {}
    if type(getContainerSize(containeruid)) ~= "number" then
            return false
    end
    for slot = 0, getContainerSize(containeruid)-1 do
            local item = getContainerItem(containeruid, slot)
            if item.itemid == 0 then
                    break
            end
            if isContainer(item.uid) then
                    table.insert(containers, item.uid)
            end
            table.insert(items, item)
    end
    if #containers > 0 then
            for i,x in ipairs(getContainerItems(containers[1])) do
                    table.insert(items, x)
            end
            table.remove(containers, 1)
    end
    return items
end
function getItemsInContainerById(container, itemid) -- Function By Kydrai
            local items = {}
            if isContainer(container) and getContainerSize(container) > 0 then
                            for slot=0, (getContainerSize(container)-1) do
                                            local item = getContainerItem(container, slot)
                                            if isContainer(item.uid) then
                                                            local itemsbag = getItemsInContainerById(item.uid, itemid)
                                                            for i=0, #itemsbag do
                                                                            table.insert(items, itemsbag[i])
                                                            end
                                            else
                                                            if itemid == item.itemid then
                                                                            table.insert(items, item.uid)
                                                            end
                                            end
                            end
            end
            return items
end
function doPlayerAddItemStacking(cid, itemid, quant) -- by mkalo
    local item = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid)
    local piles = 0
    if #item > 0 then
            for i,x in pairs(item) do
                    if getThing(x).type < 100 then
                            local it = getThing(x)
                            doTransformItem(it.uid, itemid, it.type+quant)
                            if it.type+quant > 100 then
                                    doPlayerAddItem(cid, itemid, it.type+quant-100)
                            end
                    else
                           piles = piles+1
                    end
            end
    else
            return doPlayerAddItem(cid, itemid, quant)
    end
    if piles == #item then
            doPlayerAddItem(cid, itemid, quant)
    end
end
    function corpseRetireItems(cid, pos)
        local check = false
        for i = 0, 255 do
        pos.stackpos = i
        tile = getTileThingByPos(pos)
        if tile.uid > 0 and isCorpse(tile.uid) then
            check = true break
        end
    end
    if check == true then
        local items = getContainerItems(tile.uid)
        if items then
            for i, x in pairs(items) do
                if isInArray(getPlayerStorageTable(cid, 27000), tonumber(x.itemid)) then
                    if isItemStackable(x.itemid) then
                        doPlayerAddItemStacking(cid, x.itemid, x.type)
                    else
                        doPlayerAddItem(cid, x.itemid)
                    end
                    doRemoveItem(x.uid)
                end
            end
        end
    end
end
]]></config>
<event type="login" name="LootLogin" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "MonsterAttack")
return true
end]]></event>
<event type="death" name="LootEventDeath" event="script"><![CDATA[
domodlib('Loot_func')
    function onDeath(cid, corpse, deathList)
    local killer,pos = deathList[1],getCreaturePosition(cid)
    local lookCorpse = getMonsterInfo(getCreatureName(cid)).lookCorpse
    if isContainerByItemId(lookCorpse) then
        addEvent(corpseRetireItems,1,killer,pos)
    end
return true
end]]></event>
<event type="combat" name="MonsterAttack" event="script"><![CDATA[
domodlib('Loot_func')
        if isPlayer(cid) and isMonster(target) and not isInArray(info.BlockMonsters,string.lower(getCreatureName(target))) then
            registerCreatureEvent(target, "LootEventDeath")
                        end
return true]]></event>
<talkaction words="!autoloot;/autoloot" event="buffer"><![CDATA[
domodlib('Loot_func')
local t = string.explode(string.lower(param), ",")
if not t[1] then
ShowItemsTabble(cid) return true
elseif tonumber(t[1]) or tonumber(t[2]) then
doPlayerSendCancel(cid, "enter!autoloot add,name or !autoloot remove,name") return true
elseif isInArray({"add","remove"}, tostring(t[1])) then
local func,check = tostring(t[1]) == "add" and addItemTable or removeItemTable, tostring(t[1]) == "add" and true or false
local item = getItemIdByName(tostring(t[2]), false)
if not item then
doPlayerSendCancel(cid, "This item does not exist.") return true
elseif check == true and isInArray(info.BlockItemsList, item) then
doPlayerSendCancel(cid, "You can not add this item in the list!") return true
elseif isInTable(cid, item) == check then
doPlayerSendCancel(cid, "This Item "..(check == true and "already" or "is not").." in your list.") return true
end
func(cid, item)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,check == true and "you added the item "..t[2].." in the list" or "you removed the item "..t[2].." from the list") return true
end
return true]]></talkaction>
</mod>
 
Hello
I have a request, I downloaded a datapack version 11.49 and what is my surprise, in the modules folder there is a file called autoloot lua, but, it does not do anything when I put it autoloot, you could explain to me what I have to do to make it work, if you ask, there is no autoloot in talkactions.
Thank you
 
Hello
I have a request, I downloaded a datapack version 11.49 and what is my surprise, in the modules folder there is a file called autoloot lua, but, it does not do anything when I put it autoloot, you could explain to me what I have to do to make it work, if you ask, there is no autoloot in talkactions.
Thank you
Hello lopez, where did you download that? Can we check it so we see what it does?
 
Hello
I have a request, I downloaded a datapack version 11.49 and what is my surprise, in the modules folder there is a file called autoloot lua, but, it does not do anything when I put it autoloot, you could explain to me what I have to do to make it work, if you ask, there is no autoloot in talkactions.
Thank you

Hi, sorry for my ignorance, but where do you find mod files in versions 1.2+?
 
Back
Top