Noobrzor
New Member
- Joined
- Jul 25, 2013
- Messages
- 2
- Reaction score
- 1
Greetings
I can't seem to get any AutoLoot mods to work. I've tried several, but I'm going to list two most appealing ones, together with the issue.
Firstly, /i command using the createitem.lua script works fine, and that one utilizes:
E.g. "/i bread" spawns a stack of 100 bread loaves.
1. Auto Loot #1, located here [Mod] Auto Loot (https://otland.net/threads/mod-auto-loot.164289/page-5)
I'm using a modified version from one of the comments, code is as follows:
And everything seems to work properly, except when I try to "!autoloot add,bread", which posts the following error in the console:
2. AutoLoot #2, located here: My Autoloot System for TFS 0.4 (https://otland.net/threads/my-autoloot-system-for-tfs-0-4.264702/)
Of which code is: as posted in the opening post. Can't paste it here due to 25k character limit.
Again, trying to "!autoloot add,bread" results in the following error in the console:
I've tried fixing them up on my own, very limited ability by changing/adding the "local t" and "getItemIdByName(t[1])" but naturally that did not change much.
Could I humbly request some kind assistance with this?
Cheers!
I can't seem to get any AutoLoot mods to work. I've tried several, but I'm going to list two most appealing ones, together with the issue.
Firstly, /i command using the createitem.lua script works fine, and that one utilizes:
E.g. "/i bread" spawns a stack of 100 bread loaves.
Code:
local t = string.explode(param, ",")
id = getItemIdByName(t[1])
1. Auto Loot #1, located here [Mod] Auto Loot (https://otland.net/threads/mod-auto-loot.164289/page-5)
I'm using a modified version from one of the comments, code is as follows:
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>
And everything seems to work properly, except when I try to "!autoloot add,bread", which posts the following error in the console:
Code:
[15:24:43.156] The Forgotten Server, version 0.3.7_SVN (Crying Damson)
[15:24:43.156] Compiled with GNU C++ version 3.4.5 (mingw special) (x86_64: 0)
[15:26:06.058] [Error - TalkAction Interface]
[15:26:06.059] local cid = 268475809
[15:26:06.059] local words = "!autoloot"
[15:26:06.060] local param = "add,bread"
[15:26:06.061] local channel = 65534
[15:26:06.061] domodlib('Loot_func')
[15:26:06.062] local t = string.explode(string.lower(param), ",")
[15:26:06.063] if not t[1] then
[15:26:06.063] ShowItemsTabble(cid) return true
[15:26:06.064] elseif tonumber(t[1]) or tonumber(t[2]) then
[15:26:06.064] doPlayerSendCancel(cid, "enter!autoloot add,name or !autoloot rem
ove,name") return true
[15:26:06.064] elseif isInArray({"add","remove"}, tostring(t[1])) then
[15:26:06.065] local func,check = tostring(t[1]) == "add" and addItemTable or re
moveItemTable, tostring(t[1]) == "add" and true or false
[15:26:06.065] local item = getItemIdByName(tostring(t[2]), false)
[15:26:06.066] if not item then
[15:26:06.066] doPlayerSendCancel(cid, "This item does not exist.") return true
[15:26:06.067] elseif check == true and isInArray(info.BlockItemsList, item) the
n
[15:26:06.067] doPlayerSendCancel(cid, "You can not add this item in the list!")
return true
[15:26:06.068] elseif isInTable(cid, item) == check then
[15:26:06.068] doPlayerSendCancel(cid, "This Item "..(check == true and "already
" or "is not").." in your list.") return true
[15:26:06.069] end
[15:26:06.069] func(cid, item)
[15:26:06.070] 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
[15:26:06.070] end
[15:26:06.071] return true
[15:26:06.072] Description:
[15:26:06.072] (luaGetItemIdByName) Item not found
2. AutoLoot #2, located here: My Autoloot System for TFS 0.4 (https://otland.net/threads/my-autoloot-system-for-tfs-0-4.264702/)
Of which code is: as posted in the opening post. Can't paste it here due to 25k character limit.
Again, trying to "!autoloot add,bread" results in the following error in the console:
Code:
[15:7:47.820] The Forgotten Server, version 0.3.7_SVN (Crying Damson)
[15:7:47.820] Compiled with GNU C++ version 3.4.5 (mingw special) (x86_64: 0)
[15:9:52.097] [Error - TalkAction Interface]
[15:9:52.097] local cid = 268475809
[15:9:52.097] local words = "!autoloot"
[15:9:52.098] local param = ""
[15:9:52.098] local channel = 65534
[15:9:52.099] domodlib("AutolootRevolutionBT")
[15:9:52.100] local split = string.explode(param, ",") or {}
[15:9:52.100] local action = tostring(split[1]):lower()
[15:9:52.100] local name = tostring(split[2])
[15:9:52.101] local itemid = getItemIdByName(name, false)
[15:9:52.101] local it = getItemInfo(itemid and itemid or 0)
[15:9:52.101] local position = getThingPosition(cid)
[15:9:52.101] if action == "add" then
[15:9:52.102] if not it then
[15:9:52.102] doPlayerSendCancel(cid, string.format("This item %s does n
ot exist.", name))
[15:9:52.103] else
[15:9:52.103] local maxItems = getPlayerPremiumEnabled(cid) and autoloot
Config.premiumSlots or autolootConfig.freeSlots
[15:9:52.104] local autolootItems = getPlayerAutolootItems(cid)
[15:9:52.104] if #autolootItems > maxItems then
[15:9:52.104] for index = autolootConfig.premiumSlots, autolootConfi
g.freeSlots, -1 do
[15:9:52.105] table.remove(autolootItems, index)
[15:9:52.105] end
[15:9:52.105] setPlayerAutolootItems(cid, autolootItems)
[15:9:52.106] doPlayerSendCancel(cid, "Your list of items overflowed
, you should check your list.")
[15:9:52.106] elseif #autolootItems == maxItems then
[15:9:52.106] doPlayerSendCancel(cid, string.format("Your maximum li
mit is %u items, you must eliminate one to add another.", maxItems))
[15:9:52.107] elseif addPlayerAutolootItem(cid, itemid) then
[15:9:52.107] doPlayerSendCancel(cid, string.format("You added the i
tem %s in the list.", name))
[15:9:52.108] else
[15:9:52.108] doSendMagicEffect(position, CONST_ME_POFF, cid)
[15:9:52.108] doPlayerSendCancel(cid, string.format("This item %s al
ready in the list.", name))
[15:9:52.109] end
[15:9:52.109] end
[15:9:52.109] elseif action == "remove" then
[15:9:52.110] if not it then
[15:9:52.110] doPlayerSendCancel(cid, string.format("This item %s does n
ot exist.", name))
[15:9:52.110] else
[15:9:52.111] if removePlayerAutolootItem(cid, itemid) then
[15:9:52.111] doPlayerSendCancel(cid, string.format("You removed the
item %s from the list.", name))
[15:9:52.111] else
[15:9:52.112] doPlayerSendCancel(cid, string.format("This item %s is
not in the list.", name))
[15:9:52.112] end
[15:9:52.112] end
[15:9:52.113] elseif action == "help" then
[15:9:52.113] showPlayerAutolootHelp(cid)
[15:9:52.114] elseif action == "clear" then
[15:9:52.114] setPlayerAutolootItems(cid)
[15:9:52.114] doPlayerSendCancel(cid, "The list of items is now empty.")
[15:9:52.115] else
[15:9:52.115] showPlayerAutoloot(cid)
[15:9:52.115] end
[15:9:52.116] return true
[15:9:52.116] Description:
[15:9:52.116] (luaGetItemIdByName) Item not found
I've tried fixing them up on my own, very limited ability by changing/adding the "local t" and "getItemIdByName(t[1])" but naturally that did not change much.
Could I humbly request some kind assistance with this?
Cheers!