• 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+ Use gate of experience door to teleport in.

Alkenyx

Member
Joined
Jun 6, 2014
Messages
97
Solutions
1
Reaction score
16
Location
Germany
Hello Community.

Today my brain seems to be lagging or so cuz I can't figure out how to make it possible to:
1. Right click gate of experience (id: 5103).
2. You'll get teleported behind it (into the room).
1643052900991.png
3. Sparkles brilliant script will kick the player out when their bought time is up. :)

So all I need is an action ID script to get players into the way they look and behind the door.
Opt.: It checks if the space is already filled and won't work if it's so.
 
Solution
Lua:
local config = {
    [45001] = {{-1, 0}, {1, 0}} -- left   -- this might be right
    [45002] = {{1, 0}, {-1, 0}} -- right
    [45003] = {{0, -1}, {0, 1}} -- top  -- this might be bottom. just swap top/bottom and left/right if incorrect
    [45004] = {{0, 1}, {0, -1}} -- bottom
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local index = config[item:getActionId()]
    if not index then
        print("Error: actionid not found in table.")
        return true
    end
  
    local targetPosition = Position(toPosition.x + index[1][1], toPosition.y + index[1][2], toPosition.z)

    -- if player already inside
    if player:getPosition() == targetPosition then
        targetPosition = Position(toPosition.x + index[2][1]...
Lua:
local config = {
    [45001] = {{-1, 0}, {1, 0}} -- left   -- this might be right
    [45002] = {{1, 0}, {-1, 0}} -- right
    [45003] = {{0, -1}, {0, 1}} -- top  -- this might be bottom. just swap top/bottom and left/right if incorrect
    [45004] = {{0, 1}, {0, -1}} -- bottom
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local index = config[item:getActionId()]
    if not index then
        print("Error: actionid not found in table.")
        return true
    end
  
    local targetPosition = Position(toPosition.x + index[1][1], toPosition.y + index[1][2], toPosition.z)

    -- if player already inside
    if player:getPosition() == targetPosition then
        targetPosition = Position(toPosition.x + index[2][1], toPosition.y + index[2][2], toPosition.z)
        creature:teleportTo(targetPosition)
        return true
    end
  
    -- if player is outside
    local thing = Tile(targetPosition):getTopVisibleThing()
    if thing and thing:isCreature() then
        creature:sendCancelMessage("This room is occupied.")
        return true
    end
    creature:teleportTo(targetPosition)
    return true
end
 
Solution
Lua:
local config = {
    [45001] = {{-1, 0}, {1, 0}} -- left   -- this might be right
    [45002] = {{1, 0}, {-1, 0}} -- right
    [45003] = {{0, -1}, {0, 1}} -- top  -- this might be bottom. just swap top/bottom and left/right if incorrect
    [45004] = {{0, 1}, {0, -1}} -- bottom
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local index = config[item:getActionId()]
    if not index then
        print("Error: actionid not found in table.")
        return true
    end
 
    local targetPosition = Position(toPosition.x + index[1][1], toPosition.y + index[1][2], toPosition.z)

    -- if player already inside
    if player:getPosition() == targetPosition then
        targetPosition = Position(toPosition.x + index[2][1], toPosition.y + index[2][2], toPosition.z)
        creature:teleportTo(targetPosition)
        return true
    end
 
    -- if player is outside
    local thing = Tile(targetPosition):getTopVisibleThing()
    if thing and thing:isCreature() then
        creature:sendCancelMessage("This room is occupied.")
        return true
    end
    creature:teleportTo(targetPosition)
    return true
end
1643141489632.png @Xikini
 
Back
Top