• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

TFS 0.3.7 onkill remove stone

MadMOOK

Hoo
Joined
Apr 20, 2011
Messages
802
Reaction score
44
I need something like this...
Heres what I got but it says thing not found.. and the msg dont pop up on body xD lol
Code:
local t = {
    ["energy guardian"] = {
        rockPos = {x = 2039, y = 2044, z = 14, stackpos=1},
        msg = "Noooo.." -- the message the monster says upon death
    }
}

local function remove(position)
    local k = getTileItemById(position, 1304).uid
    return k > 0 and doRemoveItem(k), doSendMagicEffect(position, CONST_ME_POFF)
end
local function doSendAnimatedText(pos, text, color, cid)
    if tonumber(text) then
        text = tonumber(text)
        if cid and isPlayer(cid) then
            doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE_OTHERS, "", text, color, pos)
        else
            local t = getSpectators(pos, 7, 5, false)
            if t then
                for _, cid in ipairs(t) do
                    if isPlayer(cid) then
                        doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE_OTHERS, "", text, color, pos)
                    end
                end
            end
        end
    else
        if cid and isCreature(cid) then
            doCreatureSay(cid, text, TALKTYPE_MONSTER)
        else
            local t = getSpectators(pos, 7, 5, false)
            if t then
                for _, cid in ipairs(t) do
                    if isPlayer(cid) then
                        doCreatureSay(cid, text, TALKTYPE_MONSTER, false, cid, pos)
                    end
                end
            end
        end
    end
end


function onKill(cid, target, damage, flags)
    local v = t[string.lower(getCreatureName(target))]
        if(v and (damage == true or bit.band(flags, 1) == 1) and isMonster(target)) then
        doRemoveItem(getThingfromPos(rockpos).uid,1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "The rock has been removed.")
        addEvent(onTimer,1*60*1000)
        end
        return true
        end
       
        function onTimer()
        doCreateItem(1304,1,{x = 2039, y = 2044, z = 14})       
        end
 
Code:
doRemoveItem(getThingfromPos(v.rockpos).uid,1)
Better use getTileItemById, else it won't work properly when there are other items on that position.
Code:
doRemoveItem(getTileItemById(v.rockpos, 1304).uid, 1)
 
Back
Top