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

Lua Teleport Scroll

adrenyslopez

Member
Joined
Dec 22, 2015
Messages
179
Reaction score
13
This scripts only works in protection zone, how can I make it work in any zone but if it doesn't have pz?



Lua:
local teleportScroll = Action()

function teleportScroll.onUse(player, item, fromPos, target, toPos, isHotkey)
    local playerPos = player:getPosition()
    local tile = Tile(playerPos)
    if not tile or not tile:hasFlag(TILESTATE_PROTECTIONZONE) then
        player:sendCancelMessage("You can use only in pz.")
        return true
    end

    local town = player:getTown()
    local templePos = town and town:getTemplePosition() or Town(1):getTemplePosition()
    playerPos:sendMagicEffect(CONST_ME_POFF)
    player:teleportTo(templePos)
    templePos:sendMagicEffect(CONST_ME_TELEPORT)
    item:transform(item:getId(), item:getCharges() -1)
    return true
end

teleportScroll:id(29019)
teleportScroll:register()
 
Solution
Can it be changed to not allow it?

Lua:
local teleportScroll = Action()

function teleportScroll.onUse(player, item, fromPos, target, toPos, isHotkey)
    if player:hasCondition(CONDITION_INFIGHT) then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "text.")
        return true
    end
    local playerPos = player:getPosition()
    local town = player:getTown()
    local templePos = town and town:getTemplePosition() or Town(1):getTemplePosition()
    playerPos:sendMagicEffect(CONST_ME_POFF)
    player:teleportTo(templePos)
    templePos:sendMagicEffect(CONST_ME_TELEPORT)
    item:transform(item:getId(), item:getCharges() -1)
    return true
end

teleportScroll:id(29019)
teleportScroll:register()
Post automatically merged:

updated...

MrVilhelm

Mafia Penguin
Premium User
Joined
Dec 11, 2020
Messages
118
Reaction score
93
Location
Sweden
GitHub
MrVilhelm
On this line (Line 6) :
Remove
Lua:
if not tile or not tile:hasFlag(TILESTATE_PROTECTIONZONE) then
Hope it helps! 🤓 ❤️
Post automatically merged:


Or even easier, just remove (Same line 6) :
Lua:
or not tile:hasFlag(TILESTATE_PROTECTIONZONE)

This will make the statment if not tile not used at all since you will always be standing on a tile but thats the easiest way Imo ^^ Or just remove the whole statment.

In that case remove everything from (Line 6 to line 9) :
Lua:
    if not tile or not tile:hasFlag(TILESTATE_PROTECTIONZONE) then
        player:sendCancelMessage("You can use only in pz.")
        return true
    end
 
Last edited:

Levi999x

AoT
Joined
Dec 14, 2017
Messages
1,868
Solutions
37
Reaction score
1,083
Location
Germany
as above said

remove these lines :D

Lua:
local teleportScroll = Action()

function teleportScroll.onUse(player, item, fromPos, target, toPos, isHotkey)
    local playerPos = player:getPosition()
    local town = player:getTown()
    local templePos = town and town:getTemplePosition() or Town(1):getTemplePosition()
    playerPos:sendMagicEffect(CONST_ME_POFF)
    player:teleportTo(templePos)
    templePos:sendMagicEffect(CONST_ME_TELEPORT)
    item:transform(item:getId(), item:getCharges() -1)
    return true
end

teleportScroll:id(29019)
teleportScroll:register()
 
OP
OP
A

adrenyslopez

Member
Joined
Dec 22, 2015
Messages
179
Reaction score
13
as above said

remove these lines :D

Lua:
local teleportScroll = Action()

function teleportScroll.onUse(player, item, fromPos, target, toPos, isHotkey)
    local playerPos = player:getPosition()
    local town = player:getTown()
    local templePos = town and town:getTemplePosition() or Town(1):getTemplePosition()
    playerPos:sendMagicEffect(CONST_ME_POFF)
    player:teleportTo(templePos)
    templePos:sendMagicEffect(CONST_ME_TELEPORT)
    item:transform(item:getId(), item:getCharges() -1)
    return true
end

teleportScroll:id(29019)
teleportScroll:register()
So I can use it even with pk or red pz
 

Levi999x

AoT
Joined
Dec 14, 2017
Messages
1,868
Solutions
37
Reaction score
1,083
Location
Germany
Can it be changed to not allow it?

Lua:
local teleportScroll = Action()

function teleportScroll.onUse(player, item, fromPos, target, toPos, isHotkey)
    if player:hasCondition(CONDITION_INFIGHT) then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "text.")
        return true
    end
    local playerPos = player:getPosition()
    local town = player:getTown()
    local templePos = town and town:getTemplePosition() or Town(1):getTemplePosition()
    playerPos:sendMagicEffect(CONST_ME_POFF)
    player:teleportTo(templePos)
    templePos:sendMagicEffect(CONST_ME_TELEPORT)
    item:transform(item:getId(), item:getCharges() -1)
    return true
end

teleportScroll:id(29019)
teleportScroll:register()
Post automatically merged:

updated version with exhaust

Lua:
local teleportScroll = Action()

function teleportScroll.onUse(player, item, fromPos, target, toPos, isHotkey)

    if player:getStorageValue(52523) >= os.time() then
        player:sendCancelMessage("You cant use it now")
        return true
    end
    
    if player:hasCondition(CONDITION_INFIGHT) then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "text.")
        return true
    end
    
    local playerPos = player:getPosition()
    local town = player:getTown()
    local templePos = town and town:getTemplePosition() or Town(1):getTemplePosition()
    playerPos:sendMagicEffect(CONST_ME_POFF)
    player:teleportTo(templePos)
    player:setStorageValue(52523, os.time() + 10) -- 10 means 10 seconds
    templePos:sendMagicEffect(CONST_ME_TELEPORT)
    item:transform(item:getId(), item:getCharges() -1)
    return true
end

teleportScroll:id(29019)
teleportScroll:register()
 
Last edited:
Solution
Top