• 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 Blue Arrow when drop item rare

Carlitos Flow

Developer (lvl*1)
Joined
Mar 2, 2011
Messages
156
Solutions
4
Reaction score
10
Hello, im trying to add the magic effect #55 when x player drops x item (like an item rare) from a corpse of monster, its not working, anyone can help me please? Thanks (already registed in login)
-(Arrow effect appear on the corpse from the monster)
I was testing with print console and only prints number 0 and 1

Lua:
local effect = 55                             
local arrow = {55, 60}                     --Effect and seconds.

function isRare(itemid)
local items = {5897, 2666, 3976}          --IDs from items
 return isInArray(ids, itemid)
end

function sendEffect(pos, time)
    if time < 0 then
        return true
    end
    doSendMagicEffect(pos, arrow[1])
    addEvent(sendEffect, 1000, pos, time - 1)
end
local function func(cid, position, corpseid, effect)
    print(1)
    if not isCreature(cid) then return true end
    local corpse = getTileItemById(position, corpseid).uid
    if corpse <= 1 then return end
    if not isContainer(corpse) then return true end
    for slot = 0, (getContainerSize(corpse)-1) do
        local item = getContainerItem(corpse, slot)
        if item.uid <= 1 then return end
        if isRare(item.itemid) then
            print(2)
            return doSendMagicEffect(position, effect)
        end
    end
end
function onKill(cid, target, lastHit)

    print(0)
    if not isMonster(target) then return true end
    local corpse = getMonsterInfo(getCreatureName(target)).lookCorpse

    addEvent(func, 5, getCreatureSummons(cid)[1], getThingPos(target), corpse, effect)
    return true
end
 
Solution
Lua:
local rare_items = {5897}
local effect = CONST_ME_TUTORIALARROW
local timer = 5

local function countdown(pos, timer)
    if timer < 0 then
        return true
    end
    doSendMagicEffect(pos, effect)
    addEvent(countdown, 6500, pos, timer - 1)
end

local function scanContainer(uid, pos)
    for i = getContainerSize(uid) - 1, 0, -1 do
        local item = getContainerItem(uid, i)
        if isContainer(item.uid) then
            scanContainer(item.uid, pos)
        else
            if isInArray(rare_items, item.itemid) then
                doSendMagicEffect(pos, effect)
                addEvent(countdown, 6500, pos, timer)
            end
        end
    end
end

local function scanCorpse(pos, corpseId)
    local corpse =...
local corpseId = getMonsterInfo(getCreatureName(target)).lookCorpse

Is there another way to get corpse ID?

getMonsterInfo and getCreatureName dont exist for me, using a downgraded version of tfs1.2 for tibia 7.7

Edit: this

local corpseId = MonsterType(target:getName()):getCorpseId()
 
Last edited:
Back
Top