• 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. ^_^
 
Cant make to work the removing teleport part, else works just fine.
You should contact Slawkens, Ive gave it few shots, but none worked, always printed Slaws Debug message.

Code:
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

--Author: Slawkens
--CONFIG
local MANA_NEEDED = 0 --0 to disable
local SOUL_NEEDED = 0 --0 to disable
local TIME_TO_REMOVE = 3 -- in seconds  (After this time teleport will be removed)
local storage = 666

function onSay(cid, words, param)
	local newpos = {
		["depot"] = {x=241, y=565, 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)}
	}
	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 = getCreaturePosition(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 * 1000, teleportPos)
					else
						doPlayerSendCancel(cid, "There is already a teleport here, please wait.")
					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


function getNextPosFromDir(fromPos, dir, size)
    local newPos =
    {
        [0]={ x=fromPos.x, y = fromPos.y-size, z = fromPos.z }, 
        [1]={ x=fromPos.x+size, y = fromPos.y, z = fromPos.z }, 
        [2]={ x=fromPos.x, y = fromPos.y+size, z = fromPos.z }, 
        [3]={ x=fromPos.x-size, y = fromPos.y, z = fromPos.z }
    }
    return newPos[dir]
end
 
B.U.M.P.

Anyone know how to make this dam thing work...?
I spent like 2 hours scripting lua functions...never got it to work.
 
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)

Nothing wrong with "teleport", it is a position. What you said was wrong you forgot x=, y=, z= and teleport.pos is not necessary.
 
All issues fixed:
Code:
--Author: Slawkens
--CONFIG
local MANA_NEEDED = 500 --0 to disable
local SOUL_NEEDED = 10 --0 to disable
local TIME_TO_REMOVE = 1 -- 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},
	["test"] = {x=95, y=123, z=7},
}

function onSay(cid, words, param)
	local teleport = newPos[param]
	if teleport then
		if isPremium(cid) == TRUE then
			if getCreatureMana(cid) >= MANA_NEEDED then
				if getPlayerSoul(cid) >= SOUL_NEEDED then
					local playerPos = getCreaturePos(cid)
					local teleportPos = getNextPosFromDir(playerPos, getPlayerLookDir(cid), 1)
					teleportPos.stackpos = STACKPOS_GROUND
					if(hasProperty(getThingFromPos(teleportPos).uid, CONST_PROP_BLOCKINGANDNOTMOVEABLE) ~= 

TRUE) then
						if(SOUL_NEEDED ~= 0) then doPlayerAddSoul(cid, -SOUL_NEEDED) end
						if(MANA_NEEDED ~= 0) then doCreatureAddMana(cid, -MANA_NEEDED) end
						doSendMagicEffect(teleportPos, CONST_ME_TELEPORT)
						doCreateTeleport(1387, teleport, teleportPos)
						addEvent(doRemoveItemFromPos, TIME_TO_REMOVE * 1000, 1387, teleportPos)
					else
						doPlayerSendCancel(cid, "You cannot place this teleport here.")
						doSendMagicEffect(getCreaturePos(cid), CONST_ME_POFF)
					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

You need also this function, (add to functions.lua or global.lua)
Code:
function doRemoveItemFromPos(itemid, position, limit)
	local item = getTileItemById(position, itemid)
	if(not item) then
		return FALSE
	end

	doRemoveItem(item.uid)
end
 
Back
Top