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

Action Lever by time

amoxicilina

Member
Joined
Jun 25, 2010
Messages
72
Reaction score
10
Hello, I need help for someone specializing in .Lua to convert this Script leverage by time, the way it is there for TFS 1.3.

function onUse(cid, item, fromPosition, itemEx, toPosition, words, param, channel, item2, topos)
local quest = {level = 50 -- level mínimo
max_times = 3, -- quantas vezes poderá usar
timetowait = {1, "day"}, -- tempo para usar novamente após atingir o max_times
max_players = 3, -- máximo de players dentro da área
room = {from = {x = 32312, y = 32507, z = 8}, to = {x = 32312, y = 32507, z = 8}}-- posição do canto superior esquerdo, posição do canto inferior direito da sala
newpos = {x = 32327, y = 32528, z = 18}, -- posição para onde o player será teleportado ao entrar
stone = {id = 1304, pos = {x = 32320, y = 32516, z = 8}} -- id da pedra, posição
timetokick = {2, "min"},-- tempo para ser kikado da sala
local pos = {X=32331, Y=32526, Z=7, stackpos=1}
kickpos = {x = 32331 , y = 32526, z = 7}} -- quando kikados da área, o player vai para essa posição


local p, inside = getPlayerPosition(cid), getPlayersInArea(quest.room.from, quest.room.to)

if getPlayerStorageValue(cid, 84309) > os.time() then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You can use again at " .. os.date("%d %B %Y %X", getPlayerStorageValue(cid, 84309))..".")
return true
else
if getPlayerStorageValue(cid, 84310) == quest.max_times then
setPlayerStorageValue(cid, 84310, -1)
end
end

if #inside >= quest.max_players then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Wait for the team to leave the room.")
doSendMagicEffect(p, CONST_ME_POFF)
return true
end

if getPlayerLevel(cid) < quest.level then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You need at least level " .. quest.level .. " to go.")
doSendMagicEffect(p, CONST_ME_POFF)
return true
end

local max_times = getPlayerStorageValue(cid, 84310) > 0 and getPlayerStorageValue(cid, 84310) or 0

if (max_times + 1) == quest.max_times then
setPlayerStorageValue(cid, 84309, mathtime(quest.timetowait) + os.time())
end

local stone = getTileItemById(quest.stone.pos, quest.stone.id).uid
if stone > 0 then
doSendMagicEffect(quest.stone.pos, CONST_ME_POFF)
doRemoveItem(stone)
end

doTeleportThing(cid, quest.room.newpos)
doSendMagicEffect(quest.room.newpos, CONST_ME_TELEPORT)
setPlayerStorageValue(cid, 84310, max_times+1)
addEvent(kickFromArea, mathtime(quest.timetokick) * 1000, cid)

return true
end

else function getPlayersInArea(fromPos, toPos)
local players = {}
for _, pid in ipairs(getPlayersOnline()) do
if isInRange(getPlayerPosition(pid), fromPos, toPos) then
table.insert(players, pid)
end
end
return players
end

else function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
end
end
return error("Bad declaration in mathtime function.")
end

else function kickFromArea(cid)
local stone = getTileItemById(quest.stone.pos, quest.stone.id)
if stone.uid == 0 then
doCreateItem(quest.stone.id, 1, quest.stone.pos)
end
if isPlayer(cid) and isInRange(getPlayerPosition(cid), quest.room.from, quest.room.to) then
doTeleportThing(cid, quest.kickpos)
end
doSendMagicEffect(quest.kickpos, CONST_ME_TELEPORT)
end

kkkk.png
 
Last edited:
Solution
Lua:
local config = {
    level = 50, -- level mínimo
    maxTimes = 3, -- quantas vezes poderá usar
    timeToWait = {1, 'day'}, -- tempo para usar novamente após atingir o max_times
    maxPlayers = 3, -- máximo de players dentro da área
    room = {fromPos = Position(32312, 32507, 8), toPos = Position(32312, 32507, 8)}, -- posição do canto superior esquerdo, posição do canto inferior direito da sala
    newPos = Position(32327, 32528, 8), -- posição para onde o player será teleportado ao entrar
    stone = {id = 1304, pos = Position(32320, 32516, 8)}, -- id da pedra, posição
    timeToKick = {2, 'min'}, -- tempo para ser kikado da sala
    kickPos = Position(32331, 32526, 7), -- quando kikados da área, o player vai para essa posição
}...
Lua:
local config = {
    level = 50, -- level mínimo
    maxTimes = 3, -- quantas vezes poderá usar
    timeToWait = {1, 'day'}, -- tempo para usar novamente após atingir o max_times
    maxPlayers = 3, -- máximo de players dentro da área
    room = {fromPos = Position(32312, 32507, 8), toPos = Position(32312, 32507, 8)}, -- posição do canto superior esquerdo, posição do canto inferior direito da sala
    newPos = Position(32327, 32528, 8), -- posição para onde o player será teleportado ao entrar
    stone = {id = 1304, pos = Position(32320, 32516, 8)}, -- id da pedra, posição
    timeToKick = {2, 'min'}, -- tempo para ser kikado da sala
    kickPos = Position(32331, 32526, 7), -- quando kikados da área, o player vai para essa posição
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:hasExhaustion(84309) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You can use again at " .. os.date("%d %B %Y %X", player:getStorageValue(84309))..".")
        return true
    end

    if player:getStorageValue(84310) == config.maxTimes then
        player:setStorageValue(84310, -1)
    end

    if #getPlayersInArea(config.room.fromPos, config.room.toPos) >= config.maxPlayers then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Wait for the team to leave the room.')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end

    if player:getLevel < config.level then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You need at least level " .. config.level .. " to go.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end

    local max_times = player:getStorageValue(84310) > 0 and player:getStorageValue(84310) or 0
    if (max_times + 1) == config.maxTimes then
        player:setStorageValue(84309, mathtime(config.timetowait) + os.time())
    end

    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if stone then
        stone:getPosition():sendMagicEffect(CONST_ME_POFF)
        stone:remove()
    end

    player:teleportTo(config.newPos)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    player:setStorageValue(84310, math.max(0, max_times) + 1)
    addEvent(kickFromArea, mathtime(config.timetokick) * 1000, cid)
    return true
end

function getPlayersInArea(fromPos, toPos)
    local players, playerss = {}, Game.getPlayers()
    for i = 1, #playerss do
        local player = playerss[i]
        if isInRange(player:getPosition(), fromPos, toPos) then
            table.insert(players, player)
        end
    end
    return players
end

function mathtime(table) -- by dwarfer
    local unit = {"sec", "min", "hour", "day"}
    for i, v in pairs(unit) do
        if v == table[2] then
            return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
        end
    end
    return error("Bad declaration in mathtime function.")
end

function kickFromArea(cid)
    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if not stone then
        Game.createItem(config.stone.id, 1, config.stone.pos)
    end

    local player = Player(cid)
    if player and isInRange(player:getPosition(), config.room.fromPos, config.room.toPos)
        player:teleportTo(config.kickPos)
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    end
end
 
Lua:
local config = {
    level = 50, -- level mínimo
    maxTimes = 3, -- quantas vezes poderá usar
    timeToWait = {1, 'day'}, -- tempo para usar novamente após atingir o max_times
    maxPlayers = 3, -- máximo de players dentro da área
    room = {fromPos = Position(32312, 32507, 8), toPos = Position(32312, 32507, 8)}, -- posição do canto superior esquerdo, posição do canto inferior direito da sala
    newPos = Position(32327, 32528, 8), -- posição para onde o player será teleportado ao entrar
    stone = {id = 1304, pos = Position(32320, 32516, 8)}, -- id da pedra, posição
    timeToKick = {2, 'min'}, -- tempo para ser kikado da sala
    kickPos = Position(32331, 32526, 7), -- quando kikados da área, o player vai para essa posição
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:hasExhaustion(84309) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You can use again at " .. os.date("%d %B %Y %X", player:getStorageValue(84309))..".")
        return true
    end

    if player:getStorageValue(84310) == config.maxTimes then
        player:setStorageValue(84310, -1)
    end

    if #getPlayersInArea(config.room.fromPos, config.room.toPos) >= config.maxPlayers then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Wait for the team to leave the room.')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end

    if player:getLevel < config.level then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You need at least level " .. config.level .. " to go.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end

    local max_times = player:getStorageValue(84310) > 0 and player:getStorageValue(84310) or 0
    if (max_times + 1) == config.maxTimes then
        player:setStorageValue(84309, mathtime(config.timetowait) + os.time())
    end

    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if stone then
        stone:getPosition():sendMagicEffect(CONST_ME_POFF)
        stone:remove()
    end

    player:teleportTo(config.newPos)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    player:setStorageValue(84310, math.max(0, max_times) + 1)
    addEvent(kickFromArea, mathtime(config.timetokick) * 1000, cid)
    return true
end

function getPlayersInArea(fromPos, toPos)
    local players, playerss = {}, Game.getPlayers()
    for i = 1, #playerss do
        local player = playerss[i]
        if isInRange(player:getPosition(), fromPos, toPos) then
            table.insert(players, player)
        end
    end
    return players
end

function mathtime(table) -- by dwarfer
    local unit = {"sec", "min", "hour", "day"}
    for i, v in pairs(unit) do
        if v == table[2] then
            return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
        end
    end
    return error("Bad declaration in mathtime function.")
end

function kickFromArea(cid)
    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if not stone then
        Game.createItem(config.stone.id, 1, config.stone.pos)
    end

    local player = Player(cid)
    if player and isInRange(player:getPosition(), config.room.fromPos, config.room.toPos)
        player:teleportTo(config.kickPos)
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    end
end

is giving this error on the console.

sub-mundo.png


I will give you information on how to install the script and if you have something wrong tell me:
c:\data\actions\scripts\sub-mundo
<action actionid="7788" script="sub-mundo/sub.lua" />

and necessary the player is on the floor, stone tile when using the lever or has no need. ID: 426
 
Last edited:
is giving this error on the console.

sub-mundo.png


I will give you information on how to install the script and if you have something wrong tell me:
c:\data\actions\scripts\sub-mundo
<action actionid="7788" script="sub-mundo/sub.lua" />

and necessary the player is on the floor, stone tile when using the lever or has no need. ID: 426
0dxwma6.png

There is nothing in the script that I can find that matches this error.
Also, when I search for <= , I find nothing.
This leads me to believe that the script you are using in sub.lua is not the same script as either of the scripts posted above.
I'd suggest reconfirming this script is installed correctly.
 
replace line 29 with
Lua:
if player:getLevel() < config.level then

I made an exchange that you instructed me and now a new error is appearing on the console. follows image and sub.lua that is implemented in the server. sorry for my English.

local config = {
level = 50, -- level mínimo
maxTimes = 3, -- quantas vezes poderá usar
timeToWait = {1, 'day'}, -- tempo para usar novamente após atingir o max_times
maxPlayers = 3, -- máximo de players dentro da área
room = {fromPos = Position(32477, 32481, 8), toPos = Position(32490, 32489, 8)}, -- posição do canto superior esquerdo, posição do canto inferior direito da sala
newPos = Position(32479, 32484, 8), -- posição para onde o player será teleportado ao entrar
stone = {id = 3687, pos = Position(32483, 32484, 8)}, -- id da pedra, posição
timeToKick = {2, 'min'}, -- tempo para ser kikado da sala
kickPos = Position(32490, 32483, 7), -- quando kikados da área, o player vai para essa posição
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if player:hasExhaustion(84309) then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You can use again at " .. os.date("%d %B %Y %X", player:getStorageValue(84309))..".")
return true
end
if player:getStorageValue(84310) == config.maxTimes then
player:setStorageValue(84310, -1)
end
if #getPlayersInArea(config.room.fromPos, config.room.toPos) >= config.maxPlayers then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Wait for the team to leave the room.')
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return true
end
if player:getLevel() < config.level then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You need at least level " .. config.level .. " to go.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return true
end
local max_times = player:getStorageValue(84310) > 0 and player:getStorageValue(84310) or 0
if (max_times + 1) == config.maxTimes then
player:setStorageValue(84309, mathtime(config.timetowait) + os.time())
end
local stone = Tile(config.stone.pos):getItemById(config.stone.id)
if stone then
stone:getPosition():sendMagicEffect(CONST_ME_POFF)
stone:remove()
end
player:teleportTo(config.newPos)
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
player:setStorageValue(84310, math.max(0, max_times) + 1)
addEvent(kickFromArea, mathtime(config.timetokick) * 1000, cid)
return true
end
function getPlayersInArea(fromPos, toPos)
local players, playerss = {}, Game.getPlayers()
for i = 1, #playerss do
local player = playerss
if isInRange(player:getPosition(), fromPos, toPos) then
table.insert(players, player)
end
end
return players
end
function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
end
end
return error("Bad declaration in mathtime function.")
end
function kickFromArea(cid)
local stone = Tile(config.stone.pos):getItemById(config.stone.id)
if not stone then
Game.createItem(config.stone.id, 1, config.stone.pos)
end
local player = Player(cid)
if player and isInRange(player:getPosition(), config.room.fromPos, config.room.toPos)
player:teleportTo(config.kickPos)
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
end
end

print_sub_lua_sonsole_erro.png


0dxwma6.png

There is nothing in the script that I can find that matches this error.
Also, when I search for <= , I find nothing.
This leads me to believe that the script you are using in sub.lua is not the same script as either of the scripts posted above.
I'd suggest reconfirming this script is installed correctly.
 
I made an exchange that you instructed me and now a new error is appearing on the console. follows image and sub.lua that is implemented in the server. sorry for my English.

local config = {
level = 50, -- level mínimo
maxTimes = 3, -- quantas vezes poderá usar
timeToWait = {1, 'day'}, -- tempo para usar novamente após atingir o max_times
maxPlayers = 3, -- máximo de players dentro da área
room = {fromPos = Position(32477, 32481, 8), toPos = Position(32490, 32489, 8)}, -- posição do canto superior esquerdo, posição do canto inferior direito da sala
newPos = Position(32479, 32484, 8), -- posição para onde o player será teleportado ao entrar
stone = {id = 3687, pos = Position(32483, 32484, 8)}, -- id da pedra, posição
timeToKick = {2, 'min'}, -- tempo para ser kikado da sala
kickPos = Position(32490, 32483, 7), -- quando kikados da área, o player vai para essa posição
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if player:hasExhaustion(84309) then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You can use again at " .. os.date("%d %B %Y %X", player:getStorageValue(84309))..".")
return true
end
if player:getStorageValue(84310) == config.maxTimes then
player:setStorageValue(84310, -1)
end
if #getPlayersInArea(config.room.fromPos, config.room.toPos) >= config.maxPlayers then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Wait for the team to leave the room.')
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return true
end
if player:getLevel() < config.level then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You need at least level " .. config.level .. " to go.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return true
end
local max_times = player:getStorageValue(84310) > 0 and player:getStorageValue(84310) or 0
if (max_times + 1) == config.maxTimes then
player:setStorageValue(84309, mathtime(config.timetowait) + os.time())
end
local stone = Tile(config.stone.pos):getItemById(config.stone.id)
if stone then
stone:getPosition():sendMagicEffect(CONST_ME_POFF)
stone:remove()
end
player:teleportTo(config.newPos)
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
player:setStorageValue(84310, math.max(0, max_times) + 1)
addEvent(kickFromArea, mathtime(config.timetokick) * 1000, cid)
return true
end
function getPlayersInArea(fromPos, toPos)
local players, playerss = {}, Game.getPlayers()
for i = 1, #playerss do
local player = playerss
if isInRange(player:getPosition(), fromPos, toPos) then
table.insert(players, player)
end
end
return players
end
function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
end
end
return error("Bad declaration in mathtime function.")
end
function kickFromArea(cid)
local stone = Tile(config.stone.pos):getItemById(config.stone.id)
if not stone then
Game.createItem(config.stone.id, 1, config.stone.pos)
end
local player = Player(cid)
if player and isInRange(player:getPosition(), config.room.fromPos, config.room.toPos)
player:teleportTo(config.kickPos)
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
end
end

print_sub_lua_sonsole_erro.png

Lua:
if player and isInRange(player:getPosition(), config.room.fromPos, config.room.toPos) then
about line 81

Next time use code tags while pasting a code so everybody could read it.
 
Lua:
local config = {
    level = 50, -- level mínimo
    maxTimes = 3, -- quantas vezes poderá usar
    timeToWait = {1, 'day'}, -- tempo para usar novamente após atingir o max_times
    maxPlayers = 3, -- máximo de players dentro da área
    room = {fromPos = Position(32312, 32507, 8), toPos = Position(32312, 32507, 8)}, -- posição do canto superior esquerdo, posição do canto inferior direito da sala
    newPos = Position(32327, 32528, 8), -- posição para onde o player será teleportado ao entrar
    stone = {id = 1304, pos = Position(32320, 32516, 8)}, -- id da pedra, posição
    timeToKick = {2, 'min'}, -- tempo para ser kikado da sala
    kickPos = Position(32331, 32526, 7), -- quando kikados da área, o player vai para essa posição
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:hasExhaustion(84309) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You can use again at " .. os.date("%d %B %Y %X", player:getStorageValue(84309))..".")
        return true
    end
    if player:getStorageValue(84310) == config.maxTimes then
        player:setStorageValue(84310, -1)
    end
    if #getPlayersInArea(config.room.fromPos, config.room.toPos) >= config.maxPlayers then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Wait for the team to leave the room.')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
    if player:getLevel() < config.level then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You need at least level " .. config.level .. " to go.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
    local max_times = player:getStorageValue(84310) > 0 and player:getStorageValue(84310) or 0
    if (max_times + 1) == config.maxTimes then
        player:setStorageValue(84309, mathtime(config.timetowait) + os.time())
    end
    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if stone then
        stone:getPosition():sendMagicEffect(CONST_ME_POFF)
        stone:remove()
    end
    player:teleportTo(config.newPos)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    player:setStorageValue(84310, math.max(0, max_times) + 1)
    addEvent(kickFromArea, mathtime(config.timetokick) * 1000, player.uid)
    return true
end
function getPlayersInArea(fromPos, toPos)
    local players, playerss = {}, Game.getPlayers()
    for i = 1, #playerss do
        local player = playerss[i]
        if isInRange(player:getPosition(), fromPos, toPos) then
            table.insert(players, player)
        end
    end
    return players
end
function mathtime(table) -- by dwarfer
    local unit = {"sec", "min", "hour", "day"}
    for i, v in pairs(unit) do
        if v == table[2] then
            return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
        end
    end
    return error("Bad declaration in mathtime function.")
end
function kickFromArea(cid)
    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if not stone then
        Game.createItem(config.stone.id, 1, config.stone.pos)
    end
    local player = Player(cid)
    if player and isInRange(player:getPosition(), config.room.fromPos, config.room.toPos)
        player:teleportTo(config.kickPos)
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    end
end
 
Lua:
local config = {
    level = 50, -- level mínimo
    maxTimes = 3, -- quantas vezes poderá usar
    timeToWait = {1, 'day'}, -- tempo para usar novamente após atingir o max_times
    maxPlayers = 3, -- máximo de players dentro da área
    room = {fromPos = Position(32312, 32507, 8), toPos = Position(32312, 32507, 8)}, -- posição do canto superior esquerdo, posição do canto inferior direito da sala
    newPos = Position(32327, 32528, 8), -- posição para onde o player será teleportado ao entrar
    stone = {id = 1304, pos = Position(32320, 32516, 8)}, -- id da pedra, posição
    timeToKick = {2, 'min'}, -- tempo para ser kikado da sala
    kickPos = Position(32331, 32526, 7), -- quando kikados da área, o player vai para essa posição
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:hasExhaustion(84309) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You can use again at " .. os.date("%d %B %Y %X", player:getStorageValue(84309))..".")
        return true
    end
    if player:getStorageValue(84310) == config.maxTimes then
        player:setStorageValue(84310, -1)
    end
    if #getPlayersInArea(config.room.fromPos, config.room.toPos) >= config.maxPlayers then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Wait for the team to leave the room.')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
    if player:getLevel() < config.level then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You need at least level " .. config.level .. " to go.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
    local max_times = player:getStorageValue(84310) > 0 and player:getStorageValue(84310) or 0
    if (max_times + 1) == config.maxTimes then
        player:setStorageValue(84309, mathtime(config.timetowait) + os.time())
    end
    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if stone then
        stone:getPosition():sendMagicEffect(CONST_ME_POFF)
        stone:remove()
    end
    player:teleportTo(config.newPos)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    player:setStorageValue(84310, math.max(0, max_times) + 1)
    addEvent(kickFromArea, mathtime(config.timetokick) * 1000, player.uid)
    return true
end
function getPlayersInArea(fromPos, toPos)
    local players, playerss = {}, Game.getPlayers()
    for i = 1, #playerss do
        local player = playerss[i]
        if isInRange(player:getPosition(), fromPos, toPos) then
            table.insert(players, player)
        end
    end
    return players
end
function mathtime(table) -- by dwarfer
    local unit = {"sec", "min", "hour", "day"}
    for i, v in pairs(unit) do
        if v == table[2] then
            return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
        end
    end
    return error("Bad declaration in mathtime function.")
end
function kickFromArea(cid)
    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if not stone then
        Game.createItem(config.stone.id, 1, config.stone.pos)
    end
    local player = Player(cid)
    if player and isInRange(player:getPosition(), config.room.fromPos, config.room.toPos)
        player:teleportTo(config.kickPos)
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    end
end

So flaviiojr I implemented I gave reload and this error in the console
jr.png

Lua:
if player and isInRange(player:getPosition(), config.room.fromPos, config.room.toPos) then
about line 81

Next time use code tags while pasting a code so everybody could read it.

then I changed the line that 2Rec asked to reload and the following error occurred when I used the lever
jr.png
 
Implement this function:
Player.setExhaustion, Player.getExhaustion [TFS 1.0]

Lua:
local config = {
    level = 50, -- level mínimo
    maxTimes = 3, -- quantas vezes poderá usar
    timeToWait = {1, 'day'}, -- tempo para usar novamente após atingir o max_times
    maxPlayers = 3, -- máximo de players dentro da área
    room = {fromPos = Position(32312, 32507, 8), toPos = Position(32312, 32507, 8)}, -- posição do canto superior esquerdo, posição do canto inferior direito da sala
    newPos = Position(32327, 32528, 8), -- posição para onde o player será teleportado ao entrar
    stone = {id = 1304, pos = Position(32320, 32516, 8)}, -- id da pedra, posição
    timeToKick = {2, 'min'}, -- tempo para ser kikado da sala
    kickPos = Position(32331, 32526, 7), -- quando kikados da área, o player vai para essa posição
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:hasExhaustion(84309) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You can use again at " .. os.date("%d %B %Y %X", player:getStorageValue(84309))..".")
        return true
    end
    if player:getStorageValue(84310) == config.maxTimes then
        player:setStorageValue(84310, -1)
    end
    if #getPlayersInArea(config.room.fromPos, config.room.toPos) >= config.maxPlayers then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Wait for the team to leave the room.')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
    if player:getLevel() < config.level then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You need at least level " .. config.level .. " to go.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
    local max_times = player:getStorageValue(84310) > 0 and player:getStorageValue(84310) or 0
    if (max_times + 1) == config.maxTimes then
        player:setStorageValue(84309, mathtime(config.timetowait) + os.time())
    end
    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if stone then
        stone:getPosition():sendMagicEffect(CONST_ME_POFF)
        stone:remove()
    end
    player:teleportTo(config.newPos)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    player:setStorageValue(84310, math.max(0, max_times) + 1)
    addEvent(kickFromArea, mathtime(config.timetokick) * 1000, player.uid)
    return true
end
function getPlayersInArea(fromPos, toPos)
    local players, playerss = {}, Game.getPlayers()
    for i = 1, #playerss do
        local player = playerss[i]
        if isInRange(player:getPosition(), fromPos, toPos) then
            table.insert(players, player)
        end
    end
    return players
end
function mathtime(table) -- by dwarfer
    local unit = {"sec", "min", "hour", "day"}
    for i, v in pairs(unit) do
        if v == table[2] then
            return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
        end
    end
    return error("Bad declaration in mathtime function.")
end
function kickFromArea(cid)
    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if not stone then
        Game.createItem(config.stone.id, 1, config.stone.pos)
    end
    local player = Player(cid)
    if player and isInRange(player:getPosition(), config.room.fromPos, config.room.toPos) then
        player:teleportTo(config.kickPos)
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    end
end
 
Implement this function:
Player.setExhaustion, Player.getExhaustion [TFS 1.0]

Lua:
local config = {
    level = 50, -- level mínimo
    maxTimes = 3, -- quantas vezes poderá usar
    timeToWait = {1, 'day'}, -- tempo para usar novamente após atingir o max_times
    maxPlayers = 3, -- máximo de players dentro da área
    room = {fromPos = Position(32312, 32507, 8), toPos = Position(32312, 32507, 8)}, -- posição do canto superior esquerdo, posição do canto inferior direito da sala
    newPos = Position(32327, 32528, 8), -- posição para onde o player será teleportado ao entrar
    stone = {id = 1304, pos = Position(32320, 32516, 8)}, -- id da pedra, posição
    timeToKick = {2, 'min'}, -- tempo para ser kikado da sala
    kickPos = Position(32331, 32526, 7), -- quando kikados da área, o player vai para essa posição
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:hasExhaustion(84309) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You can use again at " .. os.date("%d %B %Y %X", player:getStorageValue(84309))..".")
        return true
    end
    if player:getStorageValue(84310) == config.maxTimes then
        player:setStorageValue(84310, -1)
    end
    if #getPlayersInArea(config.room.fromPos, config.room.toPos) >= config.maxPlayers then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Wait for the team to leave the room.')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
    if player:getLevel() < config.level then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You need at least level " .. config.level .. " to go.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
    local max_times = player:getStorageValue(84310) > 0 and player:getStorageValue(84310) or 0
    if (max_times + 1) == config.maxTimes then
        player:setStorageValue(84309, mathtime(config.timetowait) + os.time())
    end
    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if stone then
        stone:getPosition():sendMagicEffect(CONST_ME_POFF)
        stone:remove()
    end
    player:teleportTo(config.newPos)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    player:setStorageValue(84310, math.max(0, max_times) + 1)
    addEvent(kickFromArea, mathtime(config.timetokick) * 1000, player.uid)
    return true
end
function getPlayersInArea(fromPos, toPos)
    local players, playerss = {}, Game.getPlayers()
    for i = 1, #playerss do
        local player = playerss[i]
        if isInRange(player:getPosition(), fromPos, toPos) then
            table.insert(players, player)
        end
    end
    return players
end
function mathtime(table) -- by dwarfer
    local unit = {"sec", "min", "hour", "day"}
    for i, v in pairs(unit) do
        if v == table[2] then
            return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
        end
    end
    return error("Bad declaration in mathtime function.")
end
function kickFromArea(cid)
    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if not stone then
        Game.createItem(config.stone.id, 1, config.stone.pos)
    end
    local player = Player(cid)
    if player and isInRange(player:getPosition(), config.room.fromPos, config.room.toPos) then
        player:teleportTo(config.kickPos)
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    end
end
Flavio Jr I do not know how to implement this function in the script, I do not have much knowledge in script, it will not be possible for me, if it is not possible to do the same thing, but while I try to make an implementation.
 
ok adicionar, O jogador teletransportado mais passando os 2 minutos não é expulso do quarto e apareceu alguns erros no console.
e as mensagens não estão aparecendo quando alguém está no quarto ou que não têm o nível eu preciso usar, nem que os meus 3 tentativas diárias ter expirado.

erros console:
jr.png
 
Lua:
local config = {
    level = 50, -- level mínimo
    maxTimes = 3, -- quantas vezes poderá usar
    timeToWait = {1, 'day'}, -- tempo para usar novamente após atingir o max_times
    maxPlayers = 3, -- máximo de players dentro da área
    room = {fromPos = Position(32312, 32507, 8), toPos = Position(32312, 32507, 8)}, -- posição do canto superior esquerdo, posição do canto inferior direito da sala
    newPos = Position(32327, 32528, 8), -- posição para onde o player será teleportado ao entrar
    stone = {id = 1304, pos = Position(32320, 32516, 8)}, -- id da pedra, posição
    timeToKick = {2, 'min'}, -- tempo para ser kikado da sala
    kickPos = Position(32331, 32526, 7), -- quando kikados da área, o player vai para essa posição
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:hasExhaustion(84309) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You can use again at " .. os.date("%d %B %Y %X", player:getStorageValue(84309))..".")
        return true
    end
    if player:getStorageValue(84310) == config.maxTimes then
        player:setStorageValue(84310, -1)
    end
    if #getPlayersInArea(config.room.fromPos, config.room.toPos) >= config.maxPlayers then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Wait for the team to leave the room.')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
    if player:getLevel() < config.level then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You need at least level " .. config.level .. " to go.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
    local max_times = player:getStorageValue(84310) > 0 and player:getStorageValue(84310) or 0
    if (max_times + 1) == config.maxTimes then
        player:setStorageValue(84309, mathtime(config.timeToWait) + os.time())
    end
    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if stone then
        stone:getPosition():sendMagicEffect(CONST_ME_POFF)
        stone:remove()
    end
    player:teleportTo(config.newPos)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    player:setStorageValue(84310, math.max(0, max_times) + 1)
    addEvent(kickFromArea, mathtime(config.timeToKick) * 1000, player.uid)
    return true
end

function getPlayersInArea(fromPos, toPos)
    local players, playerss = {}, Game.getPlayers()
    for i = 1, #playerss do
        local player = playerss[i]
        if isInRange(player:getPosition(), fromPos, toPos) then
            table.insert(players, player)
        end
    end
    return players
end

function mathtime(table) -- by dwarfer
    local unit = {"sec", "min", "hour", "day"}
    for i, v in pairs(unit) do
        if v == table[2] then
            return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
        end
    end
    return error("Bad declaration in mathtime function.")
end

function kickFromArea(cid)
    local stone = Tile(config.stone.pos):getItemById(config.stone.id)
    if not stone then
        Game.createItem(config.stone.id, 1, config.stone.pos)
    end
    local player = Player(cid)
    if player and isInRange(player:getPosition(), config.room.fromPos, config.room.toPos) then
        player:teleportTo(config.kickPos)
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    end
end
 
Solution
Thanks, I made some modifications in the "player: sendTextMessage" so that their messages can appear.

I changed:
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE,

fur:
player:sendTextMessage(MESSAGE_EVENT_ADVANCE,

if possible update your comment there.
 
Last edited:
Back
Top