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

Action Create Escape Teleport

Status
Not open for further replies.

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Solutions
2
Reaction score
115
The Forgotten Server 0.3.5

data/actions/actions.xml
PHP:
<action uniqueid="1000" script="create_tele.lua" />
Unique ID must be edited and inputed through the mapeditor.

data/actions/scripts/script.lua
Lua:
local config =
{
    newPos = {x=100, y=100, z=7}, -- New player position
    teleportPos = {x=100, y=100, z=7}, -- Teleport position
    LeverPos = {x=100, y=100, z=7}, -- Lever position
    timeToRemove = 10 -- Seconds
}

function onUse(cid, item, fromPos, item2, toPos)
local teleport = getTileItemById(config.teleportPos, 1387)
local playerPos = getCreaturePosition(cid)
    if item.itemid == 1945 then
	doCreateTeleport(1387, config.newPos, config.teleportPos)
	doSendMagicEffect(config.teleportPos, CONST_ME_TELEPORT)
	doSendMagicEffect(playerPos, CONST_ME_GIFT_WRAPS)
	doCreatureSay(cid, "The teleport has been created!", TALKTYPE_ORANGE_1)
	addEvent(doRemoveTeleport, config.timeToRemove * 1000)
    elseif item.itemid == 1946 then
        doPlayerSendCancel(cid, "The teleport has already been created.")
    return TRUE
    end
end

function doRemoveTeleport()
local teleport = getTileItemById(config.teleportPos, 1387)
local Lever = getTileItemById(config.LeverPos, 1946)
    if teleport.uid > 0 then
	doRemoveItem(teleport.uid)
        doSendMagicEffect(config.teleportPos, CONST_ME_POFF)
        doTransformItem(Lever.uid, 1945)
    end
end

The Forgotten Server 0.2.5

Lua:
local config =
{
    newPos = {x=100, y=100, z=7}, -- New player position
    teleportPos = {x=100, y=100, z=7}, -- Teleport position
    LeverPos = {x=100, y=100, z=7}, -- Lever position
    timeToRemove = 10 -- Seconds
}

function onUse(cid, item, fromPos, item2, toPos)
local teleport = getThingfromPos(config.teleportPos, 1387)
local playerPos = getPlayerPosition(cid)
    if item.itemid == 1945 then
        doCreateTeleport(1387, config.newPos, config.teleportPos)
        doSendMagicEffect(config.teleportPos, CONST_ME_TELEPORT)
        doSendMagicEffect(playerPos, CONST_ME_GIFT_WRAPS)
        doCreatureSay(cid, "The teleport has been created!", TALKTYPE_ORANGE_1)
        addEvent(doRemoveTeleport, config.timeToRemove * 1000)
    elseif item.itemid == 1946 then
        doPlayerSendCancel(cid, "The teleport has already been created.")
    return TRUE
    end
end

function doRemoveTeleport()
local teleport = getThingfromPos(config.teleportPos, 1387)
local Lever = getThingfromPos(config.LeverPos, 1946)
    if teleport.uid > 0 then
        doRemoveItem(teleport.uid)
        doSendMagicEffect(config.teleportPos, CONST_ME_POFF)
        doTransformItem(Lever.uid, 1945)
    end
end
 
Last edited:
No Comments? :huh:
 
Last edited:
@Zonet,
It works, don't know what to tell ya. :thumbup:
 
Last edited:
@Topic,

From this script, you could make timed quests.
Pull lever, it creates teleports in certain areas, gogogo finish quest!
I haven't done it yet, but it sounds fun :eek:
 
:huh: Comment~
 
Doest it work on tfs 0,2,4?

Btw can you post a talking teleport for tfs 0,2,4 :S that says "Teleport Room" and that things :p

:D:D Waiting :D:D
 
Last edited by a moderator:
No, I do not think this works on TFS 0.2.4
and No, I won't make the talking teleports, because there are many already.

Search function :thumbup:
 
Didn't you know that
Code:
        return 1
dont work in 0.3.4+ ;)

return 0 = return FALSE
return 1 = return TRUE

JDB trust Zonbet.

