• 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 check 3 storage at same time

T

Tibia Demon

Guest
i try to check all the 3 storage here in same time. it only check 1.
i already add actionid to all grounds = 40490
i use cplayerpos later dont need to remove it.
Lua:
local storagechecker = MoveEvent()
storagechecker:type("stepin")

local actionId = 40490
local Storagetable = {
    [1] = {storage = 20115, cplayerpos = {x = 1011, y = 1012, z = 7}},
    [2] = {storage = 20116, cplayerpos = {x = 1012, y = 1014, z = 7}},
    [3] = {storage = 20117, cplayerpos = {x = 1014, y = 1013, z = 7}}
}

function storagechecker.onStepIn(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end
    for _, storages in ipairs(Storagetable) do
        if player:getStorageValue(storages.storage) == 1 then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "you have got your reward.")
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            player:teleportTo(fromPosition)
            return true
        end
    end
end

storagechecker:aid(actionId)
storagechecker:register()
 
Solution
keeps sending effect CONST_ME_MAGIC_GREEN too fast without stopping or tping player
if questConfig[index].requiredStandingTime > (os.mtime() - tileStandingPlayers[playerId].standingTime) then
I put a 3 second cooldown on the effect.
Lua:
local actionId = 40490

local tileStandingPlayers = {} -- will hold information about the players. [creatureId] = {standingTime = 0, tableIndex = 0}
local kickPosition = Position(1008, 1013, 7)
local questConfig = {
    {storage = 20115, requiredStandingTime = 1000, tilePosition = Position(1011, 1012, 7)}, -- requiredStandingTime is in milliseconds.
    {storage = 20116, requiredStandingTime = 2000, tilePosition = Position(1012, 1014, 7)},
    {storage = 20117, requiredStandingTime = 3000, tilePosition =...
it only check 1.
Its because you are breaking the loop with that return true inside the conditional

One way would be:
Lua:
for _, storages in ipairs(Storagetable) do
    if player:getStorageValue(storages.storage) ~= 1 then
        goto skip_reward
    end
end

player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "you have got your reward.")
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)

::skip_reward::
player:teleportTo(fromPosition)
 
Its because you are breaking the loop with that return true inside the conditional

One way would be:
Lua:
for _, storages in ipairs(Storagetable) do
    if player:getStorageValue(storages.storage) ~= 1 then
        goto skip_reward
    end
end

player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "you have got your reward.")
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)

::skip_reward::
player:teleportTo(fromPosition)
i tested like this and script go always to player:teleportTo(fromPosition) with storage or not
Lua:
local storagechecker = MoveEvent()
storagechecker:type("stepin")

local actionId = 4490
local Storagetable = {
    [1] = {storage = 20115, cplayerpos = {x = 1011, y = 1012, z = 7}},
    [2] = {storage = 20116, cplayerpos = {x = 1012, y = 1014, z = 7}},
    [3] = {storage = 20117, cplayerpos = {x = 1014, y = 1013, z = 7}}
}

function storagechecker.onStepIn(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end
    for _, storages in ipairs(Storagetable) do
        if player:getStorageValue(storages.storage) ~= 1 then
            goto skip_reward
        end
    end
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "you have got your reward.")
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)

    ::skip_reward::
    player:teleportTo(fromPosition)
    return true
end

storagechecker:aid(actionId)
storagechecker:register()
Lua:
local storagechecker = MoveEvent()
storagechecker:type("stepin")

local actionId = 4490
local Storagetable = {
    [1] = {storage = 20115, cplayerpos = {x = 1011, y = 1012, z = 7}},
    [2] = {storage = 20116, cplayerpos = {x = 1012, y = 1014, z = 7}},
    [3] = {storage = 20117, cplayerpos = {x = 1014, y = 1013, z = 7}}
}

function storagechecker.onStepIn(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end
    for _, storages in ipairs(Storagetable) do
        if player:getStorageValue(storages.storage) == 1 then
            goto skip_reward
        end
    end
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "you have got your reward.")
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)

    ::skip_reward::
    player:teleportTo(fromPosition)
    return true
end

storagechecker:aid(actionId)
storagechecker:register()
 
Last edited by a moderator:
Player must have all 3 storages with value 1, not sure if thats what you wanted?
yes if player have all 3 storages then it return him fromPosition and say you have got your reward
and yes value = 1
3 storages = reward storages so if player have it he claimed it before
 
Last edited by a moderator:
I dont know if my brain isnt working atm or I cannot simply understand you

?
Lua:
local storagechecker = MoveEvent()
storagechecker:type("stepin")

local Storagetable = {
    [40491] = {storage = 20115, cplayerpos = {x = 1011, y = 1012, z = 7}},
    [40492] = {storage = 20116, cplayerpos = {x = 1012, y = 1014, z = 7}},
    [40493] = {storage = 20117, cplayerpos = {x = 1014, y = 1013, z = 7}}
}

function storagechecker.onStepIn(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end

    local cfg = Storagetable[item:getActionId()]
    if player:getStorageValue(cfg.storage) == 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "you have got your reward.") -- Player already claimed the reward?
        return player:teleportTo(fromPosition)
    end

    player:teleportTo(cfg.cplayerpos) -- Reward Room?
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    return true
end

for aid, _ in pairs(Storagetable) do
    storagechecker:aid(aid)
end
storagechecker:register()

Aids: 40491-40493
 
Paste whatever actions u want into the areas with comment
Lua:
local storagechecker = MoveEvent()
storagechecker:type("stepin")

local actionId = 4490
local Storagetable = {
    [1] = {storage = 20115, cplayerpos = {x = 1011, y = 1012, z = 7}},
    [2] = {storage = 20116, cplayerpos = {x = 1012, y = 1014, z = 7}},
    [3] = {storage = 20117, cplayerpos = {x = 1014, y = 1013, z = 7}}
}

function storagechecker.onStepIn(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end
    local gotAllStorages = true
    for _, storages in ipairs(Storagetable) do
        if not player:getStorageValue(storages.storage) == 1 then
            gotAllStorages = false
        end
    end
    if gotAllStorages == false then
        --doesn't have all storage
    else
        --have all storage
    end
    return true
end

storagechecker:aid(actionId)
storagechecker:register()
 
I dont know if my brain isnt working atm or I cannot simply understand you

?
Lua:
local storagechecker = MoveEvent()
storagechecker:type("stepin")

local Storagetable = {
    [40491] = {storage = 20115, cplayerpos = {x = 1011, y = 1012, z = 7}},
    [40492] = {storage = 20116, cplayerpos = {x = 1012, y = 1014, z = 7}},
    [40493] = {storage = 20117, cplayerpos = {x = 1014, y = 1013, z = 7}}
}

function storagechecker.onStepIn(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end

    local cfg = Storagetable[item:getActionId()]
    if player:getStorageValue(cfg.storage) == 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "you have got your reward.") -- Player already claimed the reward?
        return player:teleportTo(fromPosition)
    end

    player:teleportTo(cfg.cplayerpos) -- Reward Room?
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    return true
end

for aid, _ in pairs(Storagetable) do
    storagechecker:aid(aid)
end
storagechecker:register()

Aids: 40491-40493
sorry for bad explain. i need to use 1 action id.
Paste whatever actions u want into the areas with comment
Lua:
local storagechecker = MoveEvent()
storagechecker:type("stepin")

local actionId = 4490
local Storagetable = {
    [1] = {storage = 20115, cplayerpos = {x = 1011, y = 1012, z = 7}},
    [2] = {storage = 20116, cplayerpos = {x = 1012, y = 1014, z = 7}},
    [3] = {storage = 20117, cplayerpos = {x = 1014, y = 1013, z = 7}}
}

function storagechecker.onStepIn(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end
    local gotAllStorages = true
    for _, storages in ipairs(Storagetable) do
        if not player:getStorageValue(storages.storage) == 1 then
            gotAllStorages = false
        end
    end
    if gotAllStorages == false then
        --doesn't have all storage
    else
        --have all storage
    end
    return true
end

storagechecker:aid(actionId)
storagechecker:register()
i pasted actions like this but it read wrong or i have made something wrong?
Lua:
local questnorthtp = MoveEvent()
questnorthtp:type("stepin")

local actionId = 40490
local QuestConfig = {
    [1000] = {storage = 20115, playerpos = {x = 1011, y = 1012, z = 7}},
    [2000] = {storage = 20116, playerpos = {x = 1012, y = 1014, z = 7}},
    [3000] = {storage = 20117, playerpos = {x = 1014, y = 1013, z = 7}}
}

local config = {
    kickPosition = {x = 1008, y = 1013, z = 7}
}

function questnorthtp.onStepIn(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end
    local gotAllStorages = true
    for _, tablestorage in ipairs(QuestConfig) do
        if player:getStorageValue(tablestorage.storage) == 1 then
            gotAllStorages = false
        end
    end
    if gotAllStorages == false then
        for v, k in pairs(QuestConfig) do
            if position:isInRange(k.playerpos, k.playerpos) then
                if player:getStorageValue(k.storage) == 1 then
                    player:getPosition():sendMagicEffect(CONST_ME_POFF)
                    player:teleportTo(fromPosition)
                    return true
                end
            end
            config.kickEventFourId =
                addEvent(
                function(playerId)
                    local StandPlayer = Player(playerId)
                    if not StandPlayer or not StandPlayer:isPlayer() then
                        return nil
                    end
                    if StandPlayer then
                        local StandPlayerPosition = StandPlayer:getPosition()
                        if StandPlayerPosition:isInRange(k.playerpos, k.playerpos) then
                            StandPlayer:setStorageValue(k.storage, 1)
                            StandPlayerPosition:sendMagicEffect(CONST_ME_TELEPORT)
                            StandPlayer:teleportTo(config.kickPosition)
                            StandPlayer:getPosition():sendMagicEffect(CONST_ME_HITAREA)
                        end
                    end
                end,
                v * 1000,
                player:getId()
            )
        end
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "you have done all the tiles.")
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        player:teleportTo(fromPosition)
    end
    return true
end

questnorthtp:aid(actionId)
questnorthtp:register()
 
sorry i forgot [not] in script up this last script i am trying now but not working i try exchange lines order of this check
for _, tablestorage in ipairs(QuestConfig) do
with this all their check lines
script always go to [else lines] even with 0 storages it read that i have all storages
for v, k in pairs(QuestConfig) do

Lua:
local questnorthtp = MoveEvent()
questnorthtp:type("stepin")

local actionId = 40490
local QuestConfig = {
    [1000] = {storage = 20115, playerpos = {x = 1011, y = 1012, z = 7}},
    [2000] = {storage = 20116, playerpos = {x = 1012, y = 1014, z = 7}},
    [3000] = {storage = 20117, playerpos = {x = 1014, y = 1013, z = 7}}
}

local config = {
    kickPosition = {x = 1008, y = 1013, z = 7}
}

function questnorthtp.onStepIn(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end
    local gotAllStorages = true
    for _, tablestorage in ipairs(QuestConfig) do
        if not player:getStorageValue(tablestorage.storage) == 1 then
            gotAllStorages = false
        end
    end
    if gotAllStorages == false then
        for v, k in pairs(QuestConfig) do
            if position:isInRange(k.playerpos, k.playerpos) then
                if player:getStorageValue(k.storage) == 1 then
                    player:getPosition():sendMagicEffect(CONST_ME_POFF)
                    player:teleportTo(fromPosition)
                    return true
                end
            end
            config.kickEventFourId =
                addEvent(
                function(playerId)
                    local StandPlayer = Player(playerId)
                    if not StandPlayer or not StandPlayer:isPlayer() then
                        return nil
                    end
                    if StandPlayer then
                        local StandPlayerPosition = StandPlayer:getPosition()
                        if StandPlayerPosition:isInRange(k.playerpos, k.playerpos) then
                            StandPlayer:setStorageValue(k.storage, 1)
                            StandPlayerPosition:sendMagicEffect(CONST_ME_TELEPORT)
                            StandPlayer:teleportTo(config.kickPosition)
                            StandPlayer:getPosition():sendMagicEffect(CONST_ME_HITAREA)
                        end
                    end
                end,
                v * 1000,
                player:getId()
            )
        end
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "you have done all the tiles.")
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        player:teleportTo(fromPosition)
    end
    return true
end

questnorthtp:aid(actionId)
questnorthtp:register()
Post automatically merged:

it always think i have all storages local gotAllStorages = true
Post automatically merged:

i tried to make like this too and no work
Lua:
local questnorthtp = MoveEvent()
questnorthtp:type("stepin")

local actionId = 40490
local QuestConfig = {
    [1000] = {storage = 20115, playerpos = {x = 1011, y = 1012, z = 7}},
    [2000] = {storage = 20116, playerpos = {x = 1012, y = 1014, z = 7}},
    [3000] = {storage = 20117, playerpos = {x = 1014, y = 1013, z = 7}}
}

local config = {
    kickPosition = {x = 1008, y = 1013, z = 7}
}

function questnorthtp.onStepIn(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end
    local gotAllStorages = true
    for _, tablestorage in ipairs(QuestConfig) do
        if not player:getStorageValue(tablestorage.storage) == 1 then
            gotAllStorages = false
        end
    end
    if gotAllStorages == true then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "you have done all the tiles.")
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        player:teleportTo(fromPosition)
        return true
    end
    if gotAllStorages == false then
        for v, k in pairs(QuestConfig) do
            if position:isInRange(k.playerpos, k.playerpos) then
                if player:getStorageValue(k.storage) == 1 then
                    player:getPosition():sendMagicEffect(CONST_ME_POFF)
                    player:teleportTo(fromPosition)
                    return true
                end
            end
            config.kickEventFourId =
                addEvent(
                function(playerId)
                    local StandPlayer = Player(playerId)
                    if not StandPlayer or not StandPlayer:isPlayer() then
                        return nil
                    end
                    if StandPlayer then
                        local StandPlayerPosition = StandPlayer:getPosition()
                        if StandPlayerPosition:isInRange(k.playerpos, k.playerpos) then
                            StandPlayer:setStorageValue(k.storage, 1)
                            StandPlayerPosition:sendMagicEffect(CONST_ME_TELEPORT)
                            StandPlayer:teleportTo(config.kickPosition)
                            StandPlayer:getPosition():sendMagicEffect(CONST_ME_HITAREA)
                        end
                    end
                end,
                v * 1000,
                player:getId()
            )
        end
    end
    return true
end

questnorthtp:aid(actionId)
questnorthtp:register()
 
Last edited by a moderator:
any idea? i only need to know why this part dont work correct.
i tried adding all this ways to up script but still fail. can someone add any working method to up script or see if i added it wrong? [only way i didn't try is many aids because i need to use 1 aid]
Lua:
local gotAllStorages = true

for _, tablestorage in ipairs(QuestConfig) do
    if not player:getStorageValue(tablestorage.storage) == 1 then
        gotAllStorages = false
    end
end

if gotAllStorages == true then
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "you have done all the tiles.")

    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)

    player:teleportTo(fromPosition)

    return true
end

if gotAllStorages == false then
Lua:
local gotAllStorages = true

for _, storages in ipairs(Storagetable) do
    if not player:getStorageValue(storages.storage) == 1 then
        gotAllStorages = false
    end
end

if gotAllStorages == false then
    --doesn't have all storage
else
    --have all storage
end
Lua:
for _, tablestorage in ipairs(QuestConfig) do
    if player:getStorageValue(tablestorage.storage) == 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "you have done all the tiles.")

        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)

        player:teleportTo(fromPosition)

        return true
    end
