• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Bug mod on kill if 2 atks count 2 kills

luccagomes

New Member
Joined
Jul 30, 2015
Messages
153
Reaction score
1
I have a problem to my MOD, any can help me to fix?
If 2 peoples kill the same monster count to 2 monsters killed in task system
If 3 peoples kill the same monster count to 3 monsters killed in task system...

Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Loot Ring" version="1.0" author="Cykotitan" contact="otland.net" enabled="yes">
<event type="kill" name="lootring" event="script"> <![CDATA[
local t = {
   item = 11393,
   slot = CONST_SLOT_NECKLACE,
   newRate = 2
}

local rate = getConfigInfo('rateLoot')

function getContentDescription(uid, comma)
local ret, i, containers = '', 0, {}
while i < getContainerSize(uid) do
local v, s = getContainerItem(uid, i), ''
local k = getItemInfo(v.itemid)
if k.name ~= '' then
if v.type > 1 and k.stackable and k.showCount then
s = v.type .. ' ' .. getItemInfo(v.itemid).plural
else
local article = k.article
s = (article == '' and '' or article .. ' ') .. k.name
end
ret = ret .. (i == 0 and not comma and '' or ', ') .. s
if isContainer(v.uid) and getContainerSize(v.uid) > 0 then
table.insert(containers, v.uid)
end
else
ret = ret .. (i == 0 and not comma and '' or ', ') .. 'an item of type ' .. v.itemid .. ', please report it to gamemaster'
end
i = i + 1
end
for i = 1, #containers do
ret = ret .. getContentDescription(containers[i], true)
end
return ret
end

local lootchannelstorage = 7971

local function send(cid, pos, corpseid, monster, party)
local corpse = getTileItemById(pos, corpseid).uid
local ret = isContainer(corpse) and getContentDescription(corpse)
   if party then
     for _, pid in ipairs(getPartyMembers(party)) do
       doPlayerSendTextMessage(pid, MESSAGE_STATUS_CONSOLE_RED,'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing') )
     end
   else
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED,'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing') )
   end
end

local function createLoot(i, ext)
local item = type(i.id) == 'table' and i.id[math.random(#i.id)] or i.id
local random = math.ceil(math.random(100000) / (ext and t.newRate or rate))
local tmpItem

if random < i.chance then
tmpItem = doCreateItemEx(item, getItemInfo(item).stackable and random % i.count + 1 or 1)
end

if not tmpItem then
return
end

if i.subType ~= -1 then
doItemSetAttribute(tmpItem, 'subType', i.subType)
end

if i.actionId ~= -1 then
doItemSetAttribute(tmpItem, 'aid', i.actionId)
end

if i.uniqueId ~= -1 then
doItemSetAttribute(tmpItem, 'uid', i.uniqueId)
end

if i.text ~= '' then
doItemSetAttribute(tmpItem, 'text', i.text)
end

return tmpItem
end

local function createChildLoot(parent, i, ext)
if #i == 0 then
return true
end

local size, cap = 0, getContainerCap(parent)
for k = 1, #i do
if size == cap then
break
end
local tmp = createLoot(i[k], ext)
if tmp then
if isContainer(tmp) then
if createChildLoot(tmp, i[k].child, ext) then
doAddContainerItemEx(parent, tmp)
size = size + 1
else
doRemoveItem(tmp)
end
else
doAddContainerItemEx(parent, tmp)
size = size + 1
end
end
end

return size > 0
end

local function dropLoot(pos, v, ext)
local corpse = getTileItemById(pos, v.lookCorpse).uid
if isContainer(corpse) then
for i = 1, getContainerSize(corpse) do
doRemoveItem(getContainerItem(corpse, 0).uid)
end
local size, cap = 0, getContainerCap(corpse)
for i = 1, #v.loot do
if size == cap then
break
end
local tmp = createLoot(v.loot[i], ext)
if tmp then
if isContainer(tmp) then
if createChildLoot(tmp, v.loot[i].child, ext) then
doAddContainerItemEx(corpse, tmp)
size = size + 1
else
doRemoveItem(tmp)
end
else
doAddContainerItemEx(corpse, tmp)
size = size + 1
end
end
end
end
end

function onKill(cid, target, lastHit)
if lastHit and isMonster(target) then
local v = getMonsterInfo(getCreatureName(target))
if v.lookCorpse > 0 then
local master = getCreatureMaster(target)
if not master or master == target then
addEvent(dropLoot, 0, getThingPos(target), v, getPlayerSlotItem(cid, t.slot).itemid == t.item)
end
addEvent(send, 100, cid, getThingPos(target), v.lookCorpse, v.description, getPlayerParty(cid))
end
end
return true
end
]]></event>
<event type="login" name="Loot Ring" event="buffer"><![CDATA[
registerCreatureEvent(cid, "lootring")
]]></event>
</mod>
 
