removido
Concertar este script - Autoloot
Por markim1986, 31 de dez. de 2012 em Scripts
Editado Janeiro 1 por brun123
info
Grupo: Artesão
Registrado: 26/04/09
Posts: 120
Reputação: +2

Tente assim:
<?xml version="1.0" encoding="UTF-8"?> <mod name="autoLoot" enabled="yes" author="MatheusMkalo" forum="XTibia.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[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) 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, corpseid, killer, itemsarray) local corpse = getTileItemById(corpsepos, corpseid).uid if corpse <= 1 then return 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, math.max(x.type, 1)) else doPlayerAddItem(killer, x.itemid) end doRemoveItem(x.uid, math.max(x.type, 1)) 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 local corpseId = getMonsterInfo(getCreatureName(target)).lookCorpse addEvent(corpseRetireItems, 5, getCreaturePosition(target), corpseId, cid, loots) end return true ]]></creaturescript> <talkaction words="!autoloot;/autoloot" event="script"><![CDATA[ domodlib("autoLootLib") local t = string.explode(param, ",") local size = 0 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[i] = getItemIdByName(x, false) size = size + (t[i]:len()) end if size > 280 then return doPlayerSendCancel(cid, "There are too many items in that list!") 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>
Da esse erro quando eu tento adicionar algum item:
[10/01/2013 05:33:01] [Error - TalkAction Interface] [10/01/2013 05:33:01] buffer:onSay [10/01/2013 05:33:01] Description: [10/01/2013 05:33:01] [string "loadBuffer"]:10: attempt to index field '?' (a number value) [10/01/2013 05:33:01] stack traceback: [10/01/2013 05:33:01] [string "loadBuffer"]:10: in function <[string "loadBuffer"]:1>
Cara, agradeço muito desde jA!
removido
Editado Janeiro 1 por brun123
info
Grupo: Artesão
Registrado: 26/04/09
Posts: 120
Reputação: +2

