Ir para conteúdo
  • Cadastre-se

(Resolvido)Reviver (2 Script)


Ir para solução Resolvido por Dwarfer,

Posts Recomendados

Funciona assim

Ao Usar com 15% de HP o player teleporta e naonde ele teleportou aparece um corpse
("Checa a vocaçao dele e manda um corpo") - "Aparece assim na tela dele" (Obs: ele só fica 3 segundos e volta Full Life)
"Coraçoes 5/6"
quando aparecer "Coraçoes 3/6" Fica Red a palavra

ele pode usar 6 vezes isso
Coldown de 5 Segundos/se ele usar as 6 Vezes no dia,ele tem um Coldown de 3 Horas para usar novamente.

2 Script

Spoiler

AO USAR X SUMMON ELE GANHA 15+ DE BUFF POR 7 SEGUNDOS

SE ELE RETIRAR OS SUMMONS O BUFF AINDA CONTINUA

 

 

O rei de seu proprio destino é aquele que luta pela gloria do amanhã!
Discord : ZoR#9373


 

Link para o post
Compartilhar em outros sites

1º - Em actions/scripts:

 

tpcoracao.lua

 

Spoiler

local t = {
hp_pc = 15, -- % de hp para usar
timetoback = {3, "sec"}, -- tempo para voltar
cooldown_used = {5, "sec"}, -- cooldown ao usar o item
cooldown_maxused = {3, "hour"}, -- quando usar max_coracoes vezes o cooldown aumenta para esse
timetocooldown_maxused = {1, "day"}, -- tempo que ficará o cooldown aumentado
max_coracoes = 6, 
new_pos = {x=1,y=1,z=1}, -- posição para onde será teleportado

corpses = {
[1] = 1111,  -- id do corpo
[2] = 2222,
[3] = 3333,
[4] = 4444}
}

-- só modifique se necessário
local stors = {hearts = 16772, cooldown = 16773, daily_cooldown = 16774} 

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local p, v = getPlayerPosition(cid), t.corpses[getPlayerVocation(cid)]
    local current_hp, max = getCreatureHealth(cid), getCreatureMaxHealth(cid)

    if not v then
        return true
    end

    if getPlayerStorageValue(cid, stors.cooldown) - os.time() > 0 then
        daily = getPlayerStorageValue(cid, stors.daily_cooldown) - os.time()
        rest_time = getPlayerStorageValue(cid, stors.cooldown) - os.time()
        cooldown = daily > 0 and math.ceil(rest_time/3600) .. " hours" or rest_time .. " seconds"
        doPlayerSendCancel(cid, "You must wait " .. cooldown .. " to use again.")
        doSendMagicEffect(p, CONST_ME_POFF)
        return true
    end

    if current_hp >= (t.hp_pc/100)*max then
        doPlayerSendCancel(cid, "Your health must be " .. t.hp_pc .. "% or less to use.")
        doSendMagicEffect(p, CONST_ME_POFF)
        return true
    end

    if  getPlayerStorageValue(cid, stors.hearts) == -1 then
        setPlayerStorageValue(cid, stors.hearts, 6)
    end

    local current_hearts = getPlayerStorageValue(cid, stors.hearts)
    setPlayerStorageValue(cid, stors.hearts, current_hearts - 1)
    current_hearts = getPlayerStorageValue(cid, stors.hearts)
    local type = (current_hearts > 0.5*(t.max_coracoes) and MESSAGE_INFO_DESCR or MESSAGE_STATUS_WARNING)
    doPlayerSendTextMessage(cid, type, "Corações: [" ..current_hearts .. "/" .. t.max_coracoes .. "]")   
    doTeleportThing(cid, t.new_pos)
    doSendMagicEffect(t.new_pos, CONST_ME_TELEPORT)
    if current_hearts == 0 then
        setPlayerStorageValue(cid, stors.daily_cooldown, mathtime(t.timetocooldown_maxused) + os.time())
        setPlayerStorageValue(cid, stors.cooldown, mathtime(t.cooldown_maxused) + os.time())
        setPlayerStorageValue(cid, stors.hearts, 6)
    else
        setPlayerStorageValue(cid, stors.cooldown, mathtime(t.cooldown_used) + os.time())
        if getPlayerStorageValue(cid, stors.daily_cooldown) ~= -1 then
            setPlayerStorageValue(cid, stors.daily_cooldown, -1) 
        end
    end
    doCreateItem(v, 1, t.new_pos)
    addEvent(function() 
    if isPlayer(cid) then
        doCleanTile(t.new_pos)
        doCreatureAddHealth(cid, max-current_hp)
        doTeleportThing(cid, p)
        doSendMagicEffect(p, CONST_ME_TELEPORT)
    end
    end, mathtime(t.timetoback)*1000)
    return true
end

function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1]*(60^(v == "day" and 2 or i-1))*(v == "day" and 24 or 1)
end
end
return "Error: Bad declaration in mathtime function."
end

 

 

 

Em actions.xml: <action itemid="ID_DO_ITEM" script="tpcoracao.lua" />

 

 

2º - É um BUFF para aumentar o que? Skill? ML? Edite para o que você quiser. Você poderia fazer algo assim.

 

Em talkactions/scripts:

 

Spoiler

local t = {
skills = {club = 25, sword = 25, axe = 25, distance = 25, shield = 25, ml = 50, duration = 7}} -- duration do BUFF em segundos

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, t.skills.duration*1000)
setConditionParam(condition, CONDITION_PARAM_SKILL_CLUB, t.skills.club)
setConditionParam(condition, CONDITION_PARAM_SKILL_SWORD, t.skills.sword)
setConditionParam(condition, CONDITION_PARAM_SKILL_AXE, t.skills.axe)
setConditionParam(condition, CONDITION_PARAM_SKILL_DISTANCE, t.skills.distance)
setConditionParam(condition, CONDITION_PARAM_SKILL_SHIELD, t.skills.shield)
setConditionParam(condition, CONDITION_PARAM_STAT_MAGICPOINTS, t.skills.ml)
setConditionParam(condition, CONDITION_PARAM_BUFF, true)

local name = "Rat"

function onSay(cid, words, param, channel)
local summons = getCreatureSummons(cid)
if #summons ~= 2 then
    if param:lower() == "\""..name:lower() then
        doAddCondition(cid, condition)
    end
    doSummonMonster(cid, name)
else
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
return true
end

 

 

Em talkactions.xml: <talkaction words="utevo res" filter="word-spaced" event="script" value="NOMEDOSEUARQUIVO.lua"/>

Contato:

 

Link para o post
Compartilhar em outros sites
1 hora atrás, Dwarfer disse:

1º - Em actions/scripts:

 

tpcoracao.lua

 

  Ocultar conteúdo


local t = {
hp_pc = 15, -- % de hp para usar
timetoback = {3, "sec"}, -- tempo para voltar
cooldown_used = {5, "sec"}, -- cooldown ao usar o item
cooldown_maxused = {3, "hour"}, -- quando usar max_coracoes vezes o cooldown aumenta para esse
timetocooldown_maxused = {1, "day"}, -- tempo que ficará o cooldown aumentado
max_coracoes = 6, 
new_pos = {x=1,y=1,z=1}, -- posição para onde será teleportado

corpses = {
[1] = 1111,  -- id do corpo
[2] = 2222,
[3] = 3333,
[4] = 4444}
}

-- só modifique se necessário
local stors = {hearts = 16772, cooldown = 16773, daily_cooldown = 16774} 

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local p, v = getPlayerPosition(cid), t.corpses[getPlayerVocation(cid)]
    local current_hp, max = getCreatureHealth(cid), getCreatureMaxHealth(cid)

    if not v then
        return true
    end

    if getPlayerStorageValue(cid, stors.cooldown) - os.time() > 0 then
        daily = getPlayerStorageValue(cid, stors.daily_cooldown) - os.time()
        rest_time = getPlayerStorageValue(cid, stors.cooldown) - os.time()
        cooldown = daily > 0 and math.ceil(rest_time/3600) .. " hours" or rest_time .. " seconds"
        doPlayerSendCancel(cid, "You must wait " .. cooldown .. " to use again.")
        doSendMagicEffect(p, CONST_ME_POFF)
        return true
    end

    if current_hp >= (t.hp_pc/100)*max then
        doPlayerSendCancel(cid, "Your health must be " .. t.hp_pc .. "% or less to use.")
        doSendMagicEffect(p, CONST_ME_POFF)
        return true
    end

    if  getPlayerStorageValue(cid, stors.hearts) == -1 then
        setPlayerStorageValue(cid, stors.hearts, 6)
    end

    local current_hearts = getPlayerStorageValue(cid, stors.hearts)
    setPlayerStorageValue(cid, stors.hearts, current_hearts - 1)
    current_hearts = getPlayerStorageValue(cid, stors.hearts)
    local type = (current_hearts > 0.5*(t.max_coracoes) and MESSAGE_INFO_DESCR or MESSAGE_STATUS_WARNING)
    doPlayerSendTextMessage(cid, type, "Corações: [" ..current_hearts .. "/" .. t.max_coracoes .. "]")   
    doTeleportThing(cid, t.new_pos)
    doSendMagicEffect(t.new_pos, CONST_ME_TELEPORT)
    if current_hearts == 0 then
        setPlayerStorageValue(cid, stors.daily_cooldown, mathtime(t.timetocooldown_maxused) + os.time())
        setPlayerStorageValue(cid, stors.cooldown, mathtime(t.cooldown_maxused) + os.time())
        setPlayerStorageValue(cid, stors.hearts, 6)
    else
        setPlayerStorageValue(cid, stors.cooldown, mathtime(t.cooldown_used) + os.time())
        if getPlayerStorageValue(cid, stors.daily_cooldown) ~= -1 then
            setPlayerStorageValue(cid, stors.daily_cooldown, -1) 
        end
    end
    doCreateItem(v, 1, t.new_pos)
    addEvent(function() 
    if isPlayer(cid) then
        doCleanTile(t.new_pos)
        doCreatureAddHealth(cid, max-current_hp)
        doTeleportThing(cid, p)
        doSendMagicEffect(p, CONST_ME_TELEPORT)
    end
    end, mathtime(t.timetoback)*1000)
    return true
end

function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1]*(60^(v == "day" and 2 or i-1))*(v == "day" and 24 or 1)
end
end
return "Error: Bad declaration in mathtime function."
end

 

 

 

Em actions.xml: <action itemid="ID_DO_ITEM" script="tpcoracao.lua" />

 

 

2º - É um BUFF para aumentar o que? Skill? ML? Edite para o que você quiser. Você poderia fazer algo assim.

 

Em talkactions/scripts:

 

  Ocultar conteúdo


local t = {
skills = {club = 25, sword = 25, axe = 25, distance = 25, shield = 25, ml = 50, duration = 7}} -- duration do BUFF em segundos

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, t.skills.duration*1000)
setConditionParam(condition, CONDITION_PARAM_SKILL_CLUB, t.skills.club)
setConditionParam(condition, CONDITION_PARAM_SKILL_SWORD, t.skills.sword)
setConditionParam(condition, CONDITION_PARAM_SKILL_AXE, t.skills.axe)
setConditionParam(condition, CONDITION_PARAM_SKILL_DISTANCE, t.skills.distance)
setConditionParam(condition, CONDITION_PARAM_SKILL_SHIELD, t.skills.shield)
setConditionParam(condition, CONDITION_PARAM_STAT_MAGICPOINTS, t.skills.ml)
setConditionParam(condition, CONDITION_PARAM_BUFF, true)

local name = "Rat"

function onSay(cid, words, param, channel)
local summons = getCreatureSummons(cid)
if #summons ~= 2 then
    if param:lower() == "\""..name:lower() then
        doAddCondition(cid, condition)
    end
    doSummonMonster(cid, name)
else
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
return true
end

 

 

Em talkactions.xml: <talkaction words="utevo res" filter="word-spaced" event="script" value="NOMEDOSEUARQUIVO.lua"/>

o primeiro é uma Spell nao uma Action Id ou seja o Player vai falar exemplo "Bilada" e sim acontece as coisas

O rei de seu proprio destino é aquele que luta pela gloria do amanhã!
Discord : ZoR#9373


 

Link para o post
Compartilhar em outros sites
4 horas atrás, ZikaLord disse:

Funciona assim

Ao Usar com 15% de HP o player teleporta e naonde ele teleportou aparece um corpse

 

 

"AO USAR" deixa subtendido action.

 

Spoiler

local t = {
hp_pc = 15, -- % de hp para usar
timetoback = {3, "sec"}, -- tempo para voltar
cooldown_used = {5, "sec"}, -- cooldown ao usar o item
cooldown_maxused = {3, "hour"}, -- quando usar max_coracoes vezes o cooldown aumenta para esse
timetocooldown_maxused = {1, "day"}, -- tempo que ficará o cooldown aumentado
max_coracoes = 6, 
new_pos = {x=1,y=1,z=1}, -- posição para onde será teleportado

corpses = {
[1] = 1111,  -- id do corpo
[2] = 2222,
[3] = 3333,
[4] = 4444}
}


-- só modifique se necessário
local stors = {hearts = 16772, cooldown = 16773, daily_cooldown = 16774} 

function onCastSpell(cid, var)
	local p, v = getPlayerPosition(cid), t.corpses[getPlayerVocation(cid)]
local current_hp, max = getCreatureHealth(cid), getCreatureMaxHealth(cid)

if not v then
return true
end

if getPlayerStorageValue(cid, stors.cooldown) - os.time() > 0 then
daily = getPlayerStorageValue(cid, stors.daily_cooldown) - os.time()
rest_time = getPlayerStorageValue(cid, stors.cooldown) - os.time()
cooldown = daily > 0 and math.ceil(rest_time/3600) .. " hours" or rest_time .. " seconds"
doPlayerSendCancel(cid, "You must wait " .. cooldown .. " to use again.")
doSendMagicEffect(p, CONST_ME_POFF)
return true
end

if current_hp >= (t.hp_pc/100)*max then
doPlayerSendCancel(cid, "Your health must be " .. t.hp_pc .. "% or less to use.")
doSendMagicEffect(p, CONST_ME_POFF)
return true
end

if  getPlayerStorageValue(cid, stors.hearts) == -1 then
setPlayerStorageValue(cid, stors.hearts, 6)
end

local current_hearts = getPlayerStorageValue(cid, stors.hearts)
setPlayerStorageValue(cid, stors.hearts, current_hearts - 1)
current_hearts = getPlayerStorageValue(cid, stors.hearts)
local type = (current_hearts > 0.5*(t.max_coracoes) and MESSAGE_INFO_DESCR or MESSAGE_STATUS_WARNING)
doPlayerSendTextMessage(cid, type, "Corações: [" ..current_hearts .. "/" .. t.max_coracoes .. "]")   
doTeleportThing(cid, t.new_pos)
doSendMagicEffect(t.new_pos, CONST_ME_TELEPORT)
if current_hearts == 0 then
    setPlayerStorageValue(cid, stors.daily_cooldown, mathtime(t.timetocooldown_maxused) + os.time())
    setPlayerStorageValue(cid, stors.cooldown, mathtime(t.cooldown_maxused) + os.time())
    setPlayerStorageValue(cid, stors.hearts, 6)
else
    setPlayerStorageValue(cid, stors.cooldown, mathtime(t.cooldown_used) + os.time())
    if getPlayerStorageValue(cid, stors.daily_cooldown) ~= -1 then
        setPlayerStorageValue(cid, stors.daily_cooldown, -1) 
    end
end
doCreateItem(v, 1, t.new_pos)
addEvent(function() 
if isPlayer(cid) then
doCleanTile(t.new_pos)
doCreatureAddHealth(cid, max-current_hp)
doTeleportThing(cid, p)
doSendMagicEffect(p, CONST_ME_TELEPORT)
end
end, mathtime(t.timetoback)*1000)
return true
end

function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1]*(60^(v == "day" and 2 or i-1))*(v == "day" and 24 or 1)
end
end
return "Error: Bad declaration in mathtime function."
end

 

 

Contato:

 

Link para o post
Compartilhar em outros sites
38 minutos atrás, Dwarfer disse:

 

"AO USAR" deixa subtendido action.

 

  Mostrar conteúdo oculto


local t = {
hp_pc = 15, -- % de hp para usar
timetoback = {3, "sec"}, -- tempo para voltar
cooldown_used = {5, "sec"}, -- cooldown ao usar o item
cooldown_maxused = {3, "hour"}, -- quando usar max_coracoes vezes o cooldown aumenta para esse
timetocooldown_maxused = {1, "day"}, -- tempo que ficará o cooldown aumentado
max_coracoes = 6, 
new_pos = {x=1,y=1,z=1}, -- posição para onde será teleportado

corpses = {
[1] = 1111,  -- id do corpo
[2] = 2222,
[3] = 3333,
[4] = 4444}
}


-- só modifique se necessário
local stors = {hearts = 16772, cooldown = 16773, daily_cooldown = 16774} 

function onCastSpell(cid, var)
	local p, v = getPlayerPosition(cid), t.corpses[getPlayerVocation(cid)]
local current_hp, max = getCreatureHealth(cid), getCreatureMaxHealth(cid)

if not v then
return true
end

if getPlayerStorageValue(cid, stors.cooldown) - os.time() > 0 then
daily = getPlayerStorageValue(cid, stors.daily_cooldown) - os.time()
rest_time = getPlayerStorageValue(cid, stors.cooldown) - os.time()
cooldown = daily > 0 and math.ceil(rest_time/3600) .. " hours" or rest_time .. " seconds"
doPlayerSendCancel(cid, "You must wait " .. cooldown .. " to use again.")
doSendMagicEffect(p, CONST_ME_POFF)
return true
end

if current_hp >= (t.hp_pc/100)*max then
doPlayerSendCancel(cid, "Your health must be " .. t.hp_pc .. "% or less to use.")
doSendMagicEffect(p, CONST_ME_POFF)
return true
end

if  getPlayerStorageValue(cid, stors.hearts) == -1 then
setPlayerStorageValue(cid, stors.hearts, 6)
end

local current_hearts = getPlayerStorageValue(cid, stors.hearts)
setPlayerStorageValue(cid, stors.hearts, current_hearts - 1)
current_hearts = getPlayerStorageValue(cid, stors.hearts)
local type = (current_hearts > 0.5*(t.max_coracoes) and MESSAGE_INFO_DESCR or MESSAGE_STATUS_WARNING)
doPlayerSendTextMessage(cid, type, "Corações: [" ..current_hearts .. "/" .. t.max_coracoes .. "]")   
doTeleportThing(cid, t.new_pos)
doSendMagicEffect(t.new_pos, CONST_ME_TELEPORT)
if current_hearts == 0 then
    setPlayerStorageValue(cid, stors.daily_cooldown, mathtime(t.timetocooldown_maxused) + os.time())
    setPlayerStorageValue(cid, stors.cooldown, mathtime(t.cooldown_maxused) + os.time())
    setPlayerStorageValue(cid, stors.hearts, 6)
else
    setPlayerStorageValue(cid, stors.cooldown, mathtime(t.cooldown_used) + os.time())
    if getPlayerStorageValue(cid, stors.daily_cooldown) ~= -1 then
        setPlayerStorageValue(cid, stors.daily_cooldown, -1) 
    end
end
doCreateItem(v, 1, t.new_pos)
addEvent(function() 
if isPlayer(cid) then
doCleanTile(t.new_pos)
doCreatureAddHealth(cid, max-current_hp)
doTeleportThing(cid, p)
doSendMagicEffect(p, CONST_ME_TELEPORT)
end
end, mathtime(t.timetoback)*1000)
return true
end

function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1]*(60^(v == "day" and 2 or i-1))*(v == "day" and 24 or 1)
end
end
return "Error: Bad declaration in mathtime function."
end

 

 

eu ultilizei mas nao funciona,nao aparece nem erro no console

O rei de seu proprio destino é aquele que luta pela gloria do amanhã!
Discord : ZoR#9373


 

Link para o post
Compartilhar em outros sites

Editou as posições, os corpos? Colocou corretamente no spells.xml? Testei aqui agora e tá correto. 

Editado por Dwarfer (veja o histórico de edições)

Contato:

 

Link para o post
Compartilhar em outros sites
Spoiler

local t = {
hp_pc = 15, -- % de hp para usar
timetoback = {3, "sec"}, -- tempo para voltar
cooldown_used = {5, "sec"}, -- cooldown ao usar o item
cooldown_maxused = {3, "hour"}, -- quando usar max_coracoes vezes o cooldown aumenta para esse
timetocooldown_maxused = {1, "day"}, -- tempo que ficará o cooldown aumentado
max_coracoes = 6, 
new_pos = {x=1008,y=910,z=6}, -- posição para onde será teleportado

corpses = {
[1] = 1111,  -- id do corpo
[2] = 2222,
[3] = 3333,
[4] = 4444}
}

-- só modifique se necessário
local stors = {hearts = 16772, cooldown = 16773, daily_cooldown = 16774} 

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local p, v = getPlayerPosition(cid), t.corpses[getPlayerVocation(cid)]
    local current_hp, max = getCreatureHealth(cid), getCreatureMaxHealth(cid)

    if not v then
        return true
    end

    if getPlayerStorageValue(cid, stors.cooldown) - os.time() > 0 then
        daily = getPlayerStorageValue(cid, stors.daily_cooldown) - os.time()
        rest_time = getPlayerStorageValue(cid, stors.cooldown) - os.time()
        cooldown = daily > 0 and math.ceil(rest_time/3600) .. " hours" or rest_time .. " seconds"
        doPlayerSendCancel(cid, "You must wait " .. cooldown .. " to use again.")
        doSendMagicEffect(p, CONST_ME_POFF)
        return true
    end

    if current_hp >= (t.hp_pc/100)*max then
        doPlayerSendCancel(cid, "Your health must be " .. t.hp_pc .. "% or less to use.")
        doSendMagicEffect(p, CONST_ME_POFF)
        return true
    end

    if  getPlayerStorageValue(cid, stors.hearts) == -1 then
        setPlayerStorageValue(cid, stors.hearts, 6)
    end

    local current_hearts = getPlayerStorageValue(cid, stors.hearts)
    setPlayerStorageValue(cid, stors.hearts, current_hearts - 1)
    current_hearts = getPlayerStorageValue(cid, stors.hearts)
    local type = (current_hearts > 0.5*(t.max_coracoes) and MESSAGE_INFO_DESCR or MESSAGE_STATUS_WARNING)
    doPlayerSendTextMessage(cid, type, "Corações: [" ..current_hearts .. "/" .. t.max_coracoes .. "]")   
    doTeleportThing(cid, t.new_pos)
    doSendMagicEffect(t.new_pos, CONST_ME_TELEPORT)
    if current_hearts == 0 then
        setPlayerStorageValue(cid, stors.daily_cooldown, mathtime(t.timetocooldown_maxused) + os.time())
        setPlayerStorageValue(cid, stors.cooldown, mathtime(t.cooldown_maxused) + os.time())
        setPlayerStorageValue(cid, stors.hearts, 6)
    else
        setPlayerStorageValue(cid, stors.cooldown, mathtime(t.cooldown_used) + os.time())
        if getPlayerStorageValue(cid, stors.daily_cooldown) ~= -1 then
            setPlayerStorageValue(cid, stors.daily_cooldown, -1) 
        end
    end
    doCreateItem(v, 1, t.new_pos)
    addEvent(function() 
    if isPlayer(cid) then
        doCleanTile(t.new_pos)
        doCreatureAddHealth(cid, max-current_hp)
        doTeleportThing(cid, p)
        doSendMagicEffect(p, CONST_ME_TELEPORT)
    end
    end, mathtime(t.timetoback)*1000)
    return true
end

function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1]*(60^(v == "day" and 2 or i-1))*(v == "day" and 24 or 1)
end
end
return "Error: Bad declaration in mathtime function."
end

 

Spoiler

local t = {
hp_pc = 15, -- % de hp para usar
timetoback = {3, "sec"}, -- tempo para voltar
cooldown_used = {5, "sec"}, -- cooldown ao usar o item
cooldown_maxused = {3, "hour"}, -- quando usar max_coracoes vezes o cooldown aumenta para esse
timetocooldown_maxused = {1, "day"}, -- tempo que ficará o cooldown aumentado
max_coracoes = 6, 
new_pos = {x=1008,y=910,z=6}, -- posição para onde será teleportado

corpses = {
[1] = 1111,  -- id do corpo
[2] = 2222,
[3] = 3333,
[4] = 4444}
}


-- só modifique se necessário
local stors = {hearts = 16772, cooldown = 16773, daily_cooldown = 16774} 

function onCastSpell(cid, var)
	local p, v = getPlayerPosition(cid), t.corpses[getPlayerVocation(cid)]
local current_hp, max = getCreatureHealth(cid), getCreatureMaxHealth(cid)

if not v then
return true
end

if getPlayerStorageValue(cid, stors.cooldown) - os.time() > 0 then
daily = getPlayerStorageValue(cid, stors.daily_cooldown) - os.time()
rest_time = getPlayerStorageValue(cid, stors.cooldown) - os.time()
cooldown = daily > 0 and math.ceil(rest_time/3600) .. " hours" or rest_time .. " seconds"
doPlayerSendCancel(cid, "You must wait " .. cooldown .. " to use again.")
doSendMagicEffect(p, CONST_ME_POFF)
return true
end

if current_hp >= (t.hp_pc/100)*max then
doPlayerSendCancel(cid, "Your health must be " .. t.hp_pc .. "% or less to use.")
doSendMagicEffect(p, CONST_ME_POFF)
return true
end

if  getPlayerStorageValue(cid, stors.hearts) == -1 then
setPlayerStorageValue(cid, stors.hearts, 6)
end

local current_hearts = getPlayerStorageValue(cid, stors.hearts)
setPlayerStorageValue(cid, stors.hearts, current_hearts - 1)
current_hearts = getPlayerStorageValue(cid, stors.hearts)
local type = (current_hearts > 0.5*(t.max_coracoes) and MESSAGE_INFO_DESCR or MESSAGE_STATUS_WARNING)
doPlayerSendTextMessage(cid, type, "Corações: [" ..current_hearts .. "/" .. t.max_coracoes .. "]")   
doTeleportThing(cid, t.new_pos)
doSendMagicEffect(t.new_pos, CONST_ME_TELEPORT)
if current_hearts == 0 then
    setPlayerStorageValue(cid, stors.daily_cooldown, mathtime(t.timetocooldown_maxused) + os.time())
    setPlayerStorageValue(cid, stors.cooldown, mathtime(t.cooldown_maxused) + os.time())
    setPlayerStorageValue(cid, stors.hearts, 6)
else
    setPlayerStorageValue(cid, stors.cooldown, mathtime(t.cooldown_used) + os.time())
    if getPlayerStorageValue(cid, stors.daily_cooldown) ~= -1 then
        setPlayerStorageValue(cid, stors.daily_cooldown, -1) 
    end
end
doCreateItem(v, 1, t.new_pos)
addEvent(function() 
if isPlayer(cid) then
doCleanTile(t.new_pos)
doCreatureAddHealth(cid, max-current_hp)
doTeleportThing(cid, p)
doSendMagicEffect(p, CONST_ME_TELEPORT)
end
end, mathtime(t.timetoback)*1000)
return true
end

function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1]*(60^(v == "day" and 2 or i-1))*(v == "day" and 24 or 1)
end
end
return "Error: Bad declaration in mathtime function."
end

 

 

1 ta no action

 

2 no spells

 

Tag

<instant name="bacu dois" words="bacu dois" lvl="75" mana="3900" aggressive="1" range="5" blockwalls="1" selftarget="1" exhaustion="800" needlearn="0" event="script" value="coraco.lua">
<vocation id="1-15"/>
</instant>

 

Tag

<action itemid="5943" script="coracotp.lua" />

O rei de seu proprio destino é aquele que luta pela gloria do amanhã!
Discord : ZoR#9373


 

Link para o post
Compartilhar em outros sites
  • Solução

Se configurou os nomes dos arquivos corretamente, vai funcionar. Edite os corpses também, ali eu escrevi qualquer coisa. 

Contato:

 

Link para o post
Compartilhar em outros sites
47 minutos atrás, Dwarfer disse:

Editou as posições, os corpos? Colocou corretamente no spells.xml? Testei aqui agora e tá correto. 

 

o corpse esta aparecendo em outro lugar

O rei de seu proprio destino é aquele que luta pela gloria do amanhã!
Discord : ZoR#9373


 

Link para o post
Compartilhar em outros sites

100% Funcional

O rei de seu proprio destino é aquele que luta pela gloria do amanhã!
Discord : ZoR#9373


 

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo