samuel157
/root
- Joined
- Mar 19, 2010
- Messages
- 518
- Solutions
- 3
- Reaction score
- 71
- Location
- São Paulo, Brazil
- GitHub
- Samuel10M
Can you tell me a magic on area that kills a player with reflex and immortality? I've tried everything in chatgpt and I couldn't solve it.
LUA:
local msg = "Voce Esta Imortal Por 24 Horas."
local STORAGE = 91811
local imortal_time = 86400 -- Segundos.
function onCastSpell(cid, var)
if getPlayerStorageValue(cid, 13546) < 1 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você precisa ser DONATE para usar esta Magia.")
doSendMagicEffect(getThingPos(cid), 2)
return true
end
if getPlayerStorageValue(cid, STORAGE) > os.time() then
return doPlayerSendCancel(cid, "Você já está imortal.")
else
setPlayerStorageValue(cid, STORAGE, os.time() + imortal_time)
doPlayerSendTextMessage(cid, 27, msg:format(imortal_time))
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_EXPLOSIONHIT) -- ADICIONADO EFFECT 5
end
return true
end
LUA:
function onCastSpell(cid, var)
-- Check if the player has the required storage for the spell
if getPlayerStorageValue(cid, 12789) < 1 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You need storage spell donate.")
doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
return false
end
-- Register the statschange event
registerCreatureEvent(cid, "Reflection/statschange") -- Registers the statschange event
-- Set the duration for the Reflection effect (24 hours)
setPlayerStorageValue(cid, 12789, os.time() + 86400) -- Sets the duration (24 hours)
-- Apply the visual effect
doSendMagicEffect(getThingPosition(cid), CONST_ME_HOLYDAMAGE)
-- Inform the player that they have gained the Reflection effect
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You have 24 hours of Reflection.")
return true
end
LUA:
function onLogin(cid)
-- Verificar se o Reflection ainda está ativo
if getPlayerStorageValue(cid, 12789) > os.time() then
-- Registrar o evento statschange novamente
registerCreatureEvent(cid, "Reflection/statschange")
else
-- Remover o armazenamento caso o efeito tenha expirado
setPlayerStorageValue(cid, 12789, -1)
end
return true
end
Code:
function onStatsChange(cid, attacker, type, combat, value)
-- Verificar se o Reflection está ativo
if getPlayerStorageValue(cid, 12789) > os.time() then
-- Garantir que o atacante é válido e está vivo
if isCreature(attacker) and getCreatureHealth(attacker) > 0 then
doCreatureAddHealth(attacker, -getCreatureHealth(attacker)) -- Matar atacante
doSendMagicEffect(getThingPosition(attacker), CONST_ME_HOLYDAMAGE)
doSendAnimatedText(getThingPosition(attacker), "[OWNED!]", 35)
end
return false -- Impede que o jogador perca vida
else
-- Desativar evento quando o Reflection expira
unregisterCreatureEvent(cid, "Reflection/statschange")
setPlayerStorageValue(cid, 12789, -1)
end
return true
end