Action Create Escape Teleport

Status
Not open for further replies.

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
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:
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
No Comments? :huh:
 
Last edited:
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
@Zonet,
It works, don't know what to tell ya. :thumbup:
 
Last edited:
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
@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:
 
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
:huh: Comment~
 

life4me

Don't dream it, be it.
Joined
Jun 27, 2009
Messages
928
Best answers
0
Reaction score
15
Location
Otland
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:
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
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:
 

life4me

Don't dream it, be it.
Joined
Jun 27, 2009
Messages
928
Best answers
0
Reaction score
15
Location
Otland
Already found one, THANKS ANYWAY!!
 

Shawak

Intermediate OT User
Joined
Sep 11, 2008
Messages
1,976
Best answers
2
Reaction score
101
Location
Germany
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
 
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
I am well aware of that,
but I will do it anyway...if it will satisfy people.

Regards :cool:
 

Azi

Banned User
Joined
Aug 12, 2007
Messages
1,167
Best answers
0
Reaction score
51
Location
Włocławek
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. :)
 
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
@Azi,

Thanks for the input. :cool:
 

Wifixs

New Member
Joined
Jul 20, 2009
Messages
18
Best answers
0
Reaction score
1
@ 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
 
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
@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:

Znote

<?php echo $title; ?>
Staff member
Global Moderator
Premium User
Joined
Feb 14, 2008
Messages
6,667
Best answers
202
Reaction score
1,375
Location
Norway, Oslo
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:

Aeron

www.Asgard-World.com
Joined
Jul 23, 2009
Messages
231
Best answers
0
Reaction score
3
Location
Spain
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.
Top