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

RevScripts [1.3TFS] Room with time to exit.

Scrollia

Banned User
Joined
Apr 26, 2021
Messages
100
Reaction score
15
Hi, i need a room when 4 people pull a lever will be teleported. they will can stay there and hunt fot 1h, and then they will be kicked, when they are in another team cant get in.
THANK YOU!
 
Haven't tested.

Configure and try:
Lua:
local config = {
    -- Tiles on which the players stand on before using the lever
    enter = {
        from = Position(1, 2, 3),
        to   = Position(4, 5, 6)
    },

    -- Destination area
    destinationArea = {
        topLeft     = Position(0, 0, 0),
        bottomRight = Position(0, 0, 0)
    },

    -- Where players will be teleported to
    destinationSpawnPos = Position(0, 0, 0),
    timeStorage = 59481,
    timeToStay  = 1 * 60 * 60 -- 1h seconds
}

local function isOccupied()
    local z = config.destinationArea.topLeft.z
    for x = config.destinationArea.topLeft.x, config.destinationArea.bottomRight.x do
        for y = config.destinationArea.topLeft.y, config.destinationArea.bottomRight.y do
            local f = (function()
                local tile = Position(x, y, z)
                if not tile then return false end
                local topCreature = tile:getTopCreature()
                if topCreature:isPlayer() then
                    return true
                end
            end)()

            if f then
                return true
            end
        end
    end
    return false
end

local function kickPlayer(cid)
    local player = Player(cid)
    if not player then
        return
    end
    player:teleportTo(player:getTown():getTemplePosition())
end

local function teleportPlayers()
    local z = config.destinationArea.topLeft.z
    for x = config.enter.from.x, config.enter.to.x do
        for y = config.enter.from.y, config.enter.to.y do
            (function()
                local tile = Position(x, y, z)
                if not tile then
                    return
                end

                local topCreature = getTopCreature
                if not topCreature then
                    return
                end

                topCreature:setStorageValue(config.timeStorage, config.timeToStay + os.time())
                addEvent(kickPlayer, config.timeToStay * 1000, topCreature:getId())
                topCreature:teleportTo(config.destinationSpawnPos)
            end)()
        end
    end
end

local xyz = Action()
function xyz.onUse(player, item, fromPosition, itemEx, toPosition)
    if isOccupied() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'The destination is occupied. Try later.')
        fromPosition:sendMagicEffect(CONST_ME_POFF)
        return true
    end
    teleportPlayers()
    return true
end
xyz:register()

local ce = CreatureEvent("kickFromAreaXyz")
function ce.onLogin(player)
    if player:getStorageValue(config.timeStorage) < os.time() then
        return true
    end
    player:setStorageValue(config.timeStorage, -1)
    player:teleportTo(player:getTown():getTemplePosition())
    player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You have been kicked from the room.')
    return true
end
ce:register()
 
Haven't tested.

Configure and try:
Lua:
local config = {
    -- Tiles on which the players stand on before using the lever
    enter = {
        from = Position(1, 2, 3),
        to   = Position(4, 5, 6)
    },

    -- Destination area
    destinationArea = {
        topLeft     = Position(0, 0, 0),
        bottomRight = Position(0, 0, 0)
    },

    -- Where players will be teleported to
    destinationSpawnPos = Position(0, 0, 0),
    timeStorage = 59481,
    timeToStay  = 1 * 60 * 60 -- 1h seconds
}

local function isOccupied()
    local z = config.destinationArea.topLeft.z
    for x = config.destinationArea.topLeft.x, config.destinationArea.bottomRight.x do
        for y = config.destinationArea.topLeft.y, config.destinationArea.bottomRight.y do
            local f = (function()
                local tile = Position(x, y, z)
                if not tile then return false end
                local topCreature = tile:getTopCreature()
                if topCreature:isPlayer() then
                    return true
                end
            end)()

            if f then
                return true
            end
        end
    end
    return false
end

local function kickPlayer(cid)
    local player = Player(cid)
    if not player then
        return
    end
    player:teleportTo(player:getTown():getTemplePosition())
end

local function teleportPlayers()
    local z = config.destinationArea.topLeft.z
    for x = config.enter.from.x, config.enter.to.x do
        for y = config.enter.from.y, config.enter.to.y do
            (function()
                local tile = Position(x, y, z)
                if not tile then
                    return
                end

                local topCreature = getTopCreature
                if not topCreature then
                    return
                end

                topCreature:setStorageValue(config.timeStorage, config.timeToStay + os.time())
                addEvent(kickPlayer, config.timeToStay * 1000, topCreature:getId())
                topCreature:teleportTo(config.destinationSpawnPos)
            end)()
        end
    end
