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

Make items Teleport you?

XxDeathAvenger

New Member
Joined
May 5, 2011
Messages
95
Reaction score
2
Can someone help me make a certain item teleport me to a certain coordinate?
Help would be appreciated, thank you.
 
Try this one:
Code:
local config = {
  [2160] = {x = 100, y = 100, z = 7}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
  local position = config[item.itemid]
  if position == nil then
    return false
  end

  Player(cid):teleportTo(position)
  return true
end
 
Last edited by a moderator:
Code:
local truepos = {x=1000, y=1000, z=7}

function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerLevel(cid) >= Place_level_here then
doTeleportThing(cid, truepos, TRUE)
doCreatureSay(cid, "Teleported!", 19)
end
return true
end
Harder than that isnt it :p
Way easier configurable aswell

Heres a version where the player cant teleport if pz locked
Code:
local truepos = {x=1000, y=1000, z=7}

function onUse(cid, item, fromPosition, itemEx, toPosition)
if isPlayerPzLocked(cid) then
doTeleportThing(cid, truepos, FALSE)
doCreatureSay(cid, "You cannot teleport while pz locked!", 19)
else
doTeleportThing(cid, truepos, TRUE)
doCreatureSay(cid, "Teleported!", 19)
end
return true
end
 
im not very good at scripting at all, i just started. So, im not really sure where to insert this script.

In actions.
Be sure to put into the actions.xml right itemid and connect it to the script.
And also, always say what server you use.
 
Ok, you choose whatever script you wanna use then you go to data -> Actions and then your gonna see a file called "actions.xml" click on edit and add a new actions line and define what item you wanna use. You also gotta point the value="teleportfile.lua" thingy aswell. you gotta define where your file is.
 
Aww, it wouldn't work, and I noticed it said "function," rather than "script." So I changed it to script, and it debugged me.
Maybe another script would work?
 
Code:
local truepos = {x=1000, y=1000, z=7} -- Position the player will be send when use

function onUse(cid, item, fromPosition, itemEx, toPosition) -- Function
if isPlayerPzLocked(cid) then   -- PZlock check
doTeleportThing(cid, truepos, FALSE) -- if Pzlock it do not teleport
doCreatureSay(cid, "You cannot teleport while pz locked!", 19) - player will get msg if pz lock
else
doTeleportThing(cid, truepos, TRUE) -- if no pz lock player gets teleported
doCreatureSay(cid, "Teleported!", 19) -- player will get msg when teleport happend
end
return true
end

I tried to make it more clearly for you !

@DestinationSer


ty for script :)


In your actions.xml put this

Code:
<action itemid="ITEMID" event="script" value="YOURSCRIPTNAME.lua"/>
 
This is the actions.xml <action itemid="8976" script="other/goldenfalcon.lua"/>

This is the script I used

local truepos = {x=351, y=198, z=7}

function onUse(cid, item, fromPosition, itemEx, toPosition)
if isPlayerPzLocked(cid) then
doTeleportThing(cid, truepos, FALSE)
doCreatureSay(cid, "You cannot teleport while pz locked!", 19)
else
doTeleportThing(cid, truepos, TRUE)
doCreatureSay(cid, "Teleported!", 19)
end
return true
end

When I log back in, I had been teleported, I just debug.
 
Try this
Code:
local truepos = {x=351, y=198, z=7}

function onUse(cid, item, fromPosition, itemEx, toPosition)
if isPlayerPzLocked(cid) >= 1 then
doTeleportThing(cid, truepos, FALSE)
doCreatureSay(cid, "You cannot teleport while pz locked!", 19)
end
elseif isPlayerPzLocked(cid) < 0 then
doTeleportThing(cid, truepos, TRUE)
doCreatureSay(cid, "Teleported!", 19)
end
return true
end
I dont know if itll work but go ahead and try.
 
I'm using tfs 0.2.10
So maybe not, I'm not sure. I'm having a lot of trouble with this, I just dont know how to use a different client or server or anything. :s
 
Back
Top