Primeira coisa que você pediu:
Talkactions.xml:
<talkaction words="/tp" event="script" value="tp.lua"/>
Tp.lua:
-- Script by Luck Oake
function onSay(cid, words, param)
local waittime = 10 -- Tempo de exhaustion
local storage = 5560
local tpId = 1387 -- ID do seu Teleport
local p = getCreaturePosition(cid)
local x = {
[0] = {x=p.x, y=p.y-1, z=p.z},
[1] = {x=p.x+1, y=p.y, z=p.z},
[2] = {x=p.x, y=p.y+1, z=p.z},
[3] = {x=p.x-1, y=p.y, z=p.z}
}
pos = x[getCreatureLookDirection(cid)]
from = {x=pos.x, y=pos.y, z=7}
to = {x = 1000, y = 1000, z = 7} -- Para onde o teleport levará
area1 = {x = 998, y = 998, z = 7} -- Ponta de cima na esquerda na area que o tp leva
area2 = {x = 1002, y = 1002, z = 7} -- Ponta de baixo na direita na area que o tp leva
function back(cid)
if isInArea(getCreaturePosition(cid), area1, area2) then
doTeleportThing(cid, from)
end
end
function removeTp(tp)
local tp = getTileItemById(from, tpId)
if tp then
doRemoveItem(tp.uid, 1)
doSendMagicEffect(from, CONST_ME_POFF)
end
end
if exhaustion.get(cid, storage) == FALSE then
for _, pid in ipairs(getPlayersOnline()) do
addEvent(back, 20000, pid)
end
doCreateTeleport(tpId, to, from)
addEvent(removeTp, 5000, tp)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Aguarde " .. exhaustion.get(cid, storage) .. " segundos para usar a spell novamente.")
end
return true
end