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

Teleport Item tfs 1.5

Shoorkill

Member
Joined
Dec 17, 2018
Messages
126
Reaction score
21
I would like a teleport like this:
when using item id: X
you mark the current coordinates of your character (do not remove the item id: X)
when using it again you are given a 5 second countdown and you are taken to the location of the marked coordinates (removes 1 item id: X)
Remarks, item id: X cannot be used while by white skull or in pvp
someone help please?
 
if yes then use my script here

put item id "xxx"
<action itemid="xxx" script="Teleporte-pos.lua"/>
the script is complete here

Lua:
local function Teleport10(cid)
if isPlayer(cid) == TRUE then
xpos = getPlayerStorageValue(cid, 111)
ypos = getPlayerStorageValue(cid, 222)
zpos = getPlayerStorageValue(cid, 333)
spos = {x=xpos, y=ypos, z=zpos}
doTeleportThing(cid, spos)
doPlayerSendTextMessage(cid,MESSAGE_EVENT_ADVANCE, 'Você foi teletransportado com sucesso.')
doSendMagicEffect(getCreaturePosition(cid), 106)
doSendAnimatedText(getCreaturePosition(cid), "Woup!!", 213)
end
return TRUE
end

local function Teleport9(cid)
xpos = getPlayerStorageValue(cid, 111)
ypos = getPlayerStorageValue(cid, 222)
zpos = getPlayerStorageValue(cid, 333)
spos = {x=xpos, y=ypos, z=zpos}
if isPlayer(cid) == TRUE then
doSendMagicEffect(spos, 106)
doSendMagicEffect(getCreaturePosition(cid), 106)
addEvent(Teleport10, 1 * 1000, cid)
end
end

local function Teleport8(cid)
xpos = getPlayerStorageValue(cid, 111)
ypos = getPlayerStorageValue(cid, 222)
zpos = getPlayerStorageValue(cid, 333)
spos = {x=xpos, y=ypos, z=zpos}
if isPlayer(cid) == TRUE then
doSendMagicEffect(spos, 106)
doSendMagicEffect(getCreaturePosition(cid), 106)
addEvent(Teleport9, 1 * 1000, cid)
end
end

local function Teleport7(cid)
xpos = getPlayerStorageValue(cid, 111)
ypos = getPlayerStorageValue(cid, 222)
zpos = getPlayerStorageValue(cid, 333)
spos = {x=xpos, y=ypos, z=zpos}
if isPlayer(cid) == TRUE then
doSendMagicEffect(spos, 106)
doSendMagicEffect(getCreaturePosition(cid), 106)
addEvent(Teleport8, 1 * 1000, cid)
end
end

local function Teleport6(cid)
xpos = getPlayerStorageValue(cid, 111)
ypos = getPlayerStorageValue(cid, 222)
zpos = getPlayerStorageValue(cid, 333)
spos = {x=xpos, y=ypos, z=zpos}
if isPlayer(cid) == TRUE then
doSendMagicEffect(spos, 106)
doSendMagicEffect(getCreaturePosition(cid), 106)
addEvent(Teleport7, 1 * 1000, cid)
end
end

local function Teleport5(cid)
xpos = getPlayerStorageValue(cid, 111)
ypos = getPlayerStorageValue(cid, 222)
zpos = getPlayerStorageValue(cid, 333)
spos = {x=xpos, y=ypos, z=zpos}
if isPlayer(cid) == TRUE then
doSendMagicEffect(spos, 106)
doSendMagicEffect(getCreaturePosition(cid), 106)
addEvent(Teleport6, 1 * 1000, cid)
end
end

local function Teleport4(cid)
xpos = getPlayerStorageValue(cid, 111)
ypos = getPlayerStorageValue(cid, 222)
zpos = getPlayerStorageValue(cid, 333)
spos = {x=xpos, y=ypos, z=zpos}
if isPlayer(cid) == TRUE then
doSendMagicEffect(spos, 106)
doSendMagicEffect(getCreaturePosition(cid), 106)
addEvent(Teleport5, 1 * 1000, cid)
end
end

local function Teleport3(cid)
xpos = getPlayerStorageValue(cid, 111)
ypos = getPlayerStorageValue(cid, 222)
zpos = getPlayerStorageValue(cid, 333)
spos = {x=xpos, y=ypos, z=zpos}
if isPlayer(cid) == TRUE then
doSendMagicEffect(spos, 106)
doSendMagicEffect(getCreaturePosition(cid), 106)
addEvent(Teleport4, 1 * 1000, cid)
end
end

local function Teleport2(cid)
xpos = getPlayerStorageValue(cid, 111)
ypos = getPlayerStorageValue(cid, 222)
zpos = getPlayerStorageValue(cid, 333)
spos = {x=xpos, y=ypos, z=zpos}
if isPlayer(cid) == TRUE then
doSendMagicEffect(spos, 106)
doSendMagicEffect(getCreaturePosition(cid), 106)
addEvent(Teleport3, 1 * 1000, cid)
end
end

local function Teleport1(cid)
xpos = getPlayerStorageValue(cid, 111)
ypos = getPlayerStorageValue(cid, 222)
zpos = getPlayerStorageValue(cid, 333)
spos = {x=xpos, y=ypos, z=zpos}
if isPlayer(cid) == TRUE then
doSendMagicEffect(spos, 106)
doSendMagicEffect(getCreaturePosition(cid), 106)
addEvent(Teleport2, 1 * 1000, cid)
end
end



local condition = createConditionObject(CONDITION_EXHAUSTED)
setConditionParam(condition, CONDITION_PARAM_TICKS, 15000)

function onUse(cid, item, frompos, item2, topos)

-- Exhausted Settings --
local exhausted_seconds1 = 15 -- Segundos que irá demorar para usar denovo
local exhausted_storagevalue1 = 8754 -- Storage Value do exhausted
local exhausted_seconds3 = 15 -- How many seconds mana fluid will be unavailible to use. --
local exhausted_storagevalue3 = 8162 -- Storage Value to store exhaust. It MUST be unused! --exhausted


local teleport = getPlayerStorageValue(cid, 444)

if(os.time() < getPlayerStorageValue(cid, exhausted_storagevalue1)) then
doPlayerSendCancel(cid,"Você está muito cansado.")
return TRUE
end

if getPlayerSkullType(cid) == 3 then
doPlayerSendCancel(cid,"Você não pode usar esse teleport enquanto estiver PK.")
return TRUE
end

if teleport == -1 or teleport == 0 then
savpos = {x=getThingPos(cid).x, y=getThingPos(cid).y, z=getThingPos(cid).z, stackpos=253}
setPlayerStorageValue(cid, 111, savpos.x)
setPlayerStorageValue(cid, 222, savpos.y)
setPlayerStorageValue(cid, 333, savpos.z)
setPlayerStorageValue(cid, 444, 1)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
doPlayerSendTextMessage(cid,MESSAGE_EVENT_ADVANCE, 'Você gravou suas coordenadas em seu teleport mistico.')

rand = math.random(0,100)
elseif teleport == 1 and (os.time() >= getPlayerStorageValue(cid, exhausted_storagevalue1)) and rand < 40 then
addEvent(Teleport1, 1 * 1000, cid)
setPlayerStorageValue(cid, 444, 0)
doPlayerSendTextMessage(cid,MESSAGE_EVENT_ADVANCE, 'Você ativou seu teleport mistico.')
setPlayerStorageValue(cid, exhausted_storagevalue1, os.time() + exhausted_seconds1)
setPlayerStorageValue(cid, exhausted_storagevalue3, os.time() + exhausted_seconds3)
doTargetCombatCondition(0, cid, condition, CONST_ME_NONE)
doSendMagicEffect(getCreaturePosition(cid), 106)
doRemoveItem(item.uid,1)


elseif teleport == 1 and (os.time() >= getPlayerStorageValue(cid, exhausted_storagevalue1)) and rand > 40 then
addEvent(Teleport1, 1 * 1000, cid)
setPlayerStorageValue(cid, 444, 0)
doPlayerSendTextMessage(cid,MESSAGE_EVENT_ADVANCE, 'Você ativou seu teleport mistico.')
setPlayerStorageValue(cid, exhausted_storagevalue1, os.time() + exhausted_seconds1)
setPlayerStorageValue(cid, exhausted_storagevalue3, os.time() + exhausted_seconds3)
doTargetCombatCondition(0, cid, condition, CONST_ME_NONE)
doSendMagicEffect(getCreaturePosition(cid), 106)
doRemoveItem(item.uid,1)
end
end

then don't forget to give solution
 
I have an error:
data/actions/scripts/teleporte-pos.lua:176: attempt to call global 'doCreatureCombatCondition' (a nil value)
stack traceback:
[C]: in function 'doCreatureCombatCondition'
data/actions/scripts/tp.lua:176: in function <data/actions/scripts/teleporte-pos.lua:128>
 
Lua:
local config = {
    pos = {x = 1021, y = 1019, z = 7}, 
    cooldown = 60 
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not player then
        return
    end
    local storage = 1234
    local lastUsage = player:getStorageValue(storage)
    local currentTime = os.time()
    local timePassed = currentTime - lastUsage
    if lastUsage > 0 and timePassed < config.cooldown then
        local remainingTime = config.cooldown - timePassed
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You must wait ".. remainingTime .." seconds before using this item again.")
        return
    end
    player:sendTextMessage(MESSAGE_INFO_DESCR, "You will be teleported in 5 seconds")
    player:setStorageValue(storage, currentTime)
    addEvent(function(playerID)
        local p = Player(playerID)
        if not p then
            return
        end
        p:teleportTo(config.pos)
        p:sendTextMessage(MESSAGE_INFO_DESCR, "You have been teleported")
        p:getPosition():sendMagicEffect(11)
    end, 5000, player:getId())
end
 
Last edited:
Lua:
local config = {
    pos = {x = 5999, y = 6045, z = 7},
    cooldown = 60
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not player then
        return
    end

    local storage = 1234

    local lastUsage = player:getStorageValue(storage)
    local currentTime = os.time()
    local timePassed = currentTime - lastUsage

    if lastUsage > 0 and timePassed < config.cooldown then
        local remainingTime = config.cooldown - timePassed
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You must wait ".. remainingTime .." seconds before using this item again.")
        return
    end

    player:sendTextMessage(MESSAGE_INFO_DESCR, "You will be teleported in 5 seconds")
    player:setStorageValue(storage, currentTime)

    addEvent(function()
        player:teleportTo(config.pos)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have been teleported")
        player:getPosition():sendMagicEffect(11)
    end, 5000)
end
it does not work, it is teleporting to the same sqm that it is .. I need that when using the item it marks the coordinates of the used place, when using the item again it does a 5 second count and is thrown to the marked place again
 
I changed some code compatible with TFS 1.5
Lua:
function onUse(cid, item, frompos, item2, topos)
    local exausted = 5
    local storage = 10569

    if getTilePzInfo(getCreaturePosition(cid)) then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You cannot teleport into a protected area..")
        doSendMagicEffect(getCreaturePosition(cid), EFFECT_TELEPORT_FRAME)
        return true
    end

    if getCreatureSkullType(cid) == SKULL_RED then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Red Skull cannot use teleport.")
        doSendMagicEffect(getCreaturePosition(cid), EFFECT_TELEPORT_FRAME)
        return true
    end

    if getCreatureSkullType(cid) == SKULL_WHITE then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "White Skull cannot use teleport.")
        doSendMagicEffect(getCreaturePosition(cid), EFFECT_TELEPORT_FRAME)
        return true
    end

    if getPlayerLevel(cid) <= 99 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry you don't have enough level.")
        doSendMagicEffect(getCreaturePosition(cid), EFFECT_TELEPORT_FRAME)
        return true
    end

    if item.itemid == 12498 then
        local testplayer = isCreature(cid)
        if getPlayerStorageValue(cid, 10579) >= 1 then
            doSendMagicEffect(getCreaturePosition(cid), EFFECT_TELEPORT_FRAME)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry, you already have a teleport marked. Use marked teleport to save new coordinates.")
            return true
        end
        if getPlayerStorageValue(cid, storage) <= os.time() then
            local savpos = {x = getThingPos(item2.uid).x, y = getThingPos(item2.uid).y, z = getThingPos(item2.uid).z, stackpos = 253}
            setPlayerStorageValue(cid, 111, savpos.x)
            setPlayerStorageValue(cid, 222, savpos.y)
            setPlayerStorageValue(cid, 333, savpos.z)
            setPlayerStorageValue(cid, 10579, 1)
            doSendMagicEffect(topos, EFFECT_TELEPORT)
            setPlayerStorageValue(cid, storage, os.time() + exausted)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your coordinates have been successfully saved.")
            doRemoveItem(item.uid, 1)
            doPlayerAddItem(cid, 12499, 1)
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can only activate another teleport every 5 seconds!")
            doSendMagicEffect(getCreaturePosition(cid), EFFECT_TELEPORT_FRAME)
        end

    elseif item.itemid == 12499 then
        setPlayerStorageValue(cid, 10579, -1)
        local xpos = getPlayerStorageValue(cid, 111)
        local ypos = getPlayerStorageValue(cid, 222)
        local zpos = getPlayerStorageValue(cid, 333)
        if xpos == 0 then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Empty position, select a position to teleport.")
            doSendMagicEffect(getCreaturePosition(cid), EFFECT_TELEPORT_FRAME)
            doTransformItem(item.uid, 12498)
        elseif getPlayerStorageValue(cid, storage) <= os.time() then
            doTeleportThing(cid, {x = xpos, y = ypos, z = zpos})
            doRemoveItem(item.uid, 1)
            doSendMagicEffect({x = xpos, y = ypos, z = zpos}, EFFECT_TELEPORT)
            setPlayerStorageValue(cid, storage, os.time() + exausted)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have been successfully teleported.")
            setPlayerStorageValue(cid, 111, 0)
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can only activate another teleport every 5 seconds!")
            doSendMagicEffect(getCreaturePosition(cid), EFFECT_TELEPORT_FRAME)
        end

    else
        doPlayerSendCancel(cid, "Error! Incorrect item.")
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Error! Incorrect item. Change your 'actions.xml' file correctly! If you are a player, inform your GM or Administrator.")
        doSendMagicEffect(getCreaturePosition(cid), EFFECT_TELEPORT_FRAME)
    end

    return true
end

when you click on the item id (12498) and save the coordinate map, it turns into another id 12499, click on the new item and teleport you saved the coordinates and go teleport it, it's working fine ok

should have add two
different tag items in XML
<action itemid="12498" script="teste.lua"/>
<action itemid="12499" script="teste.lua"/>
 
I changed some code compatible with TFS 1.5
Lua:
function onUse(cid, item, frompos, item2, topos)
    local exausted = 5
    local storage = 10569

    if getTilePzInfo(getCreaturePosition(cid)) then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You cannot teleport into a protected area..")
        doSendMagicEffect(getCreaturePosition(cid), EFFECT_TELEPORT_FRAME)
        return true
    end

    if getCreatureSkullType(cid) == SKULL_RED then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Red Skull cannot use teleport.")
        doSendMagicEffect(getCreaturePosition(cid), EFFECT_TELEPORT_FRAME)
        return true
    end

    if getCreatureSkullType(cid) == SKULL_WHITE then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "White Skull cannot use teleport.")
        doSendMagicEffect(getCreaturePosition(cid), EFFECT_TELEPORT_FRAME)
        return true
    end

    if getPlayerLevel(cid) <= 99 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry you don't have enough level.")
        doSendMagicEffect(getCreaturePosition(cid), EFFECT_TELEPORT_FRAME)
        return true
    end

    if item.itemid == 12498 then
        local testplayer = isCreature(cid)
        if getPlayerStorageValue(cid, 10579) >= 1 then
            doSendMagicEffect(getCreaturePosition(cid), EFFECT_TELEPORT_FRAME)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry, you already have a teleport marked. Use marked teleport to save new coordinates.")
            return true
        end
        if getPlayerStorageValue(cid, storage) <= os.time() then
            local savpos = {x = getThingPos(item2.uid).x, y = getThingPos(item2.uid).y, z = getThingPos(item2.uid).z, stackpos = 253}
            setPlayerStorageValue(cid, 111, savpos.x)
            setPlayerStorageValue(cid, 222, savpos.y)
            setPlayerStorageValue(cid, 333, savpos.z)
            setPlayerStorageValue(cid, 10579, 1)
            doSendMagicEffect(topos, EFFECT_TELEPORT)
            setPlayerStorageValue(cid, storage, os.time() + exausted)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your coordinates have been successfully saved.")
            doRemoveItem(item.uid, 1)
            doPlayerAddItem(cid, 12499, 1)
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can only activate another teleport every 5 seconds!")
            doSendMagicEffect(getCreaturePosition(cid), EFFECT_TELEPORT_FRAME)
        end

    elseif item.itemid == 12499 then
        setPlayerStorageValue(cid, 10579, -1)
        local xpos = getPlayerStorageValue(cid, 111)
        local ypos = getPlayerStorageValue(cid, 222)
        local zpos = getPlayerStorageValue(cid, 333)
        if xpos == 0 then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Empty position, select a position to teleport.")
            doSendMagicEffect(getCreaturePosition(cid), EFFECT_TELEPORT_FRAME)
            doTransformItem(item.uid, 12498)
        elseif getPlayerStorageValue(cid, storage) <= os.time() then
            doTeleportThing(cid, {x = xpos, y = ypos, z = zpos})
            doRemoveItem(item.uid, 1)
            doSendMagicEffect({x = xpos, y = ypos, z = zpos}, EFFECT_TELEPORT)
            setPlayerStorageValue(cid, storage, os.time() + exausted)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have been successfully teleported.")
            setPlayerStorageValue(cid, 111, 0)
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can only activate another teleport every 5 seconds!")
            doSendMagicEffect(getCreaturePosition(cid), EFFECT_TELEPORT_FRAME)
        end

    else
        doPlayerSendCancel(cid, "Error! Incorrect item.")
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Error! Incorrect item. Change your 'actions.xml' file correctly! If you are a player, inform your GM or Administrator.")
        doSendMagicEffect(getCreaturePosition(cid), EFFECT_TELEPORT_FRAME)
    end

    return true
end

when you click on the item id (12498) and save the coordinate map, it turns into another id 12499, click on the new item and teleport you saved the coordinates and go teleport it, it's working fine ok

should have add two
different tag items in XML
Lua Script Error: [Action Interface]
data/actions/scripts/tp.lua:eek:nUse
data/actions/scripts/tp.lua:37: attempt to index a boolean value
stack traceback:
[C]: in function '__index'
data/actions/scripts/tp.lua:37: in function <data/actions/scripts/tp.lua:1>
 
Back
Top