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

Teleportation spell for TFS 1.2

xoiox

New Member
Joined
Aug 20, 2009
Messages
46
Reaction score
2
Hi, I'm looking for teleportation spell for TFS 1.2, which can teleport player to selected area on the screen. Will be fine, if it is instant spell. I mean way like this: When someone spell words, then select cursor appears and after select field, spell teleports him to selected place. If it's impossible for TFS 1.2 can be also such spell for rune.

PS. could you take into account also, spell can not teleport someone on the water, lava, walls etc.
 
It works fine, but I can't set up conditions for blocking tiles like water, walls, stairs, houses tiles etc.. I am not good in lua
 
Code:
 if not Tile(newPos):getGround() then return false end
if Tile(newPos):hasProperty(CONST_PROP_BLOCKSOLID) then return false end


etc
 
got an error:
iyps1l.jpg


whole script teleportrune.lua:
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

local function isWalkable(pos, creatures)
     local tile = Tile(pos)
     if (creatures and tile:getCreatureCount() > 0) or tile:hasFlag(TILESTATE_BLOCKSOLID) then
         return false
     end
     return true
end


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

if not Tile(newPos):getGround() then return false end
if Tile(newPos):hasProperty(CONST_PROP_BLOCKSOLID) then return false end

    if player:isInGhostMode() then
        player:teleportTo(toPosition)
    else
        toPosition:sendMagicEffect(CONST_ME_THUNDER)
        player:getPosition():sendMagicEffect(CONST_ME_THUNDER)
        addEvent(spellTP, 500, player.uid, player:getPosition(), toPosition)
    end
    return true
end
 
This should work:
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

local function isWalkable(position)
    local tile = Tile(position)
    if not tile then
        return false
    end

    local ground = tile:getGround()
    if not ground or ground:hasProperty(CONST_PROP_BLOCKSOLID) then
        return false
    end

    local items = tile:getItems()
    for i = 1, #items do
        local item = items[i]
        local itemType = item:getType()
        if itemType:getType() ~= ITEM_TYPE_MAGICFIELD and not itemType:isMovable() and item:hasProperty(CONST_PROP_BLOCKSOLID) then
            return false
        end
    end
    return true
end

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

    if player:isInGhostMode() then
        player:teleportTo(toPosition)
    else
        toPosition:sendMagicEffect(CONST_ME_THUNDER)
        player:getPosition():sendMagicEffect(CONST_ME_THUNDER)
        addEvent(spellTP, 500, player.uid, player:getPosition(), toPosition)
    end
    return true
end
 
Thanks Ninja, this works like I wanted, but I want this for magic professions and when player teleports to stairs tile, then he should go down/up but he stays on the stairs. Second thing is white skull PK. When player got pk and uses tp rune, then he can get on the pz tile. Could you complete a script? I don't know at this :/
 
Back
Top