try
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Loot Ring" version="1.0" author="Cykotitan" contact="otland.net" enabled="yes">
<event type="kill" name="lootring" event="script"> <![CDATA[
    local t = {
       item = 11393,
       slot = CONST_SLOT_NECKLACE,
       newRate = 2
    }

    local rate = getConfigInfo('rateLoot')

    function getContentDescription(uid, comma)
        local ret, i, containers = '', 0, {}
        while i < getContainerSize(uid) do
            local v, s = getContainerItem(uid, i), ''
            local k = getItemInfo(v.itemid)
            if k.name ~= '' then
                if v.type > 1 and k.stackable and k.showCount then
                    s = v.type .. ' ' .. getItemInfo(v.itemid).plural
                else
                    local article = k.article
                    s = (article == '' and '' or article .. ' ') .. k.name
                end
                ret = ret .. (i == 0 and not comma and '' or ', ') .. s
                if isContainer(v.uid) and getContainerSize(v.uid) > 0 then
                    table.insert(containers, v.uid)
                end
            else
                ret = ret .. (i == 0 and not comma and '' or ', ') .. 'an item of type ' .. v.itemid .. ', please report it to gamemaster'
            end
            i = i + 1
        end
        for i = 1, #containers do
            ret = ret .. getContentDescription(containers[i], true)
        end
        return ret
    end

    local lootchannelstorage = 7971

    local function send(cid, pos, corpseid, monster, party)
        local corpse = getTileItemById(pos, corpseid).uid
        local ret = isContainer(corpse) and getContentDescription(corpse)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED,'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing') )
    end

    local function createLoot(i, ext)
        local item = type(i.id) == 'table' and i.id[math.random(#i.id)] or i.id
        local random = math.ceil(math.random(100000) / (ext and t.newRate or rate))
        local tmpItem

        if random < i.chance then
            tmpItem = doCreateItemEx(item, getItemInfo(item).stackable and random % i.count + 1 or 1)
        end

        if not tmpItem then
            return
        end

        if i.subType ~= -1 then
            doItemSetAttribute(tmpItem, 'subType', i.subType)
        end

        if i.actionId ~= -1 then
            doItemSetAttribute(tmpItem, 'aid', i.actionId)
        end

        if i.uniqueId ~= -1 then
            doItemSetAttribute(tmpItem, 'uid', i.uniqueId)
        end

        if i.text ~= '' then
            doItemSetAttribute(tmpItem, 'text', i.text)
        end

        return tmpItem
    end

    local function createChildLoot(parent, i, ext)
        if #i == 0 then
            return true
        end

        local size, cap = 0, getContainerCap(parent)
        for k = 1, #i do
            if size == cap then
                break
            end
            local tmp = createLoot(i[k], ext)
            if tmp then
                if isContainer(tmp) then
                    if createChildLoot(tmp, i[k].child, ext) then
                        doAddContainerItemEx(parent, tmp)
                        size = size + 1
                    else
                        doRemoveItem(tmp)
                    end
                else
                    doAddContainerItemEx(parent, tmp)
                    size = size + 1
                end
            end
        end

        return size > 0
    end

    local function dropLoot(pos, v, ext)
        local corpse = getTileItemById(pos, v.lookCorpse).uid
        if isContainer(corpse) then
            for i = 1, getContainerSize(corpse) do
                doRemoveItem(getContainerItem(corpse, 0).uid)
            end
            local size, cap = 0, getContainerCap(corpse)
            for i = 1, #v.loot do
                if size == cap then
                    break
                end
                local tmp = createLoot(v.loot[i], ext)
                if tmp then
                    if isContainer(tmp) then
                        if createChildLoot(tmp, v.loot[i].child, ext) then
                            doAddContainerItemEx(corpse, tmp)
                            size = size + 1
                        else
                            doRemoveItem(tmp)
                        end
                    else
                        doAddContainerItemEx(corpse, tmp)
                        size = size + 1
                    end
                end
            end
        end
    end

    function onKill(cid, target, lastHit)
        if lastHit and isMonster(target) then
            local v = getMonsterInfo(getCreatureName(target))
            if v.lookCorpse > 0 then
                local master = getCreatureMaster(target)
                if not master or master == target then
                    addEvent(dropLoot, 0, getThingPos(target), v, getPlayerSlotItem(cid, t.slot).itemid == t.item)
                end
                addEvent(send, 100, cid, getThingPos(target), v.lookCorpse, v.description)
            end
        end
        return true
    end
]]></event>
<event type="login" name="Loot Ring" event="buffer"><![CDATA[
    registerCreatureEvent(cid, "lootring")
]]></event>
</mod>
 
