Eu acho que tem algum tópico explicando isso, mas o princípio é simples:
Existe uma função que retorna os segundos contados desde 1º de janeiro de 1970, a os.time(). Com isso, você consegue ter o tempo em segundos. Daí você coloca esse valor + o tempo de exhaust que você quer em algum storage do jogador e adiciona uma checagem: se o os.time() for maior ou igual ao storage, já deu o tempo, se não, ele ainda tem que esperar. Mas esperar quanto? O valor do storage - o os.time(), vai retornar os segundos que faltam pra poder usar.
Então, fica assim, a menos que eu tenha errado algo por falta de atenção:
local DESTINO = {x = 1109, y = 581, z = 7}
local TEMPO_PARA_VOLTAR = 20 * 1000 -- em ms
local events = {}
local exhaust = 200 -- EM SEGUNDOS
local dbfunc = db and type(db.executeQuery) == "function" and db.executeQuery or
db and type(db.query) == "function" and db.query or error
local function teleport_back(guid, position)
local cid = getPlayerByGUID(guid)
if isCreature(cid) then
doTeleportThing(cid, position)
doSendMagicEffect(position, CONST_ME_TELEPORT)
else
dbfunc("UPDATE players SET posx = "..position.x..", posy = "..position.y..", posz = "..position.z.." WHERE id = "..guid)
end
events[guid] = nil
end
function onCastSpell(cid)
local pos, guid = getThingPos(cid), getPlayerGUID(cid)
if events[guid] then
return not doPlayerSendCancel(cid, "You can't cast this spell now!")
end
if os.time() >= getPlayerStorageValue(cid, 157126) then
doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
doCreatureAddMana(cid, getCreatureMaxMana(cid))
doTeleportThing(cid, DESTINO)
doSendMagicEffect(DESTINO, CONST_ME_TELEPORT)
events[guid] = addEvent(teleport_back, TEMPO_PARA_VOLTAR, guid, pos)
setPlayerStorageValue(cid, 157126 + exhaust)
else
doPlayerSendCancel(cid, "Voce deve esperar "..getPlayerStorageValue(cid, 157126) - os.time().." segundos.")
end
return true
end
OBS.: acho que a maioria dos servidores já vem com a função exhaust.set e exhaust.check. Procura na sua lib por exhaustion.lua.






info
Grupo: Infante
Registrado: 27/01/13
Posts: 1.7k
Reputação: +104
Gênero: Masculino
Teria como colocar um Exasted igual desse SCRIPT:
local newPos1 = {x = 0, y = 0, z = 0} --pos pra onde sera levado o caster da spell local newPos2 = {x = 242, y = 1056, z = 4} --pos pra onde sera levado o target local time = 20 --tempo pra teleporta devolta, em segs local function teleport(cid, pid, pos, pos2) if isCreature(pid) then doTeleportThing(pid, getClosestFreeTile(pid, pos2 or pos)) doSendMagicEffect(getPlayerPosition(pid), 75) end end function onCastSpell(cid, var) local target = getCreatureTarget(cid) if not isCreature(target) or not isPlayer(target) then return doPlayerSendTextMessage(cid, 27, "Voce So Pode Usar Essa Spell Em Players e Fora de Exames,Arenas,Quests") end if getPlayerStorageValue(cid, 33333) < os.time () then local target = getCreatureTarget(cid) local posCid = getPlayerPosition(cid) local posTarget = getPlayerPosition(target) setPlayerStorageValue(cid, 33333, os.time () + 200) doSendMagicEffect(posCid, 30) doSendMagicEffect(posTarget, 196) teleport(cid, target, newPos1, newPos2) addEvent(teleport, time*1000, cid, target, posCid, posTarget) else doPlayerSendCancel(cid, " VOCE SÓ PODE USAR DAKI A "..getPlayerStorageValue(cid, 33333) - os.time ().." SEGUNDOS ") end return true endNesse
local DESTINO = {x = 1109, y = 581, z = 7} local TEMPO_PARA_VOLTAR = 20 * 1000 -- em ms local events = {} local dbfunc = db and type(db.executeQuery) == "function" and db.executeQuery or db and type(db.query) == "function" and db.query or error local function teleport_back(guid, position) local cid = getPlayerByGUID(guid) if isCreature(cid) then doTeleportThing(cid, position) doSendMagicEffect(position, CONST_ME_TELEPORT) else dbfunc("UPDATE players SET posx = "..position.x..", posy = "..position.y..", posz = "..position.z.." WHERE id = "..guid) end events[guid] = nil end function onCastSpell(cid) local pos, guid = getThingPos(cid), getPlayerGUID(cid) if events[guid] then return not doPlayerSendCancel(cid, "You can't cast this spell now!") end doCreatureAddHealth(cid, getCreatureMaxHealth(cid)) doCreatureAddMana(cid, getCreatureMaxMana(cid)) doTeleportThing(cid, DESTINO) doSendMagicEffect(DESTINO, CONST_ME_TELEPORT) events[guid] = addEvent(teleport_back, TEMPO_PARA_VOLTAR, guid, pos) return true endEditado Setembro 14 por SkyDarkyes