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

TFS 1.X+ on step in area

T

Tibia Demon

Guest
i try to fix this script to add storage to player when he step any tile in fromposition toposition area but i cant make the table and i need to check if player has obtained the storage then dont do anything.
i need to make it in like 10 fromposition toposition ranges but i am bad with tables. no need to make 10 script.
Lua:
local QuestStorage = MoveEvent()
QuestStorage:type("stepin")

local config = {
    ['queststorageone'] = {
        fromPositionArea = Position(994, 992, 7), -- fromPosition
        toPositionArea = Position(998, 997, 7), -- toPosition
        Mystorage = 'PlayerStorageKeys.queststorageone'
    },
    ['queststoragetwo'] = {
        fromPositionArea = Position(1006, 992, 7), -- fromPosition
        toPositionArea = Position(1009, 997, 7), -- toPosition
        Mystorage = 'PlayerStorageKeys.queststoragetwo'
    },
}

function QuestStorage.onStepIn(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end   
    if player:getPosition():isInRange(config.fromPositionArea, config.toPositionArea) then
    player:setStorageValue(config.Mystorage, 1)
    end
        return true
end
QuestStorage:register()
or i should add actionid to all tiles fromposition toposition?
 
Last edited by a moderator:
Solution
Very similar to your other thread, but this only requires a single actionId, placed on every tile.

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

local actionId = 111111
local config = {
    ['queststorageone'] = {
        fromPositionArea = Position(994, 992, 7), -- fromPosition
        toPositionArea = Position(998, 997, 7), -- toPosition
        Mystorage = 'PlayerStorageKeys.queststorageone'
    },
    ['queststoragetwo'] = {
        fromPositionArea = Position(1006, 992, 7), -- fromPosition
        toPositionArea = Position(1009, 997, 7), -- toPosition
        Mystorage = 'PlayerStorageKeys.queststoragetwo'
    },
}

function QuestStorage.onStepIn(player, item, position, fromPosition)
    if not player or...
Very similar to your other thread, but this only requires a single actionId, placed on every tile.

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

local actionId = 111111
local config = {
    ['queststorageone'] = {
        fromPositionArea = Position(994, 992, 7), -- fromPosition
        toPositionArea = Position(998, 997, 7), -- toPosition
        Mystorage = 'PlayerStorageKeys.queststorageone'
    },
    ['queststoragetwo'] = {
        fromPositionArea = Position(1006, 992, 7), -- fromPosition
        toPositionArea = Position(1009, 997, 7), -- toPosition
        Mystorage = 'PlayerStorageKeys.queststoragetwo'
    },
}

function QuestStorage.onStepIn(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end
    for v, k in pairs(config) do
        if position:isInRange(k.fromPositionArea, k.toPositionArea) then
            if player:getStorageValue(k.Mystorage) ~= 1 then
                player:setStorageValue(k.Mystorage, 1)
            end
            return true
        end
    end
    return true
end

QuestStorage:aid(actionId)
QuestStorage:register()
 
Solution
i tested everything good but it add wrong storage to player always add storage 0
i add storages to table in lib and i checked they are there and tested same storages in other script.
 
i tested everything good but it add wrong storage to player always add storage 0
i add storages to table in lib and i checked they are there and tested same storages in other script.
If something is not working, add prints. :)

Like this, then test, and check the console.

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

local actionId = 111111
local config = {
    ['queststorageone'] = {
        fromPositionArea = Position(994, 992, 7), -- fromPosition
        toPositionArea = Position(998, 997, 7), -- toPosition
        Mystorage = 'PlayerStorageKeys.queststorageone'
    },
    ['queststoragetwo'] = {
        fromPositionArea = Position(1006, 992, 7), -- fromPosition
        toPositionArea = Position(1009, 997, 7), -- toPosition
        Mystorage = 'PlayerStorageKeys.queststoragetwo'
    },
}

function QuestStorage.onStepIn(player, item, position, fromPosition)
    if not player or player:isInGhostMode() then
        return true
    end
    for v, k in pairs(config) do
        print("----")
        print("checking -> " .. v)
        if position:isInRange(k.fromPositionArea, k.toPositionArea) then
            print("In range.")
            print("checking storage -> " .. k.Mystorage)
            print("current value -> " .. player:getStorageValue(k.Mystorage))
            if player:getStorageValue(k.Mystorage) ~= 1 then
                player:setStorageValue(k.Mystorage, 1)
            end
            return true
        end
        print("Not in range.")
    end
    return true
end

QuestStorage:aid(actionId)
QuestStorage:register()

My guess is that you are checking a string instead of the storage number you set in your global table.
Mystorage = 'PlayerStorageKeys.queststorageone'

I imagine you need to change it to this
Mystorage = PlayerStorageKeys.queststorageone
 
Back
Top