end

local xyz = Action()
function xyz.onUse(player, item, fromPosition, itemEx, toPosition)
    if isOccupied() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'The destination is occupied. Try later.')
        fromPosition:sendMagicEffect(CONST_ME_POFF)
        return true
    end
    teleportPlayers()
    return true
end
xyz:register()

local ce = CreatureEvent("kickFromAreaXyz")
function ce.onLogin(player)
    if player:getStorageValue(config.timeStorage) < os.time() then
        return true
    end
    player:setStorageValue(config.timeStorage, -1)
    player:teleportTo(player:getTown():getTemplePosition())
    player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You have been kicked from the room.')
    return true
end
ce:register()
TY FOR REPLY! :) But where do i add actionID, and lever?
 
TY FOR REPLY! :) But where do i add actionID, and lever?
wopsie

add before xyz:register()
Lua:
xyz:aid( actionid you want to use )

Is there a possibility for players to die in that area before the time is out?
if that is the case; an additional check must be done in onLogin event
 
wopsie

add before xyz:register()
Lua:
xyz:aid( actionid you want to use )

Is there a possibility for players to die in that area before the time is out?
if that is the case; an additional check must be done in onLogin event
Yes they can die, its 'little' dunageon :)

iv got some errors :

Lua:
Lua Script Error: [Scripts Interface]
xxxxxxxxx/data/scripts/dungeon.lua:callback
xxxxxxxxx/data/scripts/dungeon.lua:27: attempt to call method 'getTopCreature' (a nil value)
stack traceback:
        [C]: in function 'getTopCreature'
        /data/scripts/dungeon.lua:27: in function <xxxxxxxx/data/scripts/dungeon.lua:24>
        /data/scripts/dungeon.lua:31: in function 'isOccupied'
        /data/scripts/dungeon.lua:74: in function <xxxxxx/data/scripts/dungeon.lua:73>
 
change: local tile = Position(x, y, z) for local tile = Tile(x, y, z)
It seems that the script there are several situations like the ones I mentioned here, so make sure to replace all these coincidences
 
