• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent [onKill] doRemoveItem + event doCreateItem

andypsylon

be be
Joined
Jan 13, 2009
Messages
772
Reaction score
65
Location
de/pl
in
data/creature/scripts/creaturescripts.xml
insert:
PHP:
<event type="kill" name="removeItem" event="script" value="onKill_removeItem.lua"/>
in
data/creaturescripts/scripts/login.lua
insert:
Code:
    registerCreatureEvent(cid, "removeItem")
create
datacreaturescriptsscriptsonKill_removeItem.lua
and insert:
Code:
-- ver. 1 2011-12-07
-- author tfs, otland.net/members/andypsylon
-- otland.net/f82/onkill-doremoveitem-event-docreateitem-146056
local c = {
    ["mob1"] =    { -- nazwa moba
        {x = 111, y = 111, z = 7}
    },
    ["mob2"] =    {
        {x = 111, y = 111, z = 7},
        {x = 111, y = 111, z = 7}
    },
    items = {1304, 1305, 1306},
    message = "TAKE WHAT YOU WILL, AND RUN AWAY!!",
    time = 30
}

function onKill(cid, target, lastHit)
    if isPlayer(target) then return true end

    local m = c[getCreatureName(target):lower()]

    if m then
        for _, pos in ipairs(m) do
            local it = nil
            for _, i in pairs(c.items) do
                local tmp = getTileItemById(pos, i)
                if tmp.itemid == i then
                    it = tmp
                    break
                end
            end
            if it == nil then return true end
            doRemoveItem(it.uid, 1)
            addEvent(doCreateItem, c.time*1000, it.itemid, 1, pos)
        end
        doCreatureSay(target, c.message, TALKTYPE_MONSTER)
    end
    return true
end

tested on tfs 0.4
 
Last edited:
Back
Top