Opa desculpa, tinha cometido um erro na parte que eu adicionei uma proteçãozinha pra não estorar o limite que a database suporta dentro de um storage value, pra evitar alguns abusos que resultam em crash.
Teste de novo:
<?xml version="1.0" encoding="UTF-8"?> <mod name="autoLoot" enabled="yes" author="MatheusMkalo" forum="XTibia.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[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) 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, corpseid, killer, itemsarray) local corpse = getTileItemById(corpsepos, corpseid).uid if corpse <= 1 then return 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, math.max(x.type, 1)) else doPlayerAddItem(killer, x.itemid) end doRemoveItem(x.uid, math.max(x.type, 1)) 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 local corpseId = getMonsterInfo(getCreatureName(target)).lookCorpse addEvent(corpseRetireItems, 5, getCreaturePosition(target), corpseId, cid, loots) end return true ]]></creaturescript> <talkaction words="!autoloot;/autoloot" event="script"><![CDATA[ domodlib("autoLootLib") local t = string.explode(param, ",") local size = 0 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[i] = getItemIdByName(x, false) size = size + string.len(t[i]) end if size > 280 then return doPlayerSendCancel(cid, "There are too many items in that list!") 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>
Opa, blz ?
Entao, agora o comando esta funcionando certinho, o so que o item nao vem pra BP, testei varios, segue o erro no console.
[10/01/2013 17:47:12] [Error - CreatureScript Interface] [10/01/2013 17:47:12] In a timer event called from: [10/01/2013 17:47:12] buffer:onKill [10/01/2013 17:47:12] Description: [10/01/2013 17:47:12] [string "function setPlayerStorageTable(cid, storage..."]:93: attempt to index local 'corpse' (a number value) [10/01/2013 17:47:12] stack traceback: [10/01/2013 17:47:12] [string "function setPlayerStorageTable(cid, storage..."]:93: in function <[string "function setPlayerStorageTable(cid, storage..."]:90>
Agradeço muito pelo seu tempo meu amigo!
Opa, vê se agora vai:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="autoLoot" enabled="yes" author="MatheusMkalo" forum="XTibia.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[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)
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, corpseid, killer, itemsarray)
local corpse = getTileItemById(corpsepos, corpseid).uid
if corpse <= 1 then return end
local items = getContainerItems(corpse)
for i,x in pairs(items) do
if isInArray(itemsarray, tonumber(x.itemid)) then
if isItemStackable(x.itemid) then
doPlayerAddItemStacking(killer, x.itemid, math.max(x.type, 1))
else
doPlayerAddItem(killer, x.itemid)
end
doRemoveItem(x.uid, math.max(x.type, 1))
end
end
end
]]></config>
<creaturescript type="kill" name="autoLootKill" event="script"><![CDATA[
domodlib("autoLootLib")
local loots = getPlayerStorageTable(cid, 6616)
if lastHit and #loots >= 1 and isMonster(target) then
local corpseId = getMonsterInfo(getCreatureName(target)).lookCorpse
addEvent(corpseRetireItems, 5, getCreaturePosition(target), corpseId, cid, loots)
end
return true
]]></creaturescript>
<talkaction words="!autoloot;/autoloot" event="script"><![CDATA[
domodlib("autoLootLib")
local t = string.explode(param, ",")
local size = 0
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[i] = getItemIdByName(x, false)
size = size + string.len(t[i])
end
if size > 280 then
return doPlayerSendCancel(cid, "There are too many items in that list!")
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>
Editado Janeiro 1 por brun123
info
Grupo: Artesão
Registrado: 26/04/09
Posts: 120
Reputação: +2

Opa, vê se agora vai:
<?xml version="1.0" encoding="UTF-8"?> <mod name="autoLoot" enabled="yes" author="MatheusMkalo" forum="XTibia.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[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) 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, corpseid, killer, itemsarray) local corpse = getTileItemById(corpsepos, corpseid).uid if corpse <= 1 then return end local items = getContainerItems(corpse) for i,x in pairs(items) do if isInArray(itemsarray, tonumber(x.itemid)) then if isItemStackable(x.itemid) then doPlayerAddItemStacking(killer, x.itemid, math.max(x.type, 1)) else doPlayerAddItem(killer, x.itemid) end doRemoveItem(x.uid, math.max(x.type, 1)) end end end ]]></config> <creaturescript type="kill" name="autoLootKill" event="script"><![CDATA[ domodlib("autoLootLib") local loots = getPlayerStorageTable(cid, 6616) if lastHit and #loots >= 1 and isMonster(target) then local corpseId = getMonsterInfo(getCreatureName(target)).lookCorpse addEvent(corpseRetireItems, 5, getCreaturePosition(target), corpseId, cid, loots) end return true ]]></creaturescript> <talkaction words="!autoloot;/autoloot" event="script"><![CDATA[ domodlib("autoLootLib") local t = string.explode(param, ",") local size = 0 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[i] = getItemIdByName(x, false) size = size + string.len(t[i]) end if size > 280 then return doPlayerSendCancel(cid, "There are too many items in that list!") 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>
Ohhh, poxa vida cara, funcionou direitinho agora, agradeço muito pela ajuda e ja abusando de seu conhecimento teria como vc dar uma olhadinha neste outro script de autoloot? .... hehehehe ... OBrigaadooo!!!
http://www.xtibia.com/forum/topic/202954-comando-autoloot/page__fromsearch__1
Modem mover o topic




info
Grupo: Artesão
Registrado: 26/04/09
Posts: 120
Reputação: +2
Nome do Script: Concertar script autoloot
Tipo do Script: Nao sei!
Versão Utilizada: 8.60
Servidor Utilizado: TheLostServer
Nível de Experiência: Complicado.
Informações Extras: --
Pessoal, estou testando varios scripts de autoloot, esse aki ate agora esta sendo o melhor, porem ele clona os itens do bixus, ou seja, ele pega o item do bixu mas se vc for la e abrir o mesmo ainda sim estará la..
Segue o script
MOD
<?xml version="1.0" encoding="UTF-8"?> <mod name="autoLoot" enabled="yes" author="MatheusMkalo" forum="XTibia.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[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) 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[i] = 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>Editado Janeiro 1 por markim1986