change: local tile = Position(x, y, z) for local tile = Tile(x, y, z)
It seems that the script there are several situations like the ones I mentioned here, so make sure to replace all these coincidences
thank you for trying to help too, but still the same problem :(
 
thank you for trying to help too, but still the same problem :(
my bad xD, try this
( don't forget to change actionid )
Lua:
local config = {
    -- Tiles on which the players stand on before using the lever
    enter = {
        from = Position(1, 2, 3),
        to   = Position(4, 5, 6)
    },

    -- Destination area
    destinationArea = {
        topLeft     = Position(0, 0, 0),
        bottomRight = Position(0, 0, 0)
    },

    -- Where players will be teleported to
    destinationSpawnPos = Position(0, 0, 0),
    timeStorage = 59481,
    timeToStay  = 1 * 60 * 60 -- 1h seconds
}

local function isOccupied()
    local z = config.destinationArea.topLeft.z
    for x = config.destinationArea.topLeft.x, config.destinationArea.bottomRight.x do
        for y = config.destinationArea.topLeft.y, config.destinationArea.bottomRight.y do
            local f = (function()
                local tile = Tile(x, y, z)
                if not tile then return false end
                local topCreature = tile:getTopCreature()
                if topCreature:isPlayer() then
                    return true
                end
            end)()
            if f then
                return true
            end
        end
    end
    return false
end

local function kickPlayer(cid)
    local player = Player(cid)
    if not player then
        return
    end
    player:teleportTo(player:getTown():getTemplePosition())
end

local function teleportPlayers()
    local z = config.destinationArea.topLeft.z
    for x = config.enter.from.x, config.enter.to.x do
        for y = config.enter.from.y, config.enter.to.y do
            (function()
                local tile = Tile(x, y, z)
                if not tile then
                    return
                end

                local topCreature = tile:getTopCreature()
                if not topCreature then
                    return
                end

                topCreature:setStorageValue(config.timeStorage, config.timeToStay + os.time())
                addEvent(kickPlayer, config.timeToStay * 1000, topCreature:getId())
                topCreature:teleportTo(config.destinationSpawnPos)
            end)()
        end
    end
end

local xyz = Action()
function xyz.onUse(player, item, fromPosition, itemEx, toPosition)
    if isOccupied() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'The destination is occupied. Try later.')
        fromPosition:sendMagicEffect(CONST_ME_POFF)
        return true
    end

    teleportPlayers()
    return true
end
xyz:aid(1234)
xyz:register()

local ce = CreatureEvent("kickFromAreaXyz")
function ce.onLogin(player)
    if player:getStorageValue(config.timeStorage) < os.time() then
        return true
    end
    player:setStorageValue(config.timeStorage, -1)
    player:teleportTo(player:getTown():getTemplePosition())
    player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You have been kicked from the room.')
    return true
end
ce:register()
 
my bad xD, try this
( don't forget to change actionid )
Lua:
local config = {
    -- Tiles on which the players stand on before using the lever
    enter = {
        from = Position(1, 2, 3),
        to   = Position(4, 5, 6)
    },

    -- Destination area
    destinationArea = {
        topLeft     = Position(0, 0, 0),
        bottomRight = Position(0, 0, 0)
    },

    -- Where players will be teleported to
    destinationSpawnPos = Position(0, 0, 0),
    timeStorage = 59481,
    timeToStay  = 1 * 60 * 60 -- 1h seconds
}

local function isOccupied()
    local z = config.destinationArea.topLeft.z
    for x = config.destinationArea.topLeft.x, config.destinationArea.bottomRight.x do
        for y = config.destinationArea.topLeft.y, config.destinationArea.bottomRight.y do
            local f = (function()
                local tile = Tile(x, y, z)
                if not tile then return false end
                local topCreature = tile:getTopCreature()
                if topCreature:isPlayer() then
                    return true
                end
            end)()
            if f then
                return true
            end
        end
    end
    return false
end

local function kickPlayer(cid)
    local player = Player(cid)
    if not player then
        return
    end
    player:teleportTo(player:getTown():getTemplePosition())
end

local function teleportPlayers()
    local z = config.destinationArea.topLeft.z
    for x = config.enter.from.x, config.enter.to.x do
        for y = config.enter.from.y, config.enter.to.y do
            (function()
                local tile = Tile(x, y, z)
                if not tile then
                    return
                end

                local topCreature = tile:getTopCreature()
                if not topCreature then
                    return
                end

                topCreature:setStorageValue(config.timeStorage, config.timeToStay + os.time())
                addEvent(kickPlayer, config.timeToStay * 1000, topCreature:getId())
                topCreature:teleportTo(config.destinationSpawnPos)
            end)()
        end
    end
end

local xyz = Action()
function xyz.onUse(player, item, fromPosition, itemEx, toPosition)
    if isOccupied() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'The destination is occupied. Try later.')
        fromPosition:sendMagicEffect(CONST_ME_POFF)
        return true
    end

    teleportPlayers()
    return true
end
xyz:aid(1234)
xyz:register()

local ce = CreatureEvent("kickFromAreaXyz")
function ce.onLogin(player)
    if player:getStorageValue(config.timeStorage) < os.time() then
        return true
    end
    player:setStorageValue(config.timeStorage, -1)
    player:teleportTo(player:getTown():getTemplePosition())
    player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You have been kicked from the room.')
    return true
end
ce:register()
still the same problem :p but thanks for tryingh to help me!
 
Lua:
local config = {
    -- Tiles on which the players stand on before using the lever
    enter = {
        from = Position(76, 413, 7),
        to   = Position(79, 413, 7)
    },
    -- Destination area
    destinationArea = {
        topLeft     = Position(65, 409, 7),
        bottomRight = Position(73, 417, 7)
    },
    -- Where players will be teleported to
    destinationSpawnPos = Position(72, 413, 7),
    timeStorage = 59481,
    timeToStay  = 5 -- seconds
}

local function isOccupied()
    local z = config.destinationArea.topLeft.z
    for x = config.destinationArea.topLeft.x, config.destinationArea.bottomRight.x do
        for y = config.destinationArea.topLeft.y, config.destinationArea.bottomRight.y do
            local f = (function()
                local tile = Tile(x, y, z)
                if not tile then return false end
                local topCreature = tile:getTopCreature()
                if not topCreature then
                    return false
                end
                return topCreature:isPlayer()
            end)()
            if f then
                return true
            end
        end
    end
    return false
end

local function kickPlayer(cid)
    local player = Player(cid)
    if not player then
        return
    end

    player:teleportTo(player:getTown():getTemplePosition())
end

local function teleportPlayers()
    local z = config.destinationArea.topLeft.z
    for x = config.enter.from.x, config.enter.to.x do
        for y = config.enter.from.y, config.enter.to.y do
            (function()
                local tile = Tile(x, y, z)
                if not tile then
                    return
                end

                local topCreature = tile:getTopCreature()
                if not topCreature then
                    return
                end

                topCreature:setStorageValue(config.timeStorage, config.timeToStay + os.time())
                addEvent(kickPlayer, config.timeToStay * 1000, topCreature:getId())
                topCreature:teleportTo(config.destinationSpawnPos)
            end)()
        end
    end
end

local xyz = Action()
function xyz.onUse(player, item, fromPosition, itemEx, toPosition)
    if isOccupied() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'The destination is occupied. Try later.')
        fromPosition:sendMagicEffect(CONST_ME_POFF)
        return true
    end

    teleportPlayers()
    return true
end

xyz:aid(1234)
xyz:register()
local ce = CreatureEvent("kickFromAreaXyz")
function ce.onLogin(player)
    if player:getStorageValue(config.timeStorage) < os.time() then
        return true
    end

    player:setStorageValue(config.timeStorage, -1)
    player:teleportTo(player:getTown():getTemplePosition())
    player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You have been kicked from the room.')
    return true
end
ce:register()
 
Lua:
local config = {
    -- Tiles on which the players stand on before using the lever
    enter = {
        from = Position(76, 413, 7),
        to   = Position(79, 413, 7)
    },
    -- Destination area
    destinationArea = {
        topLeft     = Position(65, 409, 7),
        bottomRight = Position(73, 417, 7)
    },
    -- Where players will be teleported to
    destinationSpawnPos = Position(72, 413, 7),
    timeStorage = 59481,
    timeToStay  = 5 -- seconds
}

local function isOccupied()
    local z = config.destinationArea.topLeft.z
    for x = config.destinationArea.topLeft.x, config.destinationArea.bottomRight.x do
        for y = config.destinationArea.topLeft.y, config.destinationArea.bottomRight.y do
            local f = (function()
                local tile = Tile(x, y, z)
                if not tile then return false end
                local topCreature = tile:getTopCreature()
                if not topCreature then
                    return false
                end
                return topCreature:isPlayer()
            end)()
            if f then
                return true
            end
        end
    end
    return false
end

local function kickPlayer(cid)
    local player = Player(cid)
    if not player then
        return
    end

    player:teleportTo(player:getTown():getTemplePosition())
end

local function teleportPlayers()
    local z = config.destinationArea.topLeft.z
    for x = config.enter.from.x, config.enter.to.x do
        for y = config.enter.from.y, config.enter.to.y do
            (function()
                local tile = Tile(x, y, z)
                if not tile then
                    return
                end

                local topCreature = tile:getTopCreature()
                if not topCreature then
                    return
                end

                topCreature:setStorageValue(config.timeStorage, config.timeToStay + os.time())
                addEvent(kickPlayer, config.timeToStay * 1000, topCreature:getId())
                topCreature:teleportTo(config.destinationSpawnPos)
            end)()
        end
    end
end

local xyz = Action()
function xyz.onUse(player, item, fromPosition, itemEx, toPosition)
    if isOccupied() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'The destination is occupied. Try later.')
        fromPosition:sendMagicEffect(CONST_ME_POFF)
        return true
    end

    teleportPlayers()
    return true