try
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Loot Ring" version="1.0" author="Cykotitan" contact="otland.net" enabled="yes">
<event type="kill" name="lootring" event="script"> <![CDATA[
    local t = {
       item = 11393,
       slot = CONST_SLOT_NECKLACE,
       newRate = 2
    }

    local rate = getConfigInfo('rateLoot')

    function getContentDescription(uid, comma)
        local ret, i, containers = '', 0, {}
        while i < getContainerSize(uid) do
            local v, s = getContainerItem(uid, i), ''
            local k = getItemInfo(v.itemid)
            if k.name ~= '' then
                if v.type > 1 and k.stackable and k.showCount then
                    s = v.type .. ' ' .. getItemInfo(v.itemid).plural
                else
                    local article = k.article
                    s = (article == '' and '' or article .. ' ') .. k.name
                end
                ret = ret .. (i == 0 and not comma and '' or ', ') .. s
                if isContainer(v.uid) and getContainerSize(v.uid) > 0 then
                    table.insert(containers, v.uid)
                end
            else
                ret = ret .. (i == 0 and not comma and '' or ', ') .. 'an item of type ' .. v.itemid .. ', please report it to gamemaster'
            end
            i = i + 1
        end
        for i = 1, #containers do
            ret = ret .. getContentDescription(containers[i], true)
        end
        return ret
    end

    local lootchannelstorage = 7971

    local function send(cid, pos, corpseid, monster, party)
        local corpse = getTileItemById(pos, corpseid).uid
        local ret = isContainer(corpse) and getContentDescription(corpse)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED,'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing') )
    end

    local function createLoot(i, ext)
        local item = type(i.id) == 'table' and i.id[math.random(#i.id)] or i.id
        local random = math.ceil(math.random(100000) / (ext and t.newRate or rate))
        local tmpItem

        if random < i.chance then
            tmpItem = doCreateItemEx(item, getItemInfo(item).stackable and random % i.count + 1 or 1)
        end

        if not tmpItem then
            return
        end

        if i.subType ~= -1 then
            doItemSetAttribute(tmpItem, 'subType', i.subType)
        end

        if i.actionId ~= -1 then
            doItemSetAttribute(tmpItem, 'aid', i.actionId)
        end

        if i.uniqueId ~= -1 then
            doItemSetAttribute(tmpItem, 'uid', i.uniqueId)
        end

        if i.text ~= '' then
            doItemSetAttribute(tmpItem, 'text', i.text)
        end

        return tmpItem
    end

    local function createChildLoot(parent, i, ext)
        if #i == 0 then
            return true
        end

        local size, cap = 0, getContainerCap(parent)
        for k = 1, #i do
            if size == cap then
                break
            end
            local tmp = createLoot(i[k], ext)
            if tmp then
                if isContainer(tmp) then
                    if createChildLoot(tmp, i[k].child, ext) then
                        doAddContainerItemEx(parent, tmp)
                        size = size + 1
                    else
                        doRemoveItem(tmp)
                    end
                else
                    doAddContainerItemEx(parent, tmp)
                    size = size + 1
                end
            end
        end

        return size > 0
    end

    local function dropLoot(pos, v, ext)
        local corpse = getTileItemById(pos, v.lookCorpse).uid
        if isContainer(corpse) then
            for i = 1, getContainerSize(corpse) do
                doRemoveItem(getContainerItem(corpse, 0).uid)
            end
            local size, cap = 0, getContainerCap(corpse)
            for i = 1, #v.loot do
                if size == cap then
                    break
                end
                local tmp = createLoot(v.loot[i], ext)
                if tmp then
                    if isContainer(tmp) then
                        if createChildLoot(tmp, v.loot[i].child, ext) then
                            doAddContainerItemEx(corpse, tmp)
                            size = size + 1
                        else
                            doRemoveItem(tmp)
                        end
                    else
                        doAddContainerItemEx(corpse, tmp)
                        size = size + 1
                    end
                end
            end
        end
    end

    function onKill(cid, target, lastHit)
        if lastHit and isMonster(target) then
            local v = getMonsterInfo(getCreatureName(target))
            if v.lookCorpse > 0 then
                local master = getCreatureMaster(target)
                if not master or master == target then
                    addEvent(dropLoot, 0, getThingPos(target), v, getPlayerSlotItem(cid, t.slot).itemid == t.item)
                end
                addEvent(send, 100, cid, getThingPos(target), v.lookCorpse, v.description)
            end
        end
        return true
    end
]]></event>
<event type="login" name="Loot Ring" event="buffer"><![CDATA[
    registerCreatureEvent(cid, "lootring")
]]></event>
</mod>



Ty, but don't work, now only give msg loot party if other party member kkill monster too and when i killed a spider (task)

00:00 Killed Spiders [542/900].
00:00 Killed Spiders [543/900].
00:00 Loot of a spider: nothing

It's like i killed 2 monsters, but i just killed 1
 
Mods show the whole script in error messages, the real error is shown at the bottom
H6ys3nC.png


From "Description:"


I didn't see any error
 
Back
Top