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

Solved Create Teleport

Mera Mero

Guess Who?
Joined
Dec 27, 2014
Messages
417
Reaction score
86
Hello otlanders I Got this script but i got error with it and this errors appear when my teleport going to disappear
Code:
local config = {
{pos = {x = 979, y = 975, z = 7}, itemid = 2001},
{pos = {x = 971, y = 975, z = 7}, itemid = 2002},
{pos = {x = 970, y = 981, z = 7}, itemid = 2003},
{pos = {x = 979, y = 981, z = 7}, itemid = 2004}
}

function deleteTeleport(tpUid)
    doRemoveItem(tpUid)
end

function onStepIn(cid, item, position, fromPosition)
     local amount = 0
     for x = 1, #config do
         if getTileItemById(config[x].pos, config[x].itemid).uid > 0 then
             amount = amount + 1
         else
             doPlayerSendCancel(cid, "You need to add items at first to make teleport to hidden place")
         end
     end
     if amount == #config then -- if all items are found then
         for x = 1, #config do
             doRemoveItem(getTileItemById(config[x].pos, config[x].itemid).uid, 1)
         end
        teleTimer = 5000 -- 5 seconds
         teleUid = doCreateTeleport(1387, {x = 975, y = 978, z = 6}, {x = 975, y = 978, z = 7}) -- identifier for created portal
         addEvent(deleteTeleport, teleTimer, teleUid) -- delete portal in 5 seconds, using UID
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You found a hidden area.")
     else -- if not all items are found
      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "put it in correct place")  
     end
     return true
end
error
Code:
[27/02/2015 23:22:50] [Error - MoveEvents Interface]
[27/02/2015 23:22:51] In a timer event called from:
[27/02/2015 23:22:51] data/movements/scripts/hiddenplace.lua:onStepIn
[27/02/2015 23:22:51] Description:
[27/02/2015 23:22:51] (luaDoRemoveItem) Item not found
TFS 0.3.6

bump
 
Last edited by a moderator:
I made it like this but got another error
Code:
local config = {
{pos = {x = 979, y = 975, z = 7}, itemid = 2001},
{pos = {x = 971, y = 975, z = 7}, itemid = 2002},
{pos = {x = 970, y = 981, z = 7}, itemid = 2003},
{pos = {x = 979, y = 981, z = 7}, itemid = 2004}
}

local function deleteTeleport(tp)
   if(teleport > 0) then
     doRemoveItem(teleport)
     doSendMagicEffect(tp, CONST_ME_POFF)
   end
   return true
end

function onStepIn(cid, item, position, fromPosition)
     local amount = 0
     for x = 1, #config do
         if getTileItemById(config[x].pos, config[x].itemid).uid > 0 then
             amount = amount + 1
         else
             doPlayerSendCancel(cid, "You need to add items at first to make teleport to hidden place")
         end
     end
     if amount == #config then -- if all items are found then
         for x = 1, #config do
             doRemoveItem(getTileItemById(config[x].pos, config[x].itemid).uid, 1)
         end
        teleTimer = 5000 -- 5 seconds
         teleUid = doCreateTeleport(1387, {x = 975, y = 978, z = 6}, {x = 975, y = 978, z = 7}) -- identifier for created portal
         addEvent(deleteTeleport, teleTimer, teleUid) -- delete portal in 5 seconds, using UID
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You found a hidden area.")
     else -- if not all items are found
      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "put it in correct place")   
     end
     return true
end
Code:
[28/02/2015 13:55:30] [Error - MoveEvents Interface]
[28/02/2015 13:55:30] In a timer event called from:
[28/02/2015 13:55:30] data/movements/scripts/hiddenplace.lua:onStepIn
[28/02/2015 13:55:30] Description:
[28/02/2015 13:55:30] data/movements/scripts/hiddenplace.lua:9: attempt to compare number with nil
[28/02/2015 13:55:31] stack traceback:
[28/02/2015 13:55:31]     data/movements/scripts/hiddenplace.lua:9: in function <data/movements/scripts/hiddenplace.lua:8>
May someone help me please?!
 
u can use something like this
function doRemoveTeleport(pos)
doRemoveItem(getTileItemById(pos, 1387).uid, 2)
doBroadcastMessage("The teleport is removed.")
return true
end
 
You can not add uniqueids in addEvent, uniqueids of items change (unless you add an uniqueid in the map editor, then it will always have that uniqueid), so by the time it runs the function, the uniqueid is already different, so it can't find the item based on that old uniqueid.
Get the new uniqueid in the function deleteTeleport with getTileItemById.
Code:
local function deleteTeleport(tp)
     local teleport = getTileItemById(tp, 1387).uid
     if teleport > 0 then
         doRemoveItem(teleport)
         doSendMagicEffect(tp, CONST_ME_POFF)
     end
     return true
end

Code:
addEvent(deleteTeleport, 30 * 1000, {x = 975, y = 978, z = 7})
 
You can not add uniqueids in addEvent, uniqueids of items change (unless you add an uniqueid in the map editor, then it will always have that uniqueid), so by the time it runs the function, the uniqueid is already different, so it can't find the item based on that old uniqueid.
Get the new uniqueid in the function deleteTeleport with getTileItemById.
Code:
local function deleteTeleport(tp)
     local teleport = getTileItemById(tp, 1387).uid
     if teleport > 0 then
         doRemoveItem(teleport)
         doSendMagicEffect(tp, CONST_ME_POFF)
     end
     return true
end

Code:
addEvent(deleteTeleport, 30 * 1000, {x = 975, y = 978, z = 7})
Thanks its working good now and thanks for your advice :)
 
this more edite if u want we always learn from @Limos still best support here
Code:
local config = {
{pos = {x = 993, y = 1001, z = 5}, itemid = 2001},
{pos = {x = 993, y = 995, z = 5}, itemid = 2002},
{pos = {x = 1007, y = 1001, z = 5}, itemid = 2003},
{pos = {x = 1007, y = 995, z = 5}, itemid = 2004}
}

local function deleteTeleport(tp)
     local teleport = getTileItemById(tp, 1387).uid
     if teleport > 0 then
         doRemoveItem(teleport)
         doSendMagicEffect(tp, CONST_ME_POFF)
         doSendAnimatedText({x = 1004, y = 997, z = 5}, "Closed", TEXTCOLOR_RED)
     end
     return true
end

function onStepIn(cid, item, position, fromPosition)
     local amount = 0
     for x = 1, #config do
         if getTileItemById(config[x].pos, config[x].itemid).uid > 0 then
             amount = amount + 1
         else
             doPlayerSendCancel(cid, "You need to add items at first to make teleport to hidden place")
         end
     end
     if amount == #config then -- if all items are found then
         for x = 1, #config do
             doRemoveItem(getTileItemById(config[x].pos, config[x].itemid).uid, 1)
         end
                         for x = 1, 30 do
        local n = 30 - x
            addEvent(doSendAnimatedText, x * 1000, {x = 1004, y = 997, z = 5}, n > 0 and tostring(n), TEXTCOLOR_TEAL)
        end
        teleTimer = 5000 -- 5 seconds
         teleUid = doCreateTeleport(1387, {x = 1000, y = 1000, z = 7}, {x = 1004, y = 997, z = 5}) -- identifier for created portal
         addEvent(deleteTeleport, 30 * 1000, {x = 1004, y = 997, z = 5})
         doSendAnimatedText({x = 1004, y = 997, z = 5}, "GO", 20)
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You found a hidden area.")
         doSendMagicEffect({x = 1004, y = 997, z = 5}, 56)
     else -- if not all items are found
      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "put it in correct place")  
     end
     return true
end
 
this more edite if u want we always learn from @Limos still best support here
Code:
local config = {
{pos = {x = 993, y = 1001, z = 5}, itemid = 2001},
{pos = {x = 993, y = 995, z = 5}, itemid = 2002},
{pos = {x = 1007, y = 1001, z = 5}, itemid = 2003},
{pos = {x = 1007, y = 995, z = 5}, itemid = 2004}
}

local function deleteTeleport(tp)
     local teleport = getTileItemById(tp, 1387).uid
     if teleport > 0 then
         doRemoveItem(teleport)
         doSendMagicEffect(tp, CONST_ME_POFF)
         doSendAnimatedText({x = 1004, y = 997, z = 5}, "Closed", TEXTCOLOR_RED)
     end
     return true
end

function onStepIn(cid, item, position, fromPosition)
     local amount = 0
     for x = 1, #config do
         if getTileItemById(config[x].pos, config[x].itemid).uid > 0 then
             amount = amount + 1
         else
             doPlayerSendCancel(cid, "You need to add items at first to make teleport to hidden place")
         end
     end
     if amount == #config then -- if all items are found then
         for x = 1, #config do
             doRemoveItem(getTileItemById(config[x].pos, config[x].itemid).uid, 1)
         end
                         for x = 1, 30 do
        local n = 30 - x
            addEvent(doSendAnimatedText, x * 1000, {x = 1004, y = 997, z = 5}, n > 0 and tostring(n), TEXTCOLOR_TEAL)
        end
        teleTimer = 5000 -- 5 seconds
         teleUid = doCreateTeleport(1387, {x = 1000, y = 1000, z = 7}, {x = 1004, y = 997, z = 5}) -- identifier for created portal
         addEvent(deleteTeleport, 30 * 1000, {x = 1004, y = 997, z = 5})
         doSendAnimatedText({x = 1004, y = 997, z = 5}, "GO", 20)
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You found a hidden area.")
         doSendMagicEffect({x = 1004, y = 997, z = 5}, 56)
     else -- if not all items are found
      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "put it in correct place") 
     end
     return true
end
Thanks
 
Back
Top