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