end
Lua:
for _, tablestorage in ipairs(QuestConfig) do
    if player:getStorageValue(tablestorage.storage) == 1 then
        goto skip_reward
    end
end

::skip_reward::

player:teleportTo(fromPosition)

player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "you have done all the tiles.")

player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
 
ok i will try explaining better. if something you don't understand tell me i explain again.
first i need to make 10 tiles around the map in different places when 1 player stand on each tile [with different tile times and xyz] he get this tile storage [time and pos and storage all in the table for all tiles]. i made this here and it work.
Lua:
config.kickEventFourId =
    addEvent(
    function(playerId)
        local StandPlayer = Player(playerId)
        if not StandPlayer or not StandPlayer:isPlayer() then
            return nil
        end
        if StandPlayer then
            local StandPlayerPosition = StandPlayer:getPosition()
            if StandPlayerPosition:isInRange(k.playerpos, k.playerpos) then
                StandPlayer:setStorageValue(k.storage, 1)
                StandPlayerPosition:sendMagicEffect(CONST_ME_TELEPORT)
                StandPlayer:teleportTo(config.kickPosition)
                StandPlayer:getPosition():sendMagicEffect(CONST_ME_HITAREA)
            end
        end
    end,
    v * 1000,
    player:getId()
)
second. i need when player go step in 1 tile he already done and he got it is storage it check him and return fromPosition. later i add message. i made this too and it work.
Lua:
for v, k in pairs(QuestConfig) do
    if position:isInRange(k.playerpos, k.playerpos) then
        if player:getStorageValue(k.storage) == 1 then
            player:getPosition():sendMagicEffect(CONST_ME_POFF)
            player:teleportTo(fromPosition)
            return true
        end
    end
