É só pegar a pos do item.uid e buscar quais outros corpses estao nesse mesmo tile
- Fórum
- OTServ
- Suporte
- Resolvidos
- Autoloot DxP
7 horas atrás, dalvorsn disse:É só pegar a pos do item.uid e buscar quais outros corpses estao nesse mesmo tile
obg @dalvorsn mas meus conhecementos em scripting sao tao baixos q nao sei como fazer isso
irei esperar algum programador de bom coraçao me ajude com isso
info
Grupo: Herói
Registrado: 07/03/16
Posts: 1.4k
Reputação: +385
Gênero: Masculino

Insere o restante do código dentro desse loop.
Citarfor stack = 1,255 do
local corpo = getThingFromPos {x=frompos.x, y=frompos.y, z=frompos.z, stackpos=stack})
--aqui é o escopo do loop, ponha o código aqui dentro.
end --final do escopo do loop.
Lembre-se de mudar isso:
Citarlocal quemMatou = getItemAttribute(item.uid, "corpseowner")
Para isto:
Citarlocal quemMatou = getItemAttribute(corpo.uid, "corpseowner")
Lembrando que esse código é ridículo, lento e falho.
40 minutos atrás, Poccnn disse:Insere o restante do código dentro desse loop.
Lembre-se de mudar isso:
Para isto:
Lembrando que esse código é ridículo, lento e falho.
ta funfando porem ta dando erro no tfs
[15/09/2016 08:17:29] [Error - Action Interface]
[15/09/2016 08:17:29] data/actions/scripts/Basic/autoLoot.lua:onUse
[15/09/2016 08:17:29] Description:
[15/09/2016 08:17:29] (luaGetContainerSize) Container not found
[15/09/2016 08:17:29] [Error - Action Interface]
[15/09/2016 08:17:29] data/actions/scripts/Basic/autoLoot.lua:onUse
[15/09/2016 08:17:29] Description:
[15/09/2016 08:17:29] data/actions/scripts/Basic/autoLoot.lua:25: 'for' limit must be a number
[15/09/2016 08:17:29] stack traceback:
[15/09/2016 08:17:29] data/actions/scripts/Basic/autoLoot.lua:25: in function <data/actions/scripts/Basic/autoLoot.lua:1>
function onUse(cid, item, frompos, item2, topos)
for stack = 1,255 do
local corpo = getThingFromPos {x=frompos.x, y=frompos.y, z=frompos.z, stackpos=stack}
if isWatchingTv(cid) then return true end
local quemMatou = getItemAttribute(corpo.uid, "corpseowner")
if quemMatou then
local player = getCreatureByName(quemMatou)
if isPlayer(player) then
local isInParyWithPlayer = false
if isInParty(cid) and isInParty(player) then
isInParyWithPlayer = isPartyEquals(player, cid)
end
if getCreatureName(cid) ~= getCreatureName(player) and not isInParyWithPlayer then
doPlayerSendCancel(cid, "Você não pode abrir um loot que não é seu.")
return true
end
end
end
local autoLootList = getAllItensInMyList(cid)
local bag = getPlayerSlotItem(cid, 3).uid
local itemsToRemove = {}
if isCollectAll(cid) then
for a = 0, getContainerSize(corpo.uid) do
local it = getContainerItem(corpo.uid, a)
if it.uid > 0 then
if addItemInFreeBag(bag, it.itemid, it.type) ~= false then
table.insert(itemsToRemove, it.uid)
end
end
end
end
if #autoLootList > 0 and not isCollectAll(cid) then
for a = 0, getContainerSize(corpo.uid) do
local it = getContainerItem(corpo.uid, a)
if it.uid > 0 then
for i = 1, #autoLootList do
if getItemInfo(it.itemid).name == autoLootList then
if addItemInFreeBag(bag, it.itemid, it.type) ~= false then
table.insert(itemsToRemove, it.uid)
end
end
end
end
end
end
if #itemsToRemove > 0 then
for i = 1, #itemsToRemove do
doChangeTypeItem(itemsToRemove, 0)
end
end
end
end
info
Grupo: Herói
Registrado: 07/03/16
Posts: 1.4k
Reputação: +385
Gênero: Masculino

Como eu citei acima... é um script ridículo, lento e falho.
Boa sorte.
Se eu tiver um tempinho dou uma ajeitada, o melhor jeito de fazer isso é usar o getTileInfo, dai essa função vai retornar um campo chamado things, que é o numero de things que existem no tile, que corresponde ao stackpos, dai é so iterar em cima dos things, verificando se é um corpse e se é container e etc
Dai o resto é o que o script ai ja faz
Em 9/15/2016 at 08:35, dalvorsn disse:Se eu tiver um tempinho dou uma ajeitada, o melhor jeito de fazer isso é usar o getTileInfo, dai essa função vai retornar um campo chamado things, que é o numero de things que existem no tile, que corresponde ao stackpos, dai é so iterar em cima dos things, verificando se é um corpse e se é container e etc
Dai o resto é o que o script ai ja faz
esperando ^^ tomara q tenha um tempinho livre por ai
1 hora atrás, Josegvb disse:
esperando ^^ tomara q tenha um tempinho livre por ai
function onUse(cid, item, frompos, item2, topos) if isWatchingTv(cid) then return true end local function getContainers(pos) local things = getTileInfo(pos).things local ret = {} for stack = 0, things do pos.stackpos = stack local item = getTileThingByPos(pos) if item and isContainer(item.uid) then local quemMatou = getItemAttribute(item.uid, "corpseowner") if quemMatou then local player = getCreatureByName(quemMatou) if isPlayer(player) then local isInParyWithPlayer = false if isInParty(cid) and isInParty(player) then isInParyWithPlayer = isPartyEquals(player, cid) end if getCreatureName(cid) == quemMatou or isInParyWithPlayer then table.insert(ret, item) end end end end end return ret end local corpses = getContainers(getThingPosition(item.uid)) if #corpses == 0 then doPlayerSendCancel(cid, "Você não pode abrir um loot que não é seu.") return true end local autoLootList = getAllItensInMyList(cid) local bag = getPlayerSlotItem(cid, 3).uid local itemsToRemove = {} if isCollectAll(cid) then for _, corpse in pairs(corpses) do for a = 0, getContainerSize(corpse.uid) - 1 do local it = getContainerItem(corpse.uid, a) if it.uid > 0 then if addItemInFreeBag(bag, it.itemid, it.type) ~= false then table.insert(itemsToRemove, it.uid) end end end end end if #autoLootList > 0 and not isCollectAll(cid) then for a = 0, getContainerSize(item.uid) do local it = getContainerItem(item.uid, a) if it.uid > 0 then for i = 1, #autoLootList do if getItemInfo(it.itemid).name == autoLootList[i] then if addItemInFreeBag(bag, it.itemid, it.type) ~= false then table.insert(itemsToRemove, it.uid) end end end end end end if #itemsToRemove > 0 then for i = 1, #itemsToRemove do doChangeTypeItem(itemsToRemove[i], 0) end end end
Não cheguei a testar, mas é mais ou menos isso ai
Editado Outubro 2 por dalvorsn
logo q clica no corpo acontece isso
[01/10/2016 23:33:03] [Error - Action Interface]
[01/10/2016 23:33:03] data/actions/scripts/Basic/autoLoot.lua:onUse
[01/10/2016 23:33:03] Description:
[01/10/2016 23:33:03] data/actions/scripts/Basic/autoLoot.lua:32: attempt to get length of global 'containers' (a nil value)
[01/10/2016 23:33:03] stack traceback:
[01/10/2016 23:33:03] data/actions/scripts/Basic/autoLoot.lua:32: in function <data/actions/scripts/Basic/autoLoot.lua:1>
3 minutos atrás, Josegvb disse:logo q clica no corpo acontece isso
[01/10/2016 23:33:03] [Error - Action Interface]
[01/10/2016 23:33:03] data/actions/scripts/Basic/autoLoot.lua:onUse
[01/10/2016 23:33:03] Description:
[01/10/2016 23:33:03] data/actions/scripts/Basic/autoLoot.lua:32: attempt to get length of global 'containers' (a nil value)
[01/10/2016 23:33:03] stack traceback:
[01/10/2016 23:33:03] data/actions/scripts/Basic/autoLoot.lua:32: in function <data/actions/scripts/Basic/autoLoot.lua:1>
Editei, mudei o nome e esqueci de trocar no if
1 hora atrás, dalvorsn disse:Editei, mudei o nome e esqueci de trocar no if
paresce q ta funfando 100% ^^ nao deu erro no executavel e esta pegando tds os items bem rapido, mt obg sir @dalvorsn!
se der algum bug irei citar vocè aqui novamente ^^




info
Grupo: Marquês
Registrado: 23/09/12
Posts: 1k
Reputação: +87
Gênero: Masculino
bom un dos problemas atuais é que os bixos ficam morrendo 1 encima do outro, e assim o autoloot só pega o loot do bixo q ficase encima, os outros sao perdidos...
tem como alterar o autoloot pra pegar TODOS os items de TODOS os corpses que estiver no sqm q for clicado? invez de abrir somente o 1º?
function onUse(cid, item, frompos, item2, topos) if isWatchingTv(cid) then return true end local quemMatou = getItemAttribute(item.uid, "corpseowner") if quemMatou then local player = getCreatureByName(quemMatou) if isPlayer(player) then local isInParyWithPlayer = false if isInParty(cid) and isInParty(player) then isInParyWithPlayer = isPartyEquals(player, cid) end if getCreatureName(cid) ~= getCreatureName(player) and not isInParyWithPlayer then doPlayerSendCancel(cid, "Você não pode abrir um loot que não é seu.") return true end end end local autoLootList = getAllItensInMyList(cid) local bag = getPlayerSlotItem(cid, 3).uid local itemsToRemove = {} if isCollectAll(cid) then for a = 0, getContainerSize(item.uid) do local it = getContainerItem(item.uid, a) if it.uid > 0 then if addItemInFreeBag(bag, it.itemid, it.type) ~= false then table.insert(itemsToRemove, it.uid) end end end end if #autoLootList > 0 and not isCollectAll(cid) then for a = 0, getContainerSize(item.uid) do local it = getContainerItem(item.uid, a) if it.uid > 0 then for i = 1, #autoLootList do if getItemInfo(it.itemid).name == autoLootList[i] then if addItemInFreeBag(bag, it.itemid, it.type) ~= false then table.insert(itemsToRemove, it.uid) end end end end end end if #itemsToRemove > 0 then for i = 1, #itemsToRemove do doChangeTypeItem(itemsToRemove[i], 0) end end end