end

xyz:aid(1234)
xyz:register()
local ce = CreatureEvent("kickFromAreaXyz")
function ce.onLogin(player)
    if player:getStorageValue(config.timeStorage) < os.time() then
        return true
    end

    player:setStorageValue(config.timeStorage, -1)
    player:teleportTo(player:getTown():getTemplePosition())
    player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You have been kicked from the room.')
    return true
end
ce:register()
Ty for keeping trying, now theres no error, nothing, script looks OK, but lever done nothing, cant use a lever. (yes, lever have actid)
 
Ty for keeping trying, now theres no error, nothing, script looks OK, but lever done nothing, cant use a lever. (yes, lever have actid)
need to stand on the right positions.
4 people pull a lever
configure config.enter.from & config.enter.to positions
F = from
T = to
[ F ][ ][ ][ T ]
 
need to stand on the right positions.

configure config.enter.from & config.enter.to positions
F = from
T = to
iv made that :)
[LEVER}[ F ][ ][ ][ T ]


Lua:
local config = {
    -- Tiles on which the players stand on before using the lever
    enter = {
        from = Position(923, 1117, 4),
        to   = Position(926, 1117, 4)
    },
    -- Destination area
    destinationArea = {
        topLeft     = Position(875, 87, 0),
        bottomRight = Position(1052, 207, 0)
    },
    -- Where players will be teleported to
    destinationSpawnPos = Position(1044, 195, 0),
    timeStorage = 59481,
    timeToStay  = 5 -- 1h seconds
}

local function isOccupied()
    local z = config.destinationArea.topLeft.z
    for x = config.destinationArea.topLeft.x, config.destinationArea.bottomRight.x do
        for y = config.destinationArea.topLeft.y, config.destinationArea.bottomRight.y do
            local f = (function()
                local tile = Tile(x, y, z)
                if not tile then return false end
                local topCreature = tile:getTopCreature()
                if not topCreature then
                    return false
                end
                return topCreature:isPlayer()
            end)()
            if f then
                return true
            end
        end
    end
    return false
end

local function kickPlayer(cid)
    local player = Player(cid)
    if not player then
        return
    end

    player:teleportTo(player:getTown():getTemplePosition())
end

local function teleportPlayers()
    local z = config.destinationArea.topLeft.z
    for x = config.enter.from.x, config.enter.to.x do
        for y = config.enter.from.y, config.enter.to.y do
            (function()
                local tile = Tile(x, y, z)
                if not tile then
                    return
                end

                local topCreature = tile:getTopCreature()
                if not topCreature then
                    return
                end

                topCreature:setStorageValue(config.timeStorage, config.timeToStay + os.time())
                addEvent(kickPlayer, config.timeToStay * 1000, topCreature:getId())
                topCreature:teleportTo(config.destinationSpawnPos)
            end)()
        end
    end
end

local xyz = Action()
function xyz.onUse(player, item, fromPosition, itemEx, toPosition)
    if isOccupied() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'The destination is occupied. Try later.')
        fromPosition:sendMagicEffect(CONST_ME_POFF)
        return true
    end

    teleportPlayers()
    return true
end

xyz:aid(45138)
xyz:register()
local ce = CreatureEvent("kickFromAreaXyz")
function ce.onLogin(player)
    if player:getStorageValue(config.timeStorage) < os.time() then
        return true
    end

    player:setStorageValue(config.timeStorage, -1)
    player:teleportTo(player:getTown():getTemplePosition())
    player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You have been kicked from the room.')
    return true
end
ce:register()
 
iv made that :)



Lua:
local config = {
    -- Tiles on which the players stand on before using the lever
    enter = {
        from = Position(923, 1117, 4),
        to   = Position(926, 1117, 4)
    },
    -- Destination area
    destinationArea = {
        topLeft     = Position(875, 87, 0),
        bottomRight = Position(1052, 207, 0)
    },
    -- Where players will be teleported to
    destinationSpawnPos = Position(1044, 195, 0),
    timeStorage = 59481,
    timeToStay  = 5 -- 1h seconds
}

local function isOccupied()
    local z = config.destinationArea.topLeft.z
    for x = config.destinationArea.topLeft.x, config.destinationArea.bottomRight.x do
        for y = config.destinationArea.topLeft.y, config.destinationArea.bottomRight.y do
            local f = (function()
                local tile = Tile(x, y, z)
                if not tile then return false end
                local topCreature = tile:getTopCreature()
                if not topCreature then
                    return false
                end
                return topCreature:isPlayer()
            end)()
            if f then
                return true
            end
        end
    end
    return false
end

local function kickPlayer(cid)
    local player = Player(cid)
    if not player then
        return
    end

    player:teleportTo(player:getTown():getTemplePosition())
end

local function teleportPlayers()
    local z = config.destinationArea.topLeft.z
    for x = config.enter.from.x, config.enter.to.x do
        for y = config.enter.from.y, config.enter.to.y do
            (function()
                local tile = Tile(x, y, z)
                if not tile then
                    return
                end

                local topCreature = tile:getTopCreature()
                if not topCreature then
                    return
                end

                topCreature:setStorageValue(config.timeStorage, config.timeToStay + os.time())
                addEvent(kickPlayer, config.timeToStay * 1000, topCreature:getId())
                topCreature:teleportTo(config.destinationSpawnPos)
            end)()
        end
    end
end

local xyz = Action()
function xyz.onUse(player, item, fromPosition, itemEx, toPosition)
    if isOccupied() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'The destination is occupied. Try later.')
        fromPosition:sendMagicEffect(CONST_ME_POFF)
        return true
    end

    teleportPlayers()
    return true
end

xyz:aid(45138)
xyz:register()
local ce = CreatureEvent("kickFromAreaXyz")
function ce.onLogin(player)
    if player:getStorageValue(config.timeStorage) < os.time() then
        return true
    end

    player:setStorageValue(config.timeStorage, -1)
    player:teleportTo(player:getTown():getTemplePosition())
    player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You have been kicked from the room.')
    return true
end
ce:register()
ezgif.com-gif-maker.gif
 
Back
Top