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

Create a teleport

cirtaboy

Offensive if u r jew 卍
Joined
Jul 31, 2008
Messages
1,946
Reaction score
19
Location
Sweden
Hello, im requesting this wonderful script, really cool actualy.
When you say, Utevo res "temple. It will create a teleport to take you to your temple position.


It should only be avaible to premium account.
After 10 secounds the teleport will be gone.

Other players can enter teleport but they will be taken to "YOUR"
temple position.

Will take 500 mana and 10 soul points. ^_^
 
Not tested version:

something.lua (Also you need to declare in talkactions.xml)
Code:
--Author: Slawkens
--CONFIG
local MANA_NEEDED = 500 --0 to disable
local SOUL_NEEDED = 10 --0 to disable
local TIME_TO_REMOVE = 10 -- in seconds  (After this time teleport will be removed)

function onSay(cid, words, param)
	if param == "temple" then
		if isPremium(cid) == TRUE then
			if getCreatureMana(cid) >= MANA_NEEDED or MANA_NEEDED == 0 then
				if getPlayerSoul(cid) >= SOUL_NEEDED or SOUL_NEEDED == 0 then
					local playerPos = getCreaturePos(cid)
					local teleportPos = getNextPosFromDir(playerPos, getPlayerLookDir(cid), 1)
					teleportPos.stackpos = STACKPOS_TOP_FIELD
					if getThingfromPos(teleportPos).itemid ~= 1387 then
						if(SOUL_NEEDED ~= 0) then doPlayerAddSoul(cid, -SOUL_NEEDED) end
						if(MANA_NEEDED ~= 0) then doCreatureAddMana(cid, -MANA_NEEDED) end
						tpUID = doCreateTeleport(1387, getTemplePositionById(getPlayerTown(cid)), 

teleportPos)
						doSendMagicEffect(teleportPos, CONST_ME_TELEPORT)
						addEvent(doRemoveItem, TIME_TO_REMOVE * 100, tpUID)
					end
				else
					doPlayerSendCancel(cid, "You do not have enough soul.")
				end
			else
				doPlayerSendCancel(cid, "You do not have enough mana.")
			end
		else
			doPlayerSendCancel(cid, "You need a premium account.")
		end
	end
	return TRUE
end

Make sure you also have this lua function in functions.lua or global.lua:
http://otland.net/f163/getnextposfromdir-8982/
 
You can copy it from 0.3:
[forgottenserver] Index of /tags/0.3a2

Or if you don't have much names, you can use istead do something like this:
Top of the script add:
Code:
local townPoses =
{
	{x = 111, y = 222, z = 333}, --TemplePos for TownId = 1
	{x = 444, y = 555, z = 666}, --TemplePos for TownId = 2
	{x = 777, y = 888, z = 999}, --TemplePos for TownId = 3
}

And this:
getTemplePositionById(getPlayerTown(cid))

Change to:
townPoses[getPlayerTown(cid)]
 
Code:
--Author: Slawkens
--CONFIG
local MANA_NEEDED = 500 --0 to disable
local SOUL_NEEDED = 10 --0 to disable
local TIME_TO_REMOVE = 10 -- in seconds  (After this time teleport will be removed)
local townPoses =
{
	{x = 111, y = 222, z = 333}, --TemplePos for TownId = 1
	{x = 444, y = 555, z = 666}, --TemplePos for TownId = 2
	{x = 777, y = 888, z = 999}, --TemplePos for TownId = 3
}

function onSay(cid, words, param)
	if param == "temple" then
		if isPremium(cid) == TRUE then
			if getCreatureMana(cid) >= MANA_NEEDED or MANA_NEEDED == 0 then
				if getPlayerSoul(cid) >= SOUL_NEEDED or SOUL_NEEDED == 0 then
					local playerPos = getCreaturePos(cid)
					local teleportPos = getNextPosFromDir(playerPos, getPlayerLookDir(cid), 1)
					teleportPos.stackpos = STACKPOS_TOP_FIELD
					if getThingfromPos(teleportPos).itemid ~= 1387 then
						if(SOUL_NEEDED ~= 0) then doPlayerAddSoul(cid, -SOUL_NEEDED) end
						if(MANA_NEEDED ~= 0) then doCreatureAddMana(cid, -MANA_NEEDED) end
						tpUID = doCreateTeleport(1387, townPoses[getPlayerTown(cid)], 

teleportPos)
						doSendMagicEffect(teleportPos, CONST_ME_TELEPORT)
						addEvent(doRemoveItem, TIME_TO_REMOVE * 100, tpUID)
					end
				else
					doPlayerSendCancel(cid, "You do not have enough soul.")
				end
			else
				doPlayerSendCancel(cid, "You do not have enough mana.")
			end
		else
			doPlayerSendCancel(cid, "You need a premium account.")
		end
	end
	return TRUE
end
@up, If u could make the whole code it would be alot easier, thanks!
Just copy and paste. :p

Jo3
 
I'm not sure about this part:
tpUID = doCreateTeleport(1387, townPoses[getPlayerTown(cid)], teleportPos)

It won't work actually, when revscriptsys will be done, It maybe will.

I can't test it, as I'm hosting enfo server and won't cause lags. ;p

Add this to functions.lua or global.lua
Code:
local function doRemoveItemFromPos(position)
	local itemToRemove = getThingfromPos(position).uid
	if itemToRemove ~= 0 then
		doRemoveItem(itemToRemove)
	else
		debugPrint("[Slaw: Error. Remove TP] Item does not exist o_0")
	end
end
[/end]

Script:
[code]
--Author: Slawkens
--CONFIG
local MANA_NEEDED = 500 --0 to disable
local SOUL_NEEDED = 10 --0 to disable
local TIME_TO_REMOVE = 10 -- in seconds  (After this time teleport will be removed)
local townPoses =
{
	{x = 111, y = 222, z = 333}, --TemplePos for TownId = 1
	{x = 444, y = 555, z = 666}, --TemplePos for TownId = 2
	{x = 777, y = 888, z = 999}, --TemplePos for TownId = 3
}

function onSay(cid, words, param)
	if param == "temple" then
		if isPremium(cid) == TRUE then
			if getCreatureMana(cid) >= MANA_NEEDED or MANA_NEEDED == 0 then
				if getPlayerSoul(cid) >= SOUL_NEEDED or SOUL_NEEDED == 0 then
					local playerPos = getCreaturePos(cid)
					local teleportPos = getNextPosFromDir(playerPos, getPlayerLookDir(cid), 1)
					teleportPos.stackpos = STACKPOS_TOP_FIELD
					if getThingfromPos(teleportPos).itemid ~= 1387 then
						if(SOUL_NEEDED ~= 0) then doPlayerAddSoul(cid, -SOUL_NEEDED) end
						if(MANA_NEEDED ~= 0) then doCreatureAddMana(cid, -MANA_NEEDED) end
						doCreateTeleport(1387, townPoses[getPlayerTown(cid)], teleportPos)
						doSendMagicEffect(teleportPos, CONST_ME_TELEPORT)
						addEvent(doRemoveItemFromPos, TIME_TO_REMOVE * 100, teleportPos)
					end
				else
					doPlayerSendCancel(cid, "You do not have enough soul.")
				end
			else
				doPlayerSendCancel(cid, "You do not have enough mana.")
			end
		else
			doPlayerSendCancel(cid, "You need a premium account.")
		end
	end
	return TRUE
end
 
Hello, im requesting this wonderful script, really cool actualy.
When you say, Utevo res "temple. It will create a teleport to take you to your temple position.

It should only be avaible to premium account.
After 10 secounds the teleport will be gone.

Other players can enter teleport but they will be taken to "YOUR"
temple position.

Will take 500 mana and 10 soul points.


mmm....

But does it works in rl TIBIA?

if it's not i hope Gm Fix IT ^^
 
Can you make a list of places that you can say?
Like:
Code:
[temple]
[depot]
[house]
[back]

Then a place to write the positions of each command.
Like Naruto's Advanced Teleportation.
 
Last edited:
Code:
newpos = {
["depot"] = {x=1029, y=996, z=7},
["temple"] = {x=1000, y=1000, z=7}, 
["house"] = {x=980, y=1117, z=7}, 
["back"] = { x = getPlayerStorageValue(cid, storage), y = getPlayerStorageValue(cid, storage+1), z = getPlayerStorageValue(cid, storage+2)}
}
 
Not really sure about this:
Code:
--Author: Slawkens
--CONFIG
local MANA_NEEDED = 500 --0 to disable
local SOUL_NEEDED = 10 --0 to disable
local TIME_TO_REMOVE = 10 -- in seconds  (After this time teleport will be removed)
local newpos = {
["depot"] = {x=1029, y=996, z=7},
["temple"] = {x=1000, y=1000, z=7}, 
["house"] = {x=980, y=1117, z=7}, 
["back"] = { x = getPlayerStorageValue(cid, storage), y = getPlayerStorageValue(cid, storage+1), z = getPlayerStorageValue(cid, storage+2)}
}


function onSay(cid, words, param)
	local teleport = newpos[param]
	if teleport then
		if isPremium(cid) == TRUE then
			if getCreatureMana(cid) >= MANA_NEEDED or MANA_NEEDED == 0 then
				if getPlayerSoul(cid) >= SOUL_NEEDED or SOUL_NEEDED == 0 then
					local playerPos = getCreaturePos(cid)
					local teleportPos = getNextPosFromDir(playerPos, getPlayerLookDir(cid), 1)
					teleportPos.stackpos = STACKPOS_TOP_FIELD
					if getThingfromPos(teleportPos).itemid ~= 1387 then
						if(SOUL_NEEDED ~= 0) then doPlayerAddSoul(cid, -SOUL_NEEDED) end
						if(MANA_NEEDED ~= 0) then doCreatureAddMana(cid, -MANA_NEEDED) end
						doCreateTeleport(1387, teleport, teleportPos)
						doSendMagicEffect(teleportPos, CONST_ME_TELEPORT)
						addEvent(doRemoveItemFromPos, TIME_TO_REMOVE * 100, teleportPos)
					end
				else
					doPlayerSendCancel(cid, "You do not have enough soul.")
				end
			else
				doPlayerSendCancel(cid, "You do not have enough mana.")
			end
		else
			doPlayerSendCancel(cid, "You need a premium account.")
		end
	end
	return TRUE
end

Mostly about this line:
doCreateTeleport(1387, teleport, teleportPos)
if this wont let you teleport, then first try like this:
doCreateTeleport(1387, { teleport.x, teleport.y, teleport.z }, teleportPos)
if this still wont work then make your table like this:
Code:
local newpos = {
["depot"] = {
    pos = {x=1029, y=996, z=7} },
["temple"] = {
    pos = {x=1000, y=1000, z=7} }, 
["house"] = {
    pos = {x=980, y=1117, z=7} }, 
["back"] = {
    pos = { x = getPlayerStorageValue(cid, storage), y = getPlayerStorageValue(cid, storage+1), z = getPlayerStorageValue(cid, storage+2)} }
}
and this line:
doCreateTeleport(1387, teleport, teleportPos)
change to:
doCreateTeleport(1387, teleport.pos, teleportPos)
 
Back
Top