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?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()
wopsieTY FOR REPLY! But where do i add actionID, and lever?
xyz:register()
xyz:aid( actionid you want to use )
Yes they can die, its 'little' dunageonwopsie
add beforexyz: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
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>
local tile = Position(x, y, z)
for local tile = Tile(x, y, z)
thank you for trying to help too, but still the same problemchange:local tile = Position(x, y, z)
forlocal 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
my bad xD, try thisthank you for trying to help too, but still the same problem
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 but thanks for tryingh to help me!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()
same error?still the same problem but thanks for tryingh to help me!
Yes.same error?
Yes.
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)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()
need to stand on the right positions.Ty for keeping trying, now theres no error, nothing, script looks OK, but lever done nothing, cant use a lever. (yes, lever have actid)
configure4 people pull a lever
config.enter.from
& config.enter.to
positions[ F ][ ][ ][ T ]
iv made thatneed to stand on the right positions.
configureconfig.enter.from
&config.enter.to
positions
F = from
T = to
[LEVER}[ F ][ ][ ][ T ]
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()
why my doesnt work? Mey it be couse of otsbr edit tfs?