• 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.1] Teleport wand for admins

zbizu

Legendary OT User
Joined
Nov 22, 2010
Messages
3,323
Solutions
26
Reaction score
2,690
Location
Poland
supports multi-floor and going through walls
use it like a fishing rod

actions.xml
Code:
<action itemid="12318" script="admin_tp.lua" allowfaruse="1" blockwalls="0" checkfloor="0"/>

admin_tp.lua
Code:
function spellTP(p, frompos, topos)
p:teleportTo(topos)
Position(topos):sendMagicEffect(CONST_ME_PURPLEENERGY)
Position(topos):sendMagicEffect(CONST_ME_ENERGYAREA)
Position(frompos):sendMagicEffect(CONST_ME_PURPLEENERGY)
Position(frompos):sendMagicEffect(CONST_ME_ENERGYAREA)
end


function onUse(player, item, frompos, item2, topos)
local p = player
if p:getAccountType() < ACCOUNT_TYPE_GOD then
return false
end

local i = Item(item2.uid):getPosition()
if i.x > 0 and i.x < 65536 and i.y > 0 and i.y < 65536 then
if p:isInGhostMode() then
p:teleportTo(i)
return true
else
local f = p:getPosition()
Position(f):sendMagicEffect(CONST_ME_THUNDER)
Position(i):sendMagicEffect(CONST_ME_THUNDER)
addEvent(spellTP, 500, p, f, i)
return true
end
end
return false
end
 
Last edited:
@zbizu I'm sorry I've having issues with everything you're putting out there but it's all so good, I want them all :D When I use the rod I get this error in my console:
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/admin_tp.lua:onUse
data/compat.lua:735: attempt to compare number with nil
stack traceback:
        [C]: in function '__le'
        data/compat.lua:735: in function 'getThingPos'
        data/actions/scripts/admin_tp.lua:22: in function <data/actions/scripts/
admin_tp.lua:10>
I swear I'm not just lazy and don't want to fix them myself, I sit here toying around with the scripts for about 45mins before I post. I'm just completely ignorant when it comes to scripting/editing scripts :( I'm trying to learn though
 
Paste here line 735 of your compat.lua
 
Here's the entire function for that line:
Code:
function getThingPos(uid)
    local thing
    if uid >= 0x10000000 then
        thing = Creature(uid)
    else
        thing = Item(uid)
    end

    if thing == nil then
        return false
    end

    local stackpos = 0
    local tile = thing:getTile()
    if tile ~= nil then
        stackpos = tile:getThingIndex(thing)
    end

    local position = thing:getPosition()
    position.stackpos = stackpos
    return position
end
 
@zbizu I'm sorry I've having issues with everything you're putting out there but it's all so good, I want them all :D When I use the rod I get this error in my console:
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/admin_tp.lua:onUse
data/compat.lua:735: attempt to compare number with nil
stack traceback:
        [C]: in function '__le'
        data/compat.lua:735: in function 'getThingPos'
        data/actions/scripts/admin_tp.lua:22: in function <data/actions/scripts/
admin_tp.lua:10>
I swear I'm not just lazy and don't want to fix them myself, I sit here toying around with the scripts for about 45mins before I post. I'm just completely ignorant when it comes to scripting/editing scripts :( I'm trying to learn though
Try with this instead
Code:
local function spellTP(cid, fromPosition, toPosition)
    local player = Player(cid)
    if not player then
        return
    end

    player:teleportTo(toPosition)
    toPosition:sendMagicEffect(CONST_ME_PURPLEENERGY)
    toPosition:sendMagicEffect(CONST_ME_ENERGYAREA)
    fromPosition:sendMagicEffect(CONST_ME_PURPLEENERGY)
    fromPosition:sendMagicEffect(CONST_ME_ENERGYAREA)
end


function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end

    if toPosition.x == 0 or toPosition.x == 65535 or toPosition.y == 0 or toPosition.y == 65535 then
        return false
    end

    if player:isInGhostMode() then
        player:teleportTo(toPosition)
    else
        toPosition:sendMagicEffect(CONST_ME_THUNDER)
        addEvent(spellTP, 500, player.uid, player:getPosition(), toPosition)
    end
    return true
end
By the way, the server might crash if you pass userdata objects to addEvent.
 
neat script, i knew i have to do it eventually, but kept pushing that idea further away because its not that important.
Meanwhile you brought this script on silver platter :D
i had same issue like @Doitforthegains
but i solved it like this

Code:
function spellTP(p, frompos, topos)
p:teleportTo(topos)
Position(topos):sendMagicEffect(CONST_ME_PURPLEENERGY)
Position(topos):sendMagicEffect(CONST_ME_ENERGYAREA)
Position(frompos):sendMagicEffect(CONST_ME_PURPLEENERGY)
Position(frompos):sendMagicEffect(CONST_ME_ENERGYAREA)
end


function onUse(cid, item, frompos, itemEx, topos)
local player = Player(cid)
local p = player
if p:getAccountType() < ACCOUNT_TYPE_GOD then
return false
end

local i = getThingPos(itemEx.uid)
if i.x > 0 and i.x < 65536 and i.y > 0 and i.y < 65536 then
if p:isInGhostMode() then
p:teleportTo(i)
return true
else
local f = getThingPos(cid)
Position(f):sendMagicEffect(CONST_ME_THUNDER)
Position(i):sendMagicEffect(CONST_ME_THUNDER)
addEvent(spellTP, 500, p, f, i)
return true
end
end
return false
end

EDIT:
incase you don't see the difference
zbizu has this line:
local f = getThingPos(cid)
but in function he had player, instead of cid
function onUse(player, item, frompos, item2, topos)
 
Last edited:
First post updated
fixed bugs
 
Last edited:
is there another item free?
this is this one:
Code:
<action itemid="12318" script="quests/wrath of the emperor/Mission10AMessageofFreedomSceptre.lua" />
 
is there another item free?
this is this one:
Code:
<action itemid="12318" script="quests/wrath of the emperor/Mission10AMessageofFreedomSceptre.lua" />
use wahtever item you want.

I use "GOD" rune.
 
Sorry for disturbing, I can't add it on my tfs 1.1 :/

I got this errors:

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other/admin_tp.lua:onUse
LuaScriptInterface::luaAddEvent(). Argument #3 is unsafe
stack traceback:
        [C]: in function 'addEvent'
        data/actions/scripts/other/admin_tp.lua:26: in function <data/actions/sc
ripts/other/admin_tp.lua:11>

Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
data/actions/scripts/other/admin_tp.lua:3: attempt to index local 'p' (a number
value)
stack traceback:
        [C]: in function '__index'
        data/actions/scripts/other/admin_tp.lua:3: in function <data/actions/scr
ipts/other/admin_tp.lua:2>

I really want this script :D
Anyone can help me?

By the way, your releases are perfect!!
 
Sorry for disturbing, I can't add it on my tfs 1.1 :/
Code:
function spellTP(cid, frompos, topos)
local player = Player(cid)
player:teleportTo(topos)
Position(topos):sendMagicEffect(CONST_ME_PURPLEENERGY)
Position(topos):sendMagicEffect(CONST_ME_ENERGYAREA)
Position(frompos):sendMagicEffect(CONST_ME_PURPLEENERGY)
Position(frompos):sendMagicEffect(CONST_ME_ENERGYAREA)
end

function onUse(player, item, frompos, itemEx, topos)
local cid = player:getId()
local itemExPos = itemEx:getPosition()
if not itemExPos then return false end

    if player:isInGhostMode() then
        player:teleportTo(itemExPos)
        return true
    else
        local playerPos = player:getPosition()
        Position(playerPos):sendMagicEffect(CONST_ME_THUNDER)
        Position(itemExPos):sendMagicEffect(CONST_ME_THUNDER)
        addEvent(spellTP, 300, cid, playerPos, itemExPos)
        return true
    end
 
return false
end
 
Code:
function spellTP(cid, frompos, topos)
local player = Player(cid)
player:teleportTo(topos)
Position(topos):sendMagicEffect(CONST_ME_PURPLEENERGY)
Position(topos):sendMagicEffect(CONST_ME_ENERGYAREA)
Position(frompos):sendMagicEffect(CONST_ME_PURPLEENERGY)
Position(frompos):sendMagicEffect(CONST_ME_ENERGYAREA)
end

function onUse(player, item, frompos, itemEx, topos)
local cid = player:getId()
local itemExPos = itemEx:getPosition()
if not itemExPos then return false end

    if player:isInGhostMode() then
        player:teleportTo(itemExPos)
        return true
    else
        local playerPos = player:getPosition()
        Position(playerPos):sendMagicEffect(CONST_ME_THUNDER)
        Position(itemExPos):sendMagicEffect(CONST_ME_THUNDER)
        addEvent(spellTP, 300, cid, playerPos, itemExPos)
        return true
    end

return false
end

Woooooooooooaaah!

Perfect! Thanks!!!
 
Any way to make this for players also? Maybe a cooldown? Would love to use this for a quest item =)

Good lucky.

Code:
if player:getStorageValue(150) >= os.time() then
        player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("You must wait %s before to use this item again.", showTimeLeft(player:getStorageValue(150) - os.time(), true)))
        return true
    end
  
    player:setStorageValue(150, os.time() + 10 * 60)
 
Good lucky.

Code:
if player:getStorageValue(150) >= os.time() then
        player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("You must wait %s before to use this item again.", showTimeLeft(player:getStorageValue(150) - os.time(), true)))
        return true
    end
 
    player:setStorageValue(150, os.time() + 10 * 60)
I have no idea where to add this, also is it possible to just make a teleport wand? I have been searching everywhere :p but cant find a good teleport item for tfs 1.2
 
Back
Top