• 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 on Crosshair

hyz

Member
Joined
Oct 30, 2008
Messages
39
Reaction score
16
I'm having trouble creating a teleport "RUNE", which teleports to the place where the player played the rune.
I was able to see a script of that system but it is out of date.
I'm using TFS 1.3
 
Lua:
local tprune = Action()
local tprunePlayers = {} -- don't change that
local tpruneExhaust = 5

tprune:id(2263)
tprune:allowFarUse(true)
tprune:checkFloor(true)

function tprune.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local errMsg = "" -- don't change that
    time, cid = os.time(), player:getId()

    if tprunePlayers[cid] and time < tprunePlayers[cid] then
        errMsg = "You are exhausted."
    end

    local tile = Tile(toPosition)
    if errMsg == "" and not tile then
        errMsg = "Tile not found."
    end

    if errMsg == "" and not tile:isWalkable() then
        errMsg = "Tile is not walkable."
    end

    if errMsg == "" and tile:hasFlag(TILESTATE_PROTECTIONZONE) and player:isPzLocked() then
        errMsg = RETURNVALUE_PLAYERISPZLOCKED
    end

    if errMsg ~= "" then
        player:sendCancelMessage(errMsg)
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end

    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    player:teleportTo(toPosition)
    tprunePlayers[cid] = time + tpruneExhaust
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    return true
end

tprune:register()

Something like that? At first glance, seems to work fine on 1.5. Didn't test it extensivly tho, so might have some errors.
 
Installed and got these errors

[CÓDIGO] Erro de script: [Interface de teste]
data/actions/scripts/teleport.lua
luaCreateAction(). As ações só podem ser registradas na interface Scripts.
rastreamento de pilha:
[C]: na função 'Ação'
data/actions/scripts/teleport.lua:1: no bloco principal

Erro de script Lua: [Interface de teste]
data/actions/scripts/teleport.lua
data/actions/scripts/teleport.lua:5: tentativa de indexar 'tprune' local (um valor nil)
rastreamento de pilha:
[C]: na função '__index'
data/actions/scripts/teleport.lua:5: no bloco principal
[Aviso - Evento::checkScript] Não é possível carregar o script: scripts/teleport.lua

[/CÓDIGO]
 
Back
Top