Era muito mais fácil fazer como talkaction, mas já que pediu spell, fiz spell mesmo:
crie 1 arquivo na pasta spells com o nome saveposition.lua e coloque isso dentro:
local config = {
POSITION_STORAGE = 17840,
INTERVAL_STORAGE = 17841,
INTERVAL_TIME = 5 * 60, -- tempo para usar novamente (5 * 60 = 5 minutos)
}
function onCastSpell(cid, var)
local time = getPlayerStorageValue(cid, config.INTERVAL_STORAGE)
if time - os.time() > 0 then
doPlayerSendCancel(cid, "You have to wait "..(time - os.time()).." seconds to use this spell again.")
return false
end
setPlayerStorageValue(cid, config.POSITION_STORAGE, "")
local m = getThingPos(cid)
setPlayerStorageValue(cid, config.POSITION_STORAGE, "x:"..m.x..";y:"..m.y..";z:"..m.z..";")
doSendMagicEffect(m, CONST_ME_TUTORIALSQUARE, cid)
doSendMagicEffect(m, CONST_ME_TUTORIALARROW, cid)
doPlayerSendCancel(cid, "You saved your checkpoint on that position.")
return true
end
e agora crie outro arquivo na mesma pasta com o nome returnposition.lua e coloque isso dentro:
local config = {
POSITION_STORAGE = 17840,
INTERVAL_STORAGE = 17841,
INTERVAL_TIME = 5 * 60, -- tempo para usar novamente (5 * 60 = 5 minutos)
}
function onCastSpell(cid, var)
local time = getPlayerStorageValue(cid, config.INTERVAL_STORAGE)
if time - os.time() > 0 then
doPlayerSendCancel(cid, "You have to wait "..(time - os.time()).." seconds to use this spell again.")
return false
end
local m = getPlayerStorageValue(cid, config.POSITION_STORAGE)
if type(m) ~= "string" then
doPlayerSendCancel(cid, "You have to mark a checkpoint first.")
return false
end
local x1, x2 = m:find("x:(.-);")
local y1, y2 = m:find("y:(.-);")
local z1, z2 = m:find("z:(.-);")
local x, y, z = m:sub(x1 + 2, x2 - 1), m:sub(y1 + 2, y2 - 1), m:sub(z1 + 2, z2 - 1)
m = {x = tonumber(x), y = tonumber(y), z = tonumber(z)}
setPlayerStorageValue(cid, config.POSITION_STORAGE, -1)
setPlayerStorageValue(cid, config.INTERVAL_STORAGE, os.time() + config.INTERVAL_TIME)
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doTeleportThing(cid, m, false)
doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
return true
end
e agora adicione essas 2 tags em spells.xml:
<instant name="Store Position" words="checkpoint save" lvl="20" mana="120" prem="1" aggressive="0" exhaustion="1000" needlearn="0" event="script" value="saveposition.lua"> </instant> <instant name="Return Position" words="checkpoint return" lvl="20" mana="50" prem="1" aggressive="0" exhaustion="1000" needlearn="0" event="script" value="returnposition.lua"> </instant>






info
Grupo: Cavaleiro
Registrado: 04/09/12
Posts: 185
Reputação: +2
Olá, gostaria de pedir uma spell que marca-se a posição do jogador.
Exemplo: Eu uso a spell, aí eu marquei a posição, certo? Aí eu ando pra mto longe, quando eu usar uma outra spell (ou a mesma spell)eu volto para a posição que eu tinha marcado. Queria que tivesse um cooldown de 5 minutos para usar ela denovo.
Quem puder me ajudar dou REP+.
OBS: Meu server é o forgotten server (8.54)
Obrigado.