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

I need help with make special TP.

DrComet

New Member
Joined
Nov 25, 2014
Messages
63
Reaction score
3
Hello everyone!

Today I want to ask You for way to make special TP. For example. The player have to put 3-4 items in different places and then stand on Stone Tile to be teleported to hidden area. Also I would know how to make normal teleport with use lever and some item required to be placed on, for example, Coal Basin.

0.3.6 / Forgotten Server / 8.6

Best regards,
Dr Comet
 
Code:
local config = {
   {pos = {x = 100, y = 100, z = 7}, itemid = 2112},
   {pos = {x = 120, y = 110, z = 7}, itemid = 2112},
   {pos = {x = 105, y = 120, z = 7}, itemid = 2112}
}

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
         end
     end
     if amount == #config then
         for x = 1, #config do
             doRemoveItem(getTileItemById(config[x].pos, config[x].itemid).uid, 1)
         end
         doTeleportThing(cid, {x = 100, y = 100, z = 7}) -- where it should go
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You found a hidden area.")
     end
     return true
end
For lever you can use function onUse.
 
Last edited:
Code:
local config = {
   {pos = {x = 100, y = 100, z = 7}, itemid = 2112},
   {pos = {x = 120, y = 110, z = 7}, itemid = 2112},
   {pos = {x = 105, y = 120, z = 7}, itemid = 2112}
}

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
         end
     end
     if amount == #config do
         for x = 1, #config do
             doRemoveItem(getTileItemById(config[x].pos, config[x].itemid).uid, 1)
         end
         doTeleportThing(cid, {x = 100, y = 100, z = 7}) -- where it should go
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You found a hidden area.")
     end
     return true
end
For lever you can use function onUse.
mmm i tried it and that's what i made

made script on action for lever

<action actionid="6502" script="games/hiddenplace.lua"/> <!-- hidden place -->

after then made script on server/action/games/hiddenpalce


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 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
end
end
if amount == #config do
for x = 1, #config do
doRemoveItem(getTileItemById(config[x].pos, config[x].itemid).uid, 1)
end
doTeleportThing(cid, {x = 1050, y = 822, z = 6}) -- where it should go
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You found a hidden area.")
end
return true
end

and edited it on map and made lever with uniqueid 10995

and doesn't work may you say to me what is the problem?

[30/11/2014 02:24:10] [Error - LuaScriptInterface::loadFile] data/actions/scripts/games/hiddenplace.lua:15: 'then' expected near 'do'
[30/11/2014 02:24:10] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/games/hiddenplace.lua)
[30/11/2014 02:24:10] data/actions/scripts/games/hiddenplace.lua:15: 'then' expected near 'do'
 
I just changed one do to a then on line 15, try it:
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 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
end
end
if amount == #config then
for x = 1, #config do
doRemoveItem(getTileItemById(config[x].pos, config[x].itemid).uid, 1)
end
doTeleportThing(cid, {x = 1050, y = 822, z = 6}) -- where it should go
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You found a hidden area.")
end
return true
end
 
I just changed one do to a then on line 15, try it:
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 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
end
end
if amount == #config then
for x = 1, #config do
doRemoveItem(getTileItemById(config[x].pos, config[x].itemid).uid, 1)
end
doTeleportThing(cid, {x = 1050, y = 822, z = 6}) -- where it should go
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You found a hidden area.")
end
return true
end

thats what i found this time? :D
[30/11/2014 02:33:10] [Warning - Event::loadScript] Event onUse not found (data/actions/scripts/games/hiddenplace.lua)
 
change this:
Code:
function onStepIn(cid, item, position, fromPosition)
to:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

OnStepIn is a movement function if you're walking directly into the TP.
Since you changed to pulling a lever you need to use onUse, an action function.

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 onUse(cid, item, fromPosition, itemEx, toPosition)
local amount = 0
for x = 1, #config do
if getTileItemById(config[x].pos, config[x].itemid).uid > 0 then
amount = amount + 1
end
end
if amount == #config then
for x = 1, #config do
doRemoveItem(getTileItemById(config[x].pos, config[x].itemid).uid, 1)
end
doTeleportThing(cid, {x = 1050, y = 822, z = 6}) -- where it should go
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You found a hidden area.")
end
return true
end
 
Last edited:
change this:
Code:
function onStepIn(cid, item, position, fromPosition)
to:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

OnStepIn is a movement if you're walking directly into the TP. Since you changed to lever you need to make onUse

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 onUse(cid, item, fromPosition, itemEx, toPosition)
local amount = 0
for x = 1, #config do
if getTileItemById(config[x].pos, config[x].itemid).uid > 0 then
amount = amount + 1
end
end
if amount == #config then
for x = 1, #config do
doRemoveItem(getTileItemById(config[x].pos, config[x].itemid).uid, 1)
end
doTeleportThing(cid, {x = 1050, y = 822, z = 6}) -- where it should go
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You found a hidden area.")
end
return true
end
okey but the problem now is what is the function on action.xml
actionid/uniqueid/fromid/etc

and what i must do on map editor to make it work?
i mean which number i must write on lever ,uniqueid or actionid?!
thx
 
I think you wrote earlier that you made it a uniqueid already right?
and edited it on map and made lever with uniqueid 10995

So then yes on your map editor you will make the lever unique id 10995.

in actions.xml you will right:
Code:
<action uniqueid="10995" event="script" value="games/hiddenplace.lua"/>
 
I think you wrote earlier that you made it a uniqueid already right?


So then yes on your map editor you will make the lever unique id 10995.

in actions.xml you will right:
Code:
<action uniqueid="10995" event="script" value="games/hiddenplace.lua"/>
thx worked :)
 
Back
Top