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

door+key that teleport.

oshrigames

Active Member
Joined
Nov 9, 2012
Messages
222
Reaction score
47
Location
israel
hello :D
i use TFS 1.2 (protocol 10.98)

about the unique training rooms i have.
6.png
id like to request some help with somewhat wierd script for door that teleport player once i use its unique item on the door, and only if there isn't already player on the glowing tile (time ID:11062) inside the room.
(while door itself will remain locked and closed so other people wont walk in/block exit).

also the tile itslef have action id:9000 since i use:

this is what i got so far.. 😅
Lua:
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
i imagen i'll need to add to action.xml
something like this?
Lua:
<action actionid="????" script="other/teleportDoor.lua"/>

to sum it all up:
use the "unique" item ID: 26194 on the door and get teleported from outside of the room to inside of the room
only if there is no other player already stand on the glowing tile (tile ID:11062)


i will publish it and credit Apollos & (whoever gonna help me with the tp door) for public once its finished.

much appreciated
Thanks.
 
Last edited:
Solution
😮wow that was.. ty for fast reply
works great but..
i should have been more spesific, i have multiple rooms, so
Lua:
local trainPos = Position(1008, 1043, 7)
only work for only one :x

any way around it? so it fit more rooms?
try
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.actionid == target.actionid then
        local trainPos = target:getPosition()
        trainPos.y = trainPos.y - 1
        local tile = Tile(trainPos)
        if not tile:getTopCreature() then
            trainPos:sendMagicEffect(CONST_ME_TELEPORT)
            player:teleportTo(trainPos)
            return true
        else
            local tc = tile:getCreatures()
            for i = 1, #tc do...
Code:
<action actionid="26194" script="trainingRoom.lua"/>

trainingRoom.lua
Lua:
local trainPos = Position(1008, 1043, 7)
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.actionid == target.actionid then
        local tile = Tile(trainPos)
        if not tile:getTopCreature() then
            tile:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            player:teleportTo(trainPos)
            return true
        end
    end
end

give the door on map actionid 26194 and the key aswell same actionid
 
😮wow that was.. ty for fast reply
works great but..
i should have been more spesific, i have multiple rooms, so
Lua:
local trainPos = Position(1008, 1043, 7)
only work for only one :x

any way around it? so it fit more rooms?
 
Last edited:
😮wow that was.. ty for fast reply
works great but..
i should have been more spesific, i have multiple rooms, so
Lua:
local trainPos = Position(1008, 1043, 7)
only work for only one :x

any way around it? so it fit more rooms?
try
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.actionid == target.actionid then
        local trainPos = target:getPosition()
        trainPos.y = trainPos.y - 1
        local tile = Tile(trainPos)
        if not tile:getTopCreature() then
            trainPos:sendMagicEffect(CONST_ME_TELEPORT)
            player:teleportTo(trainPos)
            return true
        else
            local tc = tile:getCreatures()
            for i = 1, #tc do
                local c = tc[i]
                if c == player then
                    trainPos.y = trainPos.y + 2
                    trainPos:sendMagicEffect(CONST_ME_TELEPORT)
                    player:teleportTo(trainPos)
                    return true
                end
            end
        end
    end
end
should work to teleport out now aswell
 
Last edited:
Solution
i add "trainPos.y = trainPos.y + 1"
since i have "south" rooms aswell.
player stand on the door but i guess that will have to do for now until i find solution.. Thanks a lot!
i will make sure to add you to credit for the entire "system" and server credits when i publish it. :3

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local trainPos = target:getPosition()
    trainPos.y = trainPos.y - 1
    trainPos.y = trainPos.y + 1
    if item.actionid == target.actionid then
        local tile = Tile(trainPos)
        if not tile:getTopCreature() then
            tile:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            player:teleportTo(trainPos)
            return true
        end
    end
end
 
i updated the code btw, moved local trainPos = target:getPosition() and trainPos.y = trainPos.y - 1 inside the first if statement block so you wouldn't get error if you click on the door without key

if you wana use it for south rooms maby somehow check where player is standing related to the door and then change Y according to that, keep in mind that it has to be changed in both statements, i'm sure the script could had been better written aswell, i'm not that great at lua ;) gl
 
Back
Top