Nevermore
Banned User
Hey, I'm using Teckman's group loot system, and it seems that all of the loot in backpacks just vanishes, doesn't do anything to sort it out.
XML:
<?xml version = "1.0" encoding = "UTF-8"?> <mod name = "Party Looot" version = "1.0" author = "Teckman" enabled = "yes">
<event type = "kill" name = "partyLootKill" event = "script"><![CDATA[
local itemsToLoot = {2520, 2393, 2432} -- add items that will be rolled by players
function doShareLoot(cid, pos, item)
local loot = {}
for i = 1, getContainerSize(getTileItemById(pos, item).uid) do
i = getContainerSize(getTileItemById(pos, item).uid) - i
local container = getContainerItem(getTileItemById(pos, item).uid, i).uid
if(getContainerItem(getTileItemById(pos, item).uid, i).itemid == 1987) then
for j = 1, getContainerSize(container) do
j = getContainerSize(container) - j
table.insert(loot, {
getContainerItem(container, j).itemid,
getContainerItem(container, j).type > 0 and getContainerItem(container, j).type or 1
})
end
else
table.insert(loot, {
getContainerItem(getTileItemById(pos, item).uid, i).itemid,
getContainerItem(getTileItemById(pos, item).uid, i).type > 0 and getContainerItem(getTileItemById(pos, item).uid, i).type or 1
})
end
end
local lastpos = getThingPos(getTileItemById(pos, item).uid)
doRemoveItem(getTileItemById(pos, item).uid)
doDecayItem(doCreateItem(item, 1, lastpos))
for i = 1, table.maxn(loot) do
if(loot[i][1] > 0 and loot[i][2] > 0) then
local money = 0
if(isInArray({2160, 2152, 2148}, loot[i][1])) then
money = (loot[i][1] == 2150 and loot[i][2] * 10000 or loot[i][1] == 2152 and loot[i][2] * 100 or loot[i][1] == 2148 and loot[i][2])
for _, cid in pairs(getPartyMembers(getPartyLeader(cid))) do
doPlayerAddMoney(cid, math.floor(money / table.maxn(getPartyMembers(getPartyLeader(cid)))))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Your share of looted money is: " .. math.floor(money / table.maxn(getPartyMembers(getPartyLeader(cid)))) .. " gold coin(s).")
end
elseif(isInArray(itemsToLoot, loot[i][1])) then
local winner = getPartyMembers(getPartyLeader(cid))[math.random(1, table.maxn(getPartyMembers(getPartyLeader(cid))))]
doPlayerAddItem(winner, loot[i][1], loot[i][2])
doPlayerSendTextMessage(winner, MESSAGE_STATUS_DEFAULT, "You've won: " .. loot[i][2] .. "x " .. getItemNameById(loot[i][1]) .. " from loot share.")
else
doAddContainerItem(getTileItemById(pos, item).uid, loot[i][1], loot[i][2])
end
end
end
return true
end
function onKill(cid, target)
if(isInParty(cid) and isMonster(target)) then
addEvent(doShareLoot, 0, cid, getCreaturePosition(target), getMonsterInfo(string.lower(getCreatureName(target))).lookCorpse)
end
return true
end
]]></event>
<event type = "login" name = "partyLootLogin" event = "script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "partyLootKill")
return true
end
]]></event>
</mod>