• 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!

making a quest

jlskelin

New Member
Joined
Mar 28, 2009
Messages
198
Reaction score
1
Hello guys i have a question im trying to make a quest like u need to kill like 3 monster so u can enter a tp im trying to find some sample but cant find i would appreciate any help thx
 
what's your engine? TFS version? i use TFS 1.5 8.0 worked fine so test it

Lua:
local tpId = 1387
local requiredMonsterCount = 3 -- Number of monsters that need to be killed
local tpPosition = {x=761, y=57, z=7} -- Position where the teleport will be created
local tpToPosition = {x=767, y=52, z=7} -- Position where the teleport will take players
local tpTime = 30 -- Time in seconds that the teleport will be open

local monsters = {
    ["Demon"] = 1,
    ["Rat"] = 2,
    ["Dragon"] = 3,
}

function removeTp()
    local t = Tile(tpPosition):getItemById(tpId)
    if t then
        t:remove()
        tpPosition:sendMagicEffect(CONST_ME_POFF)
    end
end

function hasPlayerKilledRequiredMonsters(player)
    local count = 0
    for _, monsterId in pairs(monsters) do
        if player:getStorageValue(monsterId) == 1 then
            count = count + 1
        end
    end
    return count >= requiredMonsterCount
end

function onDeath(creature, corpse, killer, mostDamage, lastHitUnjustified)
    local monsterName = creature:getName()
    local monsterId = monsters[monsterName]
    if monsterId then
        creature:setStorageValue(monsterId, 1)
        if hasPlayerKilledRequiredMonsters(creature) then
            Game.createTeleport(tpId, tpPosition, tpToPosition)
            creature:say("You killed the three monsters! A teleport has been created.", TALKTYPE_ORANGE_1)
            addEvent(removeTp, tpTime * 1000)
        end
    end
    return true
end
 
Back
Top