It's better if you write "return TRUE".

Regards,
Shawak
 
I am well aware of that,
but I will do it anyway...if it will satisfy people.

Regards :cool:
 
Didn't you know that
Code:
        return 1
dont work in 0.3.4+ ;)

return 0 = return FALSE
return 1 = return TRUE

hmm it's const in lib's... 1 = TRUE, 0 = FALSE if he made return 1 it's works to, because const is veriable. :)
 
@Azi,

Thanks for the input. :cool:
 
@ JDB
Use tsf v2.3, is why it modifies your script, if teleport creates the item, and gives teleport me to the position, but what it does not do it is to disappear teleport.... it tries several forms but it follows without working.....

Lua:
function onUse(cid, item, frompos, item2, topos)

  local config =
{
    newPos = {x=112, y=80, z=7}, -- New player position
    teleportPos = {x=frompos.x+1, y=frompos.y-1, z=frompos.z, stackpos=1}, -- Teleport position
    timeToRemove = 10 -- Seconds
}

local teleport = getThingfromPos(config.teleportPos)
local playerPos = getCreaturePosition(cid)
    if (item.itemid == 3728) then
        doCreateTeleport(1387, config.newPos, config.teleportPos)
        doSendMagicEffect(config.teleportPos, CONST_ME_TELEPORT)
        doSendMagicEffect(playerPos, CONST_ME_MAGIC_RED)
        doCreatureSay(cid, "Teleport!", TALKTYPE_ORANGE_1)
        addEvent(doRemoveTeleport, config.timeToRemove * 1000)
    return TRUE
    end
end

function doRemoveTeleport()
local teleport = getThingfromPos{x=frompos.x+1, y=frompos.y-1, z=frompos.z, stackpos=1}
        doRemoveItem(teleport.uid)
        doSendMagicEffect(config.teleportPos, CONST_ME_POFF)

    end
 
@Up,

Because this script was tested and created based on 0.3.4
I suggest you switch to TFS 0.3, or request a 0.2 version by PM.
 
Last edited:
Converted to Mystic Spirit 0.2
Tested on 0.2.5, worked perfectly.
Lua:
--- Scripted by JDB, Mystic Spirit 0.2.5 fix by Znote ---
local config =
{
    newPos = {x=277, y=1258, z=6}, -- New player position
    teleportPos = {x=283, y=1257, z=6}, -- Teleport position
    LeverPos = {x=281, y=1256, z=6}, -- Lever position
    timeToRemove = 10 -- Seconds
}

function onUse(cid, item, frompos, item2, topos)
local teleport = getTileItemById(config.teleportPos, 1387)
local playerPos = getCreaturePosition(cid)
    if item.itemid == 1945 then
        doCreateTeleport(1387, config.newPos, config.teleportPos)
        doSendMagicEffect(config.teleportPos, CONST_ME_TELEPORT)
        doSendMagicEffect(playerPos, CONST_ME_GIFT_WRAPS)
        doCreatureSay(cid, "The teleport has been created!", TALKTYPE_ORANGE_1)
        addEvent(doRemoveTeleport, config.timeToRemove * 1000)
    elseif item.itemid == 1946 then
        doPlayerSendCancel(cid, "The teleport has already been created.")
    return TRUE
    end
end

function doRemoveTeleport()
local teleport = getTileItemById(config.teleportPos, 1387)
local Lever = getTileItemById(config.LeverPos, 1946)
    if teleport.uid > 0 then
        doRemoveItem(teleport.uid)
        doSendMagicEffect(config.teleportPos, CONST_ME_POFF)
    end
end

The 0.3.5 example also worked in practical on TFS 0.2.5, but displayed console error and slowed the server down when it tried to transform the lever. Its not neccesary to do that in lua, since its already hardcoded into the server.


edit1:

ahahah it looks like it was created a 0.2 sample by the author for 6 minutes ago. :p
 
Last edited:
No Comments? :huh:
As I said in my first post, I haven't tested it.
(Can someone test it, and post?)

If no tested why post it? -.-"
_______________________________
Nice script! ^^
 
Status
Not open for further replies.
Back
Top