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

Click lever and teleport to xxxx yyyy

George00

propro
Joined
Jan 11, 2014
Messages
163
Solutions
1
Reaction score
10
Location
propro
isnt there a script if u stand in a tile and u click a lever if u have 1 boss coin u will be teleport to another area? i cant find the script
 
Solution
So i have this
Code:
local item_required = 9020
local item_count = 1
local destination = { x = 1473, y = 1046, z = 7 }
local function reset(pos)
   doTransformItem(getTileItemById(pos, 1946).uid, 1945)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
   -- check if lever is currently used
   if item.itemid == 1946 then
       return doPlayerSendTextMessage(cid, 22, "Wait for switch to reset.")
   end
   -- check if player has item
   if getPlayerItemCount(cid, item_required) < item_count then
       return doPlayerSendTextMessage(cid, 22, "You do not have the required item to use this lever.")
   end
   -- remove item, transform lever, and add reset
   doTeleportThing(cid, {x = 1473, y = 1046, z = 7})...
Remember to read the rules when posting on the boards.

tfs 0.3.7

lever id for map = 1945
XML:
<action actionid="45001" event="script" value="script_name.lua"/>
Lua:
local item_required = 1111
local item_count = 1
local destination = { x = 1000, y = 1000, z = 7 }

local function reset(pos)
   doTransformItem(getTileItemById(pos, 1946).uid, 1945)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)

   -- check if lever is currently used
   if item.itemid == 1946 then
       return doPlayerSendTextMessage(cid, 22, "Wait for switch to reset.")
   end

   -- check if player has item
   if getPlayerItemCount(cid, item_required) < item_count then
       return doPlayerSendTextMessage(cid, 22, "You do not have the required item to use this lever.")
   end

   -- remove item, transform lever, and add reset
   doTeleportThing(cid, destination)
   doPlayerRemoveItem(cid, item_required, item_count)
   doTransformItem(item.uid, item.itemid + 1)
   addEvent(reset, 10 * 1000, toPosition)

   return true
end
 
Last edited by a moderator:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
should i insert function onUse(cid, item, from x1469 y1046, itemEx, to x1471 y1046
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
should i insert function onUse(cid, item, from x1469 y1046, itemEx, to x1471 y1046

No ..
You add the XML line to data/actions/actions.xml
Then you create a file called script_name.lua in data/actions/scripts (note the name and folder can be changed if you wish, just remember to edit the XML code aswell).
Then you paste the code into that file, save both files, restart your server.

Everything will now work if you have a lever with the action id 45001
 
So i have this
Code:
local item_required = 9020
local item_count = 1
local destination = { x = 1473, y = 1046, z = 7 }
local function reset(pos)
   doTransformItem(getTileItemById(pos, 1946).uid, 1945)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
   -- check if lever is currently used
   if item.itemid == 1946 then
       return doPlayerSendTextMessage(cid, 22, "Wait for switch to reset.")
   end
   -- check if player has item
   if getPlayerItemCount(cid, item_required) < item_count then
       return doPlayerSendTextMessage(cid, 22, "You do not have the required item to use this lever.")
   end
   -- remove item, transform lever, and add reset
   doTeleportThing(cid, {x = 1473, y = 1046, z = 7})
   doPlayerRemoveItem(cid, item_required, item_count)
   doTransformItem(item.uid, item.itemid + 1)
   addEvent(reset, 10 * 1000, toPosition)
   return true
end
I have set the item required to 9020 which is the boss token but it still doesnt work

The lever id is 1945
Action id 45001

Solved just naming issuses with the xml file thanks!
 
Last edited by a moderator:
Solution
Back
Top