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

Portal with timer (Quest)

bravespiritz

Member
Joined
Aug 10, 2023
Messages
33
Reaction score
5
Hi,

What i'm trying to do is, a player is supposed to enter this portal and arrive in a Arena. The player can hunt in the arena in 5 min and if the player survive the player will be teleported to temple (1000, 1000, 7) and the player will receive a reward.

How would I go about doing this? I have started to make a script but it is not currently working. Im using TFS 1.4.2

1692021015181.png


Lua:
local magicPortalPosition = Position(1000, 988, 6)
local teleportPosition = Position(1000, 1000, 7)
local itemID = 2463
local survivalTime = 20 -- 5 minutes in seconds

function onLogin(player)
    if player:getPosition() == magicPortalPosition then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Welcome to the magic force portal!")
        player:registerEvent("magicPortalSurvival")
    end
end

function onLogout(player)
    player:teleportTo(teleportPosition)
end

function magicPortalSurvival(player)
    player:say("You are inside the magic force portal. Survive 5 minutes to receive a reward!", TALKTYPE_MONSTER_SAY)
    addEvent(function()
        if player:getPosition() == magicPortalPosition then
            player:addItem(itemID, 1)
            player:teleportTo(teleportPosition)
            player:say("Congratulations! You survived and received a reward.", TALKTYPE_MONSTER_SAY)
        end
    end, survivalTime * 1000)
end

function onStepIn(creature, item, position, fromPosition)
    if item.uid == 1000 then
        creature:registerEvent("magicPortalSurvival")
    end
    return true
end

function onStepOut(creature, item, position, fromPosition)
    if item.uid == 1000 then
        creature:unregisterEvent("magicPortalSurvival")
    end
    return true
end


for _, event in ipairs({"Login", "Logout", "StepIn", "StepOut"}) do
    registerCreatureEvent(event, event == "StepIn" or event == "StepOut" and {onStepIn, onStepOut} or _G["on" .. event])
end
 
Back
Top