end
third. which i cant make is. i want when player go step in 1 tile and he got this tile and all other tile storages the 10 tiles it check him and return fromPosition and say he have done all tiles so player stop searching for tiles again.
so the script work until this and all i want is to add 1 check to this script if player got all storages it do return him with a message.
Lua:
local questnorthtp = MoveEvent()
questnorthtp:type("stepin")

local actionId = 40490
local QuestConfig = {
    [1000] = {storage = 20115, playerpos = {x = 1011, y = 1012, z = 7}},
    [2000] = {storage = 20116, playerpos = {x = 1012, y = 1014, z = 7}},
    [3000] = {storage = 20117, playerpos = {x = 1014, y = 1013, z = 7}}
}

local config = {
    kickPosition = {x = 1008, y = 1013, z = 7}
}

function questnorthtp.onStepIn(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end
    for v, k in pairs(QuestConfig) do
        if position:isInRange(k.playerpos, k.playerpos) then
            if player:getStorageValue(k.storage) == 1 then
                player:getPosition():sendMagicEffect(CONST_ME_POFF)
                player:teleportTo(fromPosition)
                return true
            end
        end
        config.kickEventFourId =
            addEvent(
            function(playerId)
                local StandPlayer = Player(playerId)
                if not StandPlayer or not StandPlayer:isPlayer() then
                    return nil
                end
                if StandPlayer then
                    local StandPlayerPosition = StandPlayer:getPosition()
                    if StandPlayerPosition:isInRange(k.playerpos, k.playerpos) then
                        StandPlayer:setStorageValue(k.storage, 1)
                        StandPlayerPosition:sendMagicEffect(CONST_ME_TELEPORT)
                        StandPlayer:teleportTo(config.kickPosition)
                        StandPlayer:getPosition():sendMagicEffect(CONST_ME_HITAREA)
                    end
                end
            end,
            v * 1000,
            player:getId()
        )
    end
    return true
end

questnorthtp:aid(actionId)
questnorthtp:register()
all used tiles on map have the action id local actionId = 40490
and this kickPosition is to stop player blocking 1 tile.
 
Check this
Lua:
local storagechecker = MoveEvent()
storagechecker:type("stepin")

local actionId = 4490
local config = {
    [1] = {storage = 20115, pos = {x = 1011, y = 1012, z = 7}},
    [2] = {storage = 20116, pos = {x = 1012, y = 1014, z = 7}},
    [3] = {storage = 20117, pos = {x = 1014, y = 1013, z = 7}}
}

function storagechecker.onStepIn(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end
    
    local ppos = player:getPosition()
    local gotAllStorages = true
    for _, tiles in ipairs(config) do
        if ppos.x == tiles.pos.x and ppos.y == tiles.pos.y and ppos.z == tiles.pos.z then
            if not player:getStorageValue(tiles.storage) == 1 then
                player:setStorageValue(tiles.storage, 1)
                --actions when player gets new tile
            end
        end
        if not player:getStorageValue(tiles.storage) == 1 then
            gotAllStorages = false
        end
    end
    if gotAllStorages then
        --actions when player have all tiles
        player:teleportTo(fromPosition)
    end
    return true
end

storagechecker:aid(actionId)
storagechecker:register()
 
Check this
Lua:
local storagechecker = MoveEvent()
storagechecker:type("stepin")

local actionId = 4490
local config = {
    [1] = {storage = 20115, pos = {x = 1011, y = 1012, z = 7}},
    [2] = {storage = 20116, pos = {x = 1012, y = 1014, z = 7}},
    [3] = {storage = 20117, pos = {x = 1014, y = 1013, z = 7}}
}

function storagechecker.onStepIn(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end
  
    local ppos = player:getPosition()
    local gotAllStorages = true
    for _, tiles in ipairs(config) do
        if ppos.x == tiles.pos.x and ppos.y == tiles.pos.y and ppos.z == tiles.pos.z then
            if not player:getStorageValue(tiles.storage) == 1 then
                player:setStorageValue(tiles.storage, 1)
                --actions when player gets new tile
            end
        end
        if not player:getStorageValue(tiles.storage) == 1 then
            gotAllStorages = false
        end
    end
    if gotAllStorages then
        --actions when player have all tiles
        player:teleportTo(fromPosition)
    end
    return true
end

storagechecker:aid(actionId)
storagechecker:register()
Good effort, but there is a crucial part he needs.

"standing time on tile" which is different for each tile.

He was putting it in as the index for some reason, which is why it was hard to see.

I suggest this, instead
Lua:
local actionId = 40490

local tileStandingPlayers = {} -- will hold information about the players. [creatureId] = {standingTime = 0, tableIndex = 0}
local kickPosition = Position(1008, 1013, 7)
local questConfig = {
    {storage = 20115, requiredStandingTime = 1000, tilePosition = Position(1011, 1012, z = 7)}, -- requiredStandingTime is in milliseconds.
    {storage = 20116, requiredStandingTime = 2000, tilePosition = Position(1012, 1014, z = 7)},
    {storage = 20117, requiredStandingTime = 3000, tilePosition = Position(1014, 1013, z = 7)}
}


local function tileChecker(playerId, startedTime)
    -- recreate the player, to ensure they still exist
    local player = Player(playerId)
    if not player then
        return
    end
   
    -- check if table has been reset.
    if not tileStandingPlayers[playerId] or startedTime ~= tileStandingPlayers[playerId].standingTime then
        return
    end
   
    -- check if player has left the tile location
    local index = tileStandingPlayers[playerId].tableIndex   
    if index.tilePosition ~= player:getPosition() then
        return
    end
   
    -- check if time has elapsed
    local index = tileStandingPlayers[playerId].tableIndex   
    local currentTime = os.mtime()
    if questConfig[index].requiredStandingTime < (os.mtime() - tileStandingPlayers[playerId].standingTime) then
        -- if not enough time has elapsed, then loop function
        questConfig[index].tilePosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
        addEvent(tileChecker, 250, playerId, startedTime)
        return
    end
   
   
    -- enough time has elapsed, so give storage and teleport player off the tile
    player:setStorageValue(questConfig[index].storage, 1)
    questConfig[index].tilePosition:sendMagicEffect(CONST_ME_TELEPORT)
    player:teleportTo(kickPosition)
    kickPosition:sendMagicEffect(CONST_ME_HITAREA)
   
    -- and finally, let's clean up the table.
    tileStandingPlayers[playerId] = nil
   
    -- while we're at it, let's tell the player if they have completed all the tiles
    for v, k in pairs(questConfig) do
        if player:getStorageValue(k.storage) ~= 1 then
            player:say("There's still some more tiles to go!", TALKTYPE_MONSTER_SAY)
            return
        end
    end
    player:say("You've completed all of the tiles!", TALKTYPE_MONSTER_SAY)
end




local StepIn_questnorthtp = MoveEvent()
StepIn_questnorthtp:type("stepin")

function StepIn_questnorthtp.onStepIn(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end
   
    local hasAllStorages = true
   
    -- loop through table
    for v, k in pairs(questConfig) do
        -- find the current tile
        if position == k.tilePosition then
            -- check if player has this storage
            if player:getStorageValue(k.storage) ~= 1 then
                -- if the player doesn't have this storage, then start the timer, and allow player onto the tile.
                local currentTime = os.mtime()
                local playerId = player:getId()
                tileStandingPlayers[playerId] = {standingTime = currentTime, tableIndex = v}
                addEvent(tileChecker, 250, playerId, currentTime)
                return true -- since we want the player to stay on the tile, we break the loop here, as there is no point in checking the rest of the positions.
            end
        end
       
        -- regardless of tile, let's check if they've completed all the tiles
        if player:getStorageValue(k.storage) ~= 1 then
            hasAllStorages = false
        end
    end
   
    -- if the script get's here, we know the player already has this tile's storage, so we can teleport them
    player:teleportTo(fromPosition)
   
    -- and here we give the player information about the tiles
    if hasAllStorages then
        player:say("You've completed all of the tiles!", TALKTYPE_MONSTER_SAY)
    else
        player:say("You've completed this tile already. There's still some more tiles to go!", TALKTYPE_MONSTER_SAY)
    end
    return true
end

StepIn_questnorthtp:aid(actionId)
StepIn_questnorthtp:register()
 
Check this
Lua:
local storagechecker = MoveEvent()
storagechecker:type("stepin")

local actionId = 4490
local config = {
    [1] = {storage = 20115, pos = {x = 1011, y = 1012, z = 7}},
    [2] = {storage = 20116, pos = {x = 1012, y = 1014, z = 7}},
    [3] = {storage = 20117, pos = {x = 1014, y = 1013, z = 7}}
}

function storagechecker.onStepIn(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end
 
    local ppos = player:getPosition()
    local gotAllStorages = true
    for _, tiles in ipairs(config) do
        if ppos.x == tiles.pos.x and ppos.y == tiles.pos.y and ppos.z == tiles.pos.z then
            if not player:getStorageValue(tiles.storage) == 1 then
                player:setStorageValue(tiles.storage, 1)
                --actions when player gets new tile
            end
        end
        if not player:getStorageValue(tiles.storage) == 1 then
            gotAllStorages = false
        end
    end
    if gotAllStorages then
        --actions when player have all tiles
        player:teleportTo(fromPosition)
    end
    return true
end

storagechecker:aid(actionId)
storagechecker:register()
sorry but this change some of requirements in the script. its not how i wanted sorry if my bad explaining cause this.
Good effort, but there is a crucial part he needs.

"standing time on tile" which is different for each tile.

He was putting it in as the index for some reason, which is why it was hard to see.

I suggest this, instead
Lua:
local actionId = 40490

local tileStandingPlayers = {} -- will hold information about the players. [creatureId] = {standingTime = 0, tableIndex = 0}
local kickPosition = Position(1008, 1013, 7)
local questConfig = {
    {storage = 20115, requiredStandingTime = 1000, tilePosition = Position(1011, 1012, z = 7)}, -- requiredStandingTime is in milliseconds.
    {storage = 20116, requiredStandingTime = 2000, tilePosition = Position(1012, 1014, z = 7)},
    {storage = 20117, requiredStandingTime = 3000, tilePosition = Position(1014, 1013, z = 7)}
}


local function tileChecker(playerId, startedTime)
    -- recreate the player, to ensure they still exist
    local player = Player(playerId)
    if not player then
        return
    end
 
    -- check if table has been reset.
    if not tileStandingPlayers[playerId] or startedTime ~= tileStandingPlayers[playerId].standingTime then
        return
    end
 
    -- check if player has left the tile location
    local index = tileStandingPlayers[playerId].tableIndex
    if index.tilePosition ~= player:getPosition() then
        return
    end
 
    -- check if time has elapsed
    local index = tileStandingPlayers[playerId].tableIndex
    local currentTime = os.mtime()
    if questConfig[index].requiredStandingTime < (os.mtime() - tileStandingPlayers[playerId].standingTime) then
        -- if not enough time has elapsed, then loop function
        questConfig[index].tilePosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
        addEvent(tileChecker, 250, playerId, startedTime)
        return
    end
 
 
    -- enough time has elapsed, so give storage and teleport player off the tile
    player:setStorageValue(questConfig[index].storage, 1)
    questConfig[index].tilePosition:sendMagicEffect(CONST_ME_TELEPORT)
    player:teleportTo(kickPosition)
    kickPosition:sendMagicEffect(CONST_ME_HITAREA)
 
    -- and finally, let's clean up the table.
    tileStandingPlayers[playerId] = nil
 
    -- while we're at it, let's tell the player if they have completed all the tiles
    for v, k in pairs(questConfig) do
        if player:getStorageValue(k.storage) ~= 1 then
            player:say("There's still some more tiles to go!", TALKTYPE_MONSTER_SAY)
            return
        end
    end
    player:say("You've completed all of the tiles!", TALKTYPE_MONSTER_SAY)
end




local StepIn_questnorthtp = MoveEvent()
StepIn_questnorthtp:type("stepin")

function StepIn_questnorthtp.onStepIn(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end
 
    local hasAllStorages = true
 
    -- loop through table
    for v, k in pairs(questConfig) do
        -- find the current tile
        if position == k.tilePosition then
            -- check if player has this storage
            if player:getStorageValue(k.storage) ~= 1 then
                -- if the player doesn't have this storage, then start the timer, and allow player onto the tile.
                local currentTime = os.mtime()
                local playerId = player:getId()
                tileStandingPlayers[playerId] = {standingTime = currentTime, tableIndex = v}
                addEvent(tileChecker, 250, playerId, currentTime)
                return true -- since we want the player to stay on the tile, we break the loop here, as there is no point in checking the rest of the positions.
            end
        end
    
        -- regardless of tile, let's check if they've completed all the tiles
        if player:getStorageValue(k.storage) ~= 1 then
            hasAllStorages = false
        end
    end
 
    -- if the script get's here, we know the player already has this tile's storage, so we can teleport them
    player:teleportTo(fromPosition)
 
    -- and here we give the player information about the tiles
    if hasAllStorages then
        player:say("You've completed all of the tiles!", TALKTYPE_MONSTER_SAY)
    else
        player:say("You've completed this tile already. There's still some more tiles to go!", TALKTYPE_MONSTER_SAY)
    end
    return true
end

StepIn_questnorthtp:aid(actionId)
StepIn_questnorthtp:register()
i copied script like it is and only changed this here tilePosition = Position(1011, 1012, z = 7) to tilePosition = {x = 1011, y = 1012, z = 7} because had error.
Code:
first error was lua:6: ')' expected near '=' so i remove z =

and then second error come lua:26: attempt to index local 'index' (a number value) that is why i changed.

and i added tiles in map with aid 40490
i try with new player 0 storage and it say [You've completed this tile already. There's still some more tiles to go!] and return fromPosition
i have completed 0 tile and i cant go in any tile.
 
sorry but this change some of requirements in the script. its not how i wanted sorry if my bad explaining cause this.

i copied script like it is and only changed this here tilePosition = Position(1011, 1012, z = 7) to tilePosition = {x = 1011, y = 1012, z = 7} because had error.
Code:
first error was lua:6: ')' expected near '=' so i remove z =

and then second error come lua:26: attempt to index local 'index' (a number value) that is why i changed.

and i added tiles in map with aid 40490
i try with new player 0 storage and it say [You've completed this tile already. There's still some more tiles to go!] and return fromPosition
i have completed 0 tile and i cant go in any tile.

Fixed both issues.

try again
Lua:
local actionId = 40490

local tileStandingPlayers = {} -- will hold information about the players. [creatureId] = {standingTime = 0, tableIndex = 0}
local kickPosition = Position(1008, 1013, 7)
local questConfig = {
    {storage = 20115, requiredStandingTime = 1000, tilePosition = Position(1011, 1012, 7)}, -- requiredStandingTime is in milliseconds.
    {storage = 20116, requiredStandingTime = 2000, tilePosition = Position(1012, 1014, 7)},
    {storage = 20117, requiredStandingTime = 3000, tilePosition = Position(1014, 1013, 7)}
}


local function tileChecker(playerId, startedTime)
    -- recreate the player, to ensure they still exist
    local player = Player(playerId)
    if not player then
        return
    end
    
    -- check if table has been reset.
    if not tileStandingPlayers[playerId] or startedTime ~= tileStandingPlayers[playerId].standingTime then
        return
    end
    
    -- check if player has left the tile location
    local index = tileStandingPlayers[playerId].tableIndex   
    if questConfig[index].tilePosition ~= player:getPosition() then
        return
    end
    
    -- check if time has elapsed 
    local currentTime = os.mtime()
    if questConfig[index].requiredStandingTime < (os.mtime() - tileStandingPlayers[playerId].standingTime) then
        -- if not enough time has elapsed, then loop function
        questConfig[index].tilePosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
        addEvent(tileChecker, 250, playerId, startedTime)
        return
    end
    
    
    -- enough time has elapsed, so give storage and teleport player off the tile
    player:setStorageValue(questConfig[index].storage, 1)
    questConfig[index].tilePosition:sendMagicEffect(CONST_ME_TELEPORT)
    player:teleportTo(kickPosition)
    kickPosition:sendMagicEffect(CONST_ME_HITAREA)
    
    -- and finally, let's clean up the table.
    tileStandingPlayers[playerId] = nil
    
    -- while we're at it, let's tell the player if they have completed all the tiles
    for v, k in pairs(questConfig) do
        if player:getStorageValue(k.storage) ~= 1 then
            player:say("There's still some more tiles to go!", TALKTYPE_MONSTER_SAY)
            return
        end
    end
    player:say("You've completed all of the tiles!", TALKTYPE_MONSTER_SAY)
end




local StepIn_questnorthtp = MoveEvent()
StepIn_questnorthtp:type("stepin")

function StepIn_questnorthtp.onStepIn(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end
    
    local hasAllStorages = true
    
    -- loop through table
    for v, k in pairs(questConfig) do
        -- find the current tile
        if position == k.tilePosition then
            -- check if player has this storage
            if player:getStorageValue(k.storage) ~= 1 then
                -- if the player doesn't have this storage, then start the timer, and allow player onto the tile.
                local currentTime = os.mtime()
                local playerId = player:getId()
                tileStandingPlayers[playerId] = {standingTime = currentTime, tableIndex = v}
                addEvent(tileChecker, 250, playerId, currentTime)
                return true -- since we want the player to stay on the tile, we break the loop here, as there is no point in checking the rest of the positions.
            end
        end
    
        -- regardless of tile, let's check if they've completed all the tiles
        if player:getStorageValue(k.storage) ~= 1 then
            hasAllStorages = false
        end
    end
    
    -- if the script get's here, we know the player already has this tile's storage, so we can teleport them
    player:teleportTo(fromPosition)
    
    -- and here we give the player information about the tiles
    if hasAllStorages then
        player:say("You've completed all of the tiles!", TALKTYPE_MONSTER_SAY)
    else
        player:say("You've completed this tile already. There's still some more tiles to go!", TALKTYPE_MONSTER_SAY)
    end
    return true
end

StepIn_questnorthtp:aid(actionId)
StepIn_questnorthtp:register()
 
Fixed both issues.

try again
Lua:
local actionId = 40490

local tileStandingPlayers = {} -- will hold information about the players. [creatureId] = {standingTime = 0, tableIndex = 0}
local kickPosition = Position(1008, 1013, 7)
local questConfig = {
    {storage = 20115, requiredStandingTime = 1000, tilePosition = Position(1011, 1012, 7)}, -- requiredStandingTime is in milliseconds.
    {storage = 20116, requiredStandingTime = 2000, tilePosition = Position(1012, 1014, 7)},
    {storage = 20117, requiredStandingTime = 3000, tilePosition = Position(1014, 1013, 7)}
}


local function tileChecker(playerId, startedTime)
    -- recreate the player, to ensure they still exist
    local player = Player(playerId)
    if not player then
        return
    end
   
    -- check if table has been reset.
    if not tileStandingPlayers[playerId] or startedTime ~= tileStandingPlayers[playerId].standingTime then
        return
    end
   
    -- check if player has left the tile location
    local index = tileStandingPlayers[playerId].tableIndex  
    if questConfig[index].tilePosition ~= player:getPosition() then
        return
    end
   
    -- check if time has elapsed
    local currentTime = os.mtime()
    if questConfig[index].requiredStandingTime < (os.mtime() - tileStandingPlayers[playerId].standingTime) then
        -- if not enough time has elapsed, then loop function
        questConfig[index].tilePosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
        addEvent(tileChecker, 250, playerId, startedTime)
        return
    end
   
   
    -- enough time has elapsed, so give storage and teleport player off the tile
    player:setStorageValue(questConfig[index].storage, 1)
    questConfig[index].tilePosition:sendMagicEffect(CONST_ME_TELEPORT)
    player:teleportTo(kickPosition)
    kickPosition:sendMagicEffect(CONST_ME_HITAREA)
   
    -- and finally, let's clean up the table.
    tileStandingPlayers[playerId] = nil
   
    -- while we're at it, let's tell the player if they have completed all the tiles
    for v, k in pairs(questConfig) do
        if player:getStorageValue(k.storage) ~= 1 then
            player:say("There's still some more tiles to go!", TALKTYPE_MONSTER_SAY)
            return
        end
    end
    player:say("You've completed all of the tiles!", TALKTYPE_MONSTER_SAY)
end




local StepIn_questnorthtp = MoveEvent()
StepIn_questnorthtp:type("stepin")

function StepIn_questnorthtp.onStepIn(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end
   
    local hasAllStorages = true
   
    -- loop through table
    for v, k in pairs(questConfig) do
        -- find the current tile
        if position == k.tilePosition then
            -- check if player has this storage
            if player:getStorageValue(k.storage) ~= 1 then
                -- if the player doesn't have this storage, then start the timer, and allow player onto the tile.
                local currentTime = os.mtime()
                local playerId = player:getId()
                tileStandingPlayers[playerId] = {standingTime = currentTime, tableIndex = v}
                addEvent(tileChecker, 250, playerId, currentTime)
                return true -- since we want the player to stay on the tile, we break the loop here, as there is no point in checking the rest of the positions.
            end
        end
   
        -- regardless of tile, let's check if they've completed all the tiles
        if player:getStorageValue(k.storage) ~= 1 then
            hasAllStorages = false
        end
    end
   
    -- if the script get's here, we know the player already has this tile's storage, so we can teleport them
    player:teleportTo(fromPosition)
   
    -- and here we give the player information about the tiles
    if hasAllStorages then
        player:say("You've completed all of the tiles!", TALKTYPE_MONSTER_SAY)
    else
        player:say("You've completed this tile already. There's still some more tiles to go!", TALKTYPE_MONSTER_SAY)
    end
    return true
end

StepIn_questnorthtp:aid(actionId)
StepIn_questnorthtp:register()
working now but i changed to this requiredStandingTime = 20000 and it tp player after 0.5 second not 20 second
 
working now but i changed to this requiredStandingTime = 20000 and it tp player after 0.5 second not 20 second
Added some prints. Let me know what prints to console.

Lua:
local function tileChecker(playerId, startedTime)
    -- recreate the player, to ensure they still exist
    local player = Player(playerId)
    if not player then
        return
    end
    
    -- check if table has been reset.
    if not tileStandingPlayers[playerId] or startedTime ~= tileStandingPlayers[playerId].standingTime then
        return
    end
    
    -- check if player has left the tile location
    local index = tileStandingPlayers[playerId].tableIndex   
    if questConfig[index].tilePosition ~= player:getPosition() then
        return
    end
    
    -- check if time has elapsed
    print("requiredStandingTime: " .. questConfig[index].requiredStandingTime)
    print("elapsedTime: " .. (os.mtime() - tileStandingPlayers[playerId].standingTime))
    if questConfig[index].requiredStandingTime < (os.mtime() - tileStandingPlayers[playerId].standingTime) then
        -- if not enough time has elapsed, then loop function
        questConfig[index].tilePosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
        addEvent(tileChecker, 250, playerId, startedTime)
        return
    end
    
    
    -- enough time has elapsed, so give storage and teleport player off the tile
    player:setStorageValue(questConfig[index].storage, 1)
    questConfig[index].tilePosition:sendMagicEffect(CONST_ME_TELEPORT)
    player:teleportTo(kickPosition)
    kickPosition:sendMagicEffect(CONST_ME_HITAREA)
    
    -- and finally, let's clean up the table.
    tileStandingPlayers[playerId] = nil
    
    -- while we're at it, let's tell the player if they have completed all the tiles
    for v, k in pairs(questConfig) do
        if player:getStorageValue(k.storage) ~= 1 then
            player:say("There's still some more tiles to go!", TALKTYPE_MONSTER_SAY)
            return
        end
    end
    player:say("You've completed all of the tiles!", TALKTYPE_MONSTER_SAY)
end
 
Back
Top