Postado Abril 2, 2014 11 anos Olá galera do TibiaKing. Alguém com experiência em scripting saberia me dizer o porque desse erro no meu script de autoloot? [02/04/2014 15:00:53] data/lib/050-function.lua:239: attempt to index a boolean value [02/04/2014 15:00:53] stack traceback: [02/04/2014 15:00:53] data/lib/050-function.lua:239: in function 'getItemName' [02/04/2014 15:00:53] data/creaturescripts/scripts/aloot.lua:57: in function <data/creaturescripts/scripts/aloot.lua:8> Segue o script: function onLogin(cid) registerCreatureEvent(cid, "aloot_kill") return true end local stor = 7575 function autoloot(cid, target, pos) local function doStack(cid, itemid, new) local count = getPlayerItemCount(cid, itemid) if (count > 100) then count = count - math.floor(count / 100) * 100 end local newCount = count + new if (count ~= 0) then local find = getPlayerItemById(cid, true, itemid, count).uid if (find > 0) then doRemoveItem(find) else newCount = new end end local item = doCreateItemEx(itemid, newCount) doPlayerAddItemEx(cid, item, true) end local function scanContainer(cid, uid, list) for k = (getContainerSize(uid) - 1), 0, -1 do local tmp = getContainerItem(uid, k) if (isInArray(list, tmp.itemid)) then if isItemStackable(tmp.itemid) and (getPlayerItemCount(cid, tmp.itemid) > 0) then doStack(cid, tmp.itemid, tmp.type) else local item = doCreateItemEx(tmp.itemid, tmp.type) doPlayerAddItemEx(cid, item, true) end doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Looted ' .. tmp.type .. ' ' .. getItemNameById(tmp.itemid) .. '.') doRemoveItem(tmp.uid) elseif isContainer(tmp.uid) then scanContainer(cid, tmp.uid, list) end end end local items = {} for i = getTileInfo(pos).items, 1, -1 do pos.stackpos = i table.insert(items, getThingFromPos(pos)) end if (#items == 0) then return end local corpse = -1 for _, item in ipairs(items) do local name = getItemName(item.uid):lower() if name:find(target:lower()) then corpse = item.uid break end end if (corpse ~= -1) and isContainer(corpse) then scanContainer(cid, corpse, tostring(getPlayerStorageValue(cid, stor)):gsub('_', ''):explode(',')) end end function onKill(cid, target, lastHit) if not isPlayer(target) then local infos = getPlayerStorageValue(cid, stor) if (infos == -1) then return true end local list = tostring(infos):explode(',') if (#list == 0) then return true end addEvent(autoloot, 150, cid, getCreatureName(target), getCreaturePosition(target)) end return true end Esse erro acontece constantemente no distro do meu servidor, alguém poderia me ajudar por favor?
Postado Abril 2, 2014 11 anos Autor Putz, ai você me pegou Rodrigão, eu não faço idéia de aonde vejo isso. Você poderia me auxiliar ?
Postado Abril 2, 2014 11 anos Clica 2x no programa que se abre para abrir seu otserv, ele vai carrega umas coisas, olhe na primeira linha a versão do se TFS. De qualquer forma tente esse script aqui. Na pasta mods crie um arquivo chamado autoLoot e cole isso dentro. mods/autoLoot.xml <?xml version="1.0" encoding="UTF-8"?><mod name="autoLoot" enabled="yes" author="MatheusMkalo" forum="tibiaking.com"><config name="autoLootLib"><![CDATA[ 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 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) end else if itemid == item.itemid then table.insert(items, item.uid) end end end end return items end function doPlayerAddItemStacking(cid, itemid, quant) 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(corpsepos, killer, itemsarray) local corpse = nil for i = 1, 254 do corpsepos.stackpos = i corpse = getThingFromPos(corpsepos) if corpse.uid > 0 and isCorpse(corpse.uid) then break end end local items = getContainerItems(corpse.uid) for i,x in pairs(items) do if isInArray(itemsarray, tonumber(x.itemid)) then if isItemStackable(x.itemid) then doPlayerAddItemStacking(killer, x.itemid, x.type) else doPlayerAddItem(killer, x.itemid) end doRemoveItem(x.uid, x.type) end end end ]]></config><creaturescript type="kill" name="autoLootKill" event="script"><![CDATA[ domodlib("autoLootLib") local loots = getPlayerStorageTable(cid, 6616) if lastHit and #loots >= 1 then addEvent(corpseRetireItems, 100, getCreaturePosition(target), cid, loots) end return true ]]></creaturescript><talkaction words="!autoloot;/autoloot" event="script"><![CDATA[ domodlib("autoLootLib") local t = string.explode(param, ",") for i,x in pairs(t) do if not getItemIdByName(x, false) then return doPlayerSendCancel(cid, "Some of these items don't exist.") end t = getItemIdByName(x, false) end setPlayerStorageTable(cid, 6616, t) doPlayerSendTextMessage(cid, 25, "Auto Looting: " .. param) return true ]]></talkaction><creaturescript type="login" name="autoLootRegister" event="script"><![CDATA[ registerCreatureEvent(cid, "autoLootKill") return true ]]></creaturescript></mod> Exemplo: !autoloot mastermind shield, gold coin Prontinho, se esse script não funcionar passe o seu script completo.
Postado Abril 2, 2014 11 anos Autor Não funcionou Rodrigo, ai está a parte do talkactions do script: local stor, limit = 7575, 5 --storage, limit to add. local allow_container = false --empty! not looted with items, atleast for now. function onSay(cid, words, param) local expl = param:explode(':') local action, rst = expl[1], expl[2] if (action:lower() == 'check') then local infos, list = getPlayerStorageValue(cid, stor), {} if (infos ~= -1) then list = tostring(infos):explode(',') end local txt = 'Autoloot List:\n' if (#list > 0) then for k, id in ipairs(list) do id = id:gsub('_', '') if tonumber(id) then txt = txt .. getItemNameById(tonumber(id)) .. ((k < #list) and '\n' or '') end end else txt = 'Empty' end doPlayerPopupFYI(cid, txt) elseif (action:lower() == 'add') then local infos, list = getPlayerStorageValue(cid, stor), {} if (infos ~= -1) then list = tostring(infos):gsub('_', ''):explode(',') end if (#list >= limit) then return doPlayerSendCancel(cid, 'You already have ' .. limit .. ' autolooting items.') end local item = tonumber(rst) if not item then item = getItemIdByName(rst, false) if not item then return doPlayerSendCancel(cid, 'Esse item nao existe.') end end if not allow_container and isItemContainer(item) then return doPlayerSendCancel(cid, 'this item can not be autolooted.') end local attrs = getItemInfo(item) if not attrs then return doPlayerSendCancel(cid, 'Esse item nao existe.') elseif not attrs.movable or not attrs.pickupable then return doPlayerSendCancel(cid, 'this item can not be autolooted.') end if isInArray(list, item) then return doPlayerSendCancel(cid, 'Ja foi adicionado.') end table.insert(list, tostring(item)) local new = '' for v, id in ipairs(list) do new = new .. '_' .. id:gsub('_' ,'') .. ((v < #list) and ',' or '') end doPlayerSetStorageValue(cid, stor, tostring(new)) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Item >>' .. getItemNameById(item) .. '<< has been added to the autoloot list.') elseif (action:lower() == 'remove') then local infos, list = getPlayerStorageValue(cid, stor), {} if (infos ~= -1) then list = tostring(infos):gsub('_', ''):explode(',') end if (#list == 0) then return doPlayerSendCancel(cid, 'You dont have any item added.') end local item = tonumber(rst) if not item then item = getItemIdByName(rst, false) if not item then return doPlayerSendCancel(cid, 'not valid item.') end end if not isInArray(list, item) then return doPlayerSendCancel(cid, 'This item is not in the list.') end local new = '' for v, id in ipairs(list) do if (tonumber(id) ~= item) then new = new .. '_' .. id:gsub('_' ,'') .. ((v < #list) and ',' or '') end end doPlayerSetStorageValue(cid, stor, tostring(new)) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Item >>' .. getItemNameById(item) .. '<< removed from the autoloot list.') end return true end
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.