• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Click on tree, remove item and teleport

wafuboe

Active Member
Joined
Dec 24, 2010
Messages
884
Solutions
2
Reaction score
26
Well im requesting a tree that if you click on it having a certain item, it will teleport you and give a storage to be able to use it again removing the item.

Also if someone is on a certain area, nobody can use the script, unless there is no one in a certain area
 
Post your distro, example: TFS 1.2

So you want your script:
-Remove an item once
-Allow player to teleport to place forever after the first time he uses the tree and item is removed
-If a player is already in place the tree is teleporting than it won't let you enter

Correct?
 
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local QuestItem = 1234
    local Tree = 5678

    if target.uid == Tree and Game.getStorageValue(xxx) < 1 then
    if player:removeItem(QueatItem, 1) then
        player:setStorageValue(123, 1)
        fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'hello *****.')
        toPosition:sendMagicEffect(CONST_ME_TELEPORT)
        Game.setStorageValue(xxx, 1)
         end
    end
 
    return true
end

on the map editor go to the tree and set the Unique id = 5678
 
Last edited:
I wouldn't use that code. Any tree you put on the map with that item id would be able to be used as a teleport.

Code:
 local QuestItem = 1234
local Tree = 5678

xxx
end

return true
end

if the target.uid == Tree (local Tree above) = 5678< you can change the id for the item that you need.
 
i already added two lines using game.storage.
you can do something like.
when the player use the tree.
addEvent()

something like.

local function clean area- that ones from warzones will work.

i can do it for you.
give me more parameters, and the pos from, to.
 
LUA:
local itemid = 1234,
local storageKey = 8888,
local centerPosition = Position(644, 748, 7),
local teleportPosition = Position(1, 2, 3)

--// <action actionid="4444" script="teleportTree.lua"/>

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local specs = Game.getSpectators(centerPosition, false, true, 7, 7, 3, 3)
    if (#specs > 0) then
        return player:sendTextMessage("Player is in area.")
    end
    if (player:getStorageValue(storageKey) == 1) or (player:removeItem(itemid, 1) and player:setStorageValue(storageKey, 1)) then
        player:teleportTo(teleportPosition)
        teleportPosition:sendMagicEffect(CONST_ME_TELEPORT)
    end
    return true
end
 
LUA:
local itemid = 1234,
local storageKey = 8888,
local centerPosition = Position(644, 748, 7),
local teleportPosition = Position(1, 2, 3)

--// <action actionid="4444" script="teleportTree.lua"/>

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local specs = Game.getSpectators(centerPosition, false, true, 7, 7, 3, 3)
    if (#specs > 0) then
        return player:sendTextMessage("Player is in area.")
    end
    if (player:getStorageValue(storageKey) == 1) or (player:removeItem(itemid, 1) and player:setStorageValue(storageKey, 1)) then
        player:teleportTo(teleportPosition)
        teleportPosition:sendMagicEffect(CONST_ME_TELEPORT)
    end
    return true
end
thanks you xeraphus :D ill test it
 
Back
Top