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

Solved storage + time

leandroluck

New Member
Joined
Dec 24, 2010
Messages
104
Reaction score
1
Code:
function onStepIn(creature, item, position, fromPosition)
    local
    player = creature:getPlayer()
    if not player then
        return true
    end
   
    local config = {
    centerDemonRoomPosition = Position(33646, 32241, 9),

            }

             
    local specs, spec = Game.getSpectators(config.centerDemonRoomPosition, false, false, 3, 3, 2, 2)
        for i = 1, #specs do
            spec = specs[i]
            if spec:isPlayer() then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "A team is already inside the quest room.")
                return true
            end

            spec:remove()
        end
     
    if player:getStorageValue(cid, 958420)  ~= 1 then

    player:teleportTo(fromPosition)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'em testes')
 
     
    else
   
 
 
    setGlobalStorageValue(958420, 1)
    addEvent(setGlobalStorageValue, 600000, 958420, -1)
    player:teleportTo(Position(33642, 32248, 9))
 
   
 
    end
    return true
end


what I'm trying to do the player can only enter the portal after 2 hours.
 
Last edited:
Solution
Your area consists of a single tile only ({x = 33636, y = 32226, z = 9, stackpos = 255} to {x = 33636, y = 32226, z = 9, stackpos = 255})

Edit:
The part in the brackets is not actually supposed to be code which you can use. It is simply the area you are currently using in your script.
Code:
-- Setting the 2 hour "cooldown"
player:setStorageValue(YOUR_STORAGE_KEY, os.time() + 7200)

-- Checking if the player can enter again
if os.time() > player:getStorageValue(YOUR_STORAGE_KEY) then
    -- player can enter again
else
    -- player has to wait
end
 
Code:
-- Setting the 2 hour "cooldown"
player:setStorageValue(YOUR_STORAGE_KEY, os.time() + 7200)

-- Checking if the player can enter again
if os.time() > player:getStorageValue(YOUR_STORAGE_KEY) then
    -- player can enter again
else
    -- player has to wait
end

Code:
local BOSSba = "Kroazur" -- boss name
local BOSS_POSb = {x = 33646, y = 32241, z = 9} -- boss spawn

   
local roomba = {fromx = 33636, tox = 33636, fromy = 32226, toy = 32226, z = 9} -- boss room

local function isPlayerInArea(fromPos, toPos)
    for _x = fromPos.x, toPos.x do
        for _y = fromPos.y, toPos.y do
            for _z = fromPos.z, toPos.z do
                creatureb = getTopCreature({x = _x, y = _y, z = _z})
                    if (isPlayer(creatureb.uid)) then
                    return true
                end
            end
        end
    end
    return false
end

function AddBOSSba()

local BOSSba = 0
for x = roomba.fromx, roomba.tox do
for y = roomba.fromy, roomba.toy do
for z = roomba.z, roomba.z do

creatureb = {x = x, y = y, z = z}
mobb = getTopCreature(creatureb).uid

    if getCreatureName(mobb) == BOSSba then
        BOSSba = 1
    end
end
end
end

if BOSSba == 1 then
end

if BOSSba == 0 then
        Game.createMonster("Kroazur", BOSS_POSb)
end

return true
end

function onStepIn(cid, item, position, topos, frompos)
    local player = Player(cid)
    if not player then
        return true
    end
         
       
       if os.time() > player:getStorageValue(959450) and not isPlayerInArea({x = 33636, y = 32226, z = 9, stackpos = 255}, {x = 33636, y = 32226, z = 9, stackpos = 255}) then
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            player:teleportTo(Position(33642, 32248, 9))
            player:setStorageValue(959450, os.time() + 5)
            addEvent(AddBOSSba, 5 * 1000)
   
else 
doPlayerSendCancel(cid, "Please, wait 2 hrs counting the last use to start again.")
end
    return true
end

no work here
 
Last edited:
Lua:
local function isPlayerInArea(fromPos, toPos)
    for x = fromPos.x, toPos.x do
        for y = fromPos.y, toPos.y do
            for z = fromPos.z, toPos.z do
                local pos = {x = x, y = y, z = z}
                local tile = Tile(pos)
               
                if tile ~= nil and tile:getTopCreature() ~= nil then
                    if tile:getTopCreature():isPlayer() then
                        return true
                    end
                end
            end
        end
    end
    return false
end
 
Code:
local BOSSba = "Kroazur" -- boss name
local BOSS_POSb = {x = 33646, y = 32241, z = 9} -- boss spawn

   
local roomeee = {fromx = 33636, tox = 33636, fromy = 32226, toy = 32226, z = 9} -- boss room

local function isPlayerInArea(fromPos, toPos)
    for _x = fromPos.x, toPos.x do
        for _y = fromPos.y, toPos.y do
            for _z = fromPos.z, toPos.z do
                creatureb = getTopCreature({x = _x, y = _y, z = _z})
                    if (isPlayer(creatureb.uid)) then
                    return true
                end
            end
        end
    end
    return false
end


function AddBossb()

local BOSSba = 0
for x = roomeee.fromx, roomeee.tox do
for y = roomeee.fromy, roomeee.toy do
for z = roomeee.z, roomeee.z do

creatureeee = {x = x, y = y, z = z}
mobeee = getTopCreature(creatureeee).uid

    if getCreatureName(mobeee) == BOSSba then
        BOSSba = 1
    end
end
end
end


if BOSSba == 1 then
end


if BOSSba == 0 then
   local monsterlol = 
       Game.createMonster("Kroazur", BOSS_POSb)
    monsterlol:setReward(true)
end

return true
end

function onStepIn(cid, item, position, topos, frompos)
    local player = Player(cid)
    if not player then
        return true
    end
         
       
       if os.time() > player:getStorageValue(949450) and not isPlayerInArea({x = 33636, y = 32226, z = 9, stackpos = 255}, {x = 33636, y = 32226, z = 9, stackpos = 255}) then
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            player:teleportTo(Position(33642, 32248, 9))
            player:setStorageValue(949450, os.time() + 10)
            addEvent(AddBossb, 5 * 1000)
   
else 
doPlayerSendCancel(cid, "Please, wait 2 hrs counting the last use to start again.")
end
    return true
end

I have modified some things the team is apparently running ..

But now the player check and the monster check is not
in case
if you have a player in the room you are not allowed to enter another player.
if you have a mob in the room the player enters will not sumona another
 
Lua:
local function isPlayerInArea(fromPos, toPos)
    for x = fromPos.x, toPos.x do
        for y = fromPos.y, toPos.y do
            for z = fromPos.z, toPos.z do
                local pos = {x = x, y = y, z = z}
                local tile = Tile(pos)
             
                if tile ~= nil and tile:getTopCreature() ~= nil then
                    if tile:getTopCreature():isPlayer() then
                        return true
                    end
                end
            end
        end
    end
    return false
end
I tested here the player can enter the portal with the player in respawn
the function is being ignored no errors in the console
 
Your area consists of a single tile only ({x = 33636, y = 32226, z = 9, stackpos = 255} to {x = 33636, y = 32226, z = 9, stackpos = 255})

Edit:
The part in the brackets is not actually supposed to be code which you can use. It is simply the area you are currently using in your script.
 
Last edited:
Solution
Your area consists of a single tile only ({x = 33636, y = 32226, z = 9, stackpos = 255} to {x = 33636, y = 32226, z = 9, stackpos = 255})
[Warning - Event::checkScript] Can not load script: scripts/Feyrist.lua
data/movements/scripts/Feyrist.lua:64: ')' expected near 'to'


I already removed ')'
 
I didn't say a thing about the room or its functionalities, it was regarding your error log/message: You removed a closing parenthesis which throws an error and the script cannot be read, therefore it won't work.
 
Your area consists of a single tile only ({x = 33636, y = 32226, z = 9, stackpos = 255} to {x = 33636, y = 32226, z = 9, stackpos = 255})

Edit:
The part in the brackets is not actually supposed to be code which you can use. It is simply the area you are currently using in your script.
I found the solution ..

making him check the entire room and preventing another player from entering the room if she is busy.

if any player stays in the room stopped after a few minutes he is player out


Tks Summ and Itutorial
 
Back
Top