• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved [TFS 1.2] - Spell does not show amount healed

_M4G0_

Well-Known Member
Joined
Feb 6, 2016
Messages
504
Solutions
16
Reaction score
98
i have created this spell but the spell dont show how much player heal
tfs 1.2
Lua:
local combat = createCombatObject()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, false)
function onCastSpell(cid, var)
    local min = getCreatureMaxHealth(cid) * 5/250
    local max = getCreatureMaxHealth(cid) * 5/250
    local condition = createConditionObject(CONDITION_REGENERATION)
    condition:setParameter(CONDITION_PARAM_SUBID, 1)
    condition:setParameter(CONDITION_PARAM_BUFF, true)
    condition:setParameter(CONDITION_PARAM_TICKS, 1 * 20 * 1000)
    condition:setParameter(CONDITION_PARAM_HEALTHGAIN, math.max(math.random(min, max)))
    condition:setParameter(CONDITION_PARAM_HEALTHTICKS, 500)
    doAddCondition(cid, condition)
    return doCombat(cid, combat, var)
end
 
Last edited:
EDIT:
I see you have this
Lua:
    if not player then
        return
    end
nevermind, my bad
 
Last edited:
Lua:
local config = {
cooldown = 15,
tempo = 12,
percent = 5,
storage = 45382,
effect = 14
}
function onCastSpell(cid, var)
local player = Player(cid)
if player:getStorageValue(config.storage) < os.time() then
for i = 1, config.tempo do
addEvent(function(cid)
    local player = Player(cid)
    if not player then
        return
    end
local lifedraw = (player:getMaxHealth(player) * (config.percent)/100)
    player:getPosition():sendMagicEffect(config.effect)
    player:addHealth(lifedraw, 1)
end, i * 1000, player)
end
player:setStorageValue(config.storage, os.time() + config.cooldown)
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "Your Mass Healing is at cooldown, you must wait "..(player:getStorageValue(config.storage) - os.time()).." seconds.")
end

return true
end
 
Last edited:
server down :(
Lua:
local config = {
cooldown = 15,
tempo = 12,
percent = 5,
storage = 45382,
effect = 14
}
function onCastSpell(cid, var)
local player = Player(cid)
if player:getStorageValue(config.storage) < os.time() then
for i = 1, config.tempo do
addEvent(function(cid)
    local player = Player(cid)
    if not player then
        return
    end
local lifedraw = (player:getMaxHealth(player) * (config.percent)/100)
    player:getPosition():sendMagicEffect(config.effect)
    player:addHealth(lifedraw, 1)
end, i * 1000, player)
end
player:setStorageValue(config.storage, os.time() + config.cooldown)
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "Your Mass Healing is at cooldown, you must wait "..(player:getStorageValue(config.storage) - os.time()).." seconds.")
end

return true
end
 
Last edited:
Lua:
local config = {
    cooldown = 15,
    tempo = 12,
    percent = 5,
    storage = 45382,
    effect = 14
}

local function heal(cid, i, j)
    local player = Player(cid)
    if not player then
        return
    end
    if i >= j then
        return
    end
    local lifedraw = (player:getMaxHealth(cid) * (config.percent)/100)
    player:getPosition():sendMagicEffect(config.effect)
    player:addHealth(lifedraw) 
    addEvent(heal, 1000, cid, i+1, j)
end

function onCastSpell(creature, variant)
    local player = creature:getPlayer()
    if not player then
        return false
    end
    local remainingTime = (os.time() - player:getStorageValue(config.storage))
    if remainingTime >= config.cooldown then
        heal(player:getId(), 1, config.tempo)
        player:setStorageValue(config.storage, os.time())
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Your Mass Healing is at cooldown, you must wait "..(config.cooldown - remainingTime).." seconds.")
    end
    return true
end
 
Thanks for the code @Xeraphus
After some days testing, in have concluded this spell crash the server

i have created this spell but the spell dont show amount healed
Lua:
local combat = createCombatObject()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, false)
function onCastSpell(cid, var)
    local min = getCreatureMaxHealth(cid) * 5/250
    local max = getCreatureMaxHealth(cid) * 5/250
    local condition = createConditionObject(CONDITION_REGENERATION)
    condition:setParameter(CONDITION_PARAM_SUBID, 1)
    condition:setParameter(CONDITION_PARAM_BUFF, true)
    condition:setParameter(CONDITION_PARAM_TICKS, 1 * 20 * 1000)
    condition:setParameter(CONDITION_PARAM_HEALTHGAIN, math.max(math.random(min, max)))
    condition:setParameter(CONDITION_PARAM_HEALTHTICKS, 500)
    doAddCondition(cid, condition)
    return doCombat(cid, combat, var)
end

BUMP
 
Last edited:
Thanks for the code @Xeraphus
After some days testing, in have concluded this spell crash the server

i have created this spell but the spell dont show how much player heal
Lua:
local combat = createCombatObject()
combat:setParameter(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
combat:setParameter(combat, COMBAT_PARAM_AGGRESSIVE, false)
function onCastSpell(cid, var)
    local min = getCreatureMaxHealth(cid) * 5/250
    local max = getCreatureMaxHealth(cid) * 5/250
    local condition = createConditionObject(CONDITION_REGENERATION)
    condition:setParameter(CONDITION_PARAM_SUBID, 1)
    condition:setParameter(CONDITION_PARAM_BUFF, true)
    condition:setParameter(CONDITION_PARAM_TICKS, 1 * 20 * 1000)
    condition:setParameter(CONDITION_PARAM_HEALTHGAIN, math.max(math.random(min, max)))
    condition:setParameter(CONDITION_PARAM_HEALTHTICKS, 500)
    doAddCondition(cid, condition)
    return doCombat(cid, combat, var)
end

BUMP

Lua:
local player = Player(cid)
if player then
     player:say(value, TALKTYPE_SAY)
end

Then you need to make move math.max to a variable, so you get the same value on both places.
 
Why use?
Lua:
math.max(math.random(min, max))
math.random returns a random number between min and max not multiple numbers so math.max is an extra step which does nothing for your formula.
 
Why use?
Lua:
math.max(math.random(min, max))
math.random returns a random number between min and max not multiple numbers so math.max is an extra step which does nothing for your formula.
first version using number+level

Lua:
local player = Player(cid)
if player then
     player:say(value, TALKTYPE_SAY)
end

Then you need to make move math.max to a variable, so you get the same value on both places.
change
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HEALING)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, false)
function onCastSpell(cid, var)
local player = Player(cid)


    local min = player:getMaxHealth(cid) * 5/250
    local max = player:getMaxHealth(cid) * 5/200
    local value = math.max(min, max)
    local condition = createConditionObject(CONDITION_REGENERATION)
    condition:setParameter(CONDITION_PARAM_SUBID, 1)
    condition:setParameter(CONDITION_PARAM_BUFF, true)
    condition:setParameter(CONDITION_PARAM_TICKS, 1 * 20 * 1000)
    condition:setParameter(CONDITION_PARAM_HEALTHGAIN, value)
 
    player:addCondition(condition)
    player:sendTextMessage(MESSAGE_HEALED, ("You heal yourself for %d hitpoints."):format(value), player:getPosition(), value, TEXTCOLOR_MAYABLUE)
    return doCombat(cid, combat, var)
    end
02:05 You heal yourself for 24 hitpoints.

but dont show ticks/gain
 
Last edited:
I guess it supposed to be math.random instead.



What do you mean it doesn't show ticks/gain?

I don't think so since the values are the same, weird formula :p

change
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HEALING)
combat:setParameter(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
combat:setParameter(combat, COMBAT_PARAM_AGGRESSIVE, false)
function onCastSpell(cid, var)
local player = Player(cid)


    local min = player:getMaxHealth(cid) * 5/250
    local max = player:getMaxHealth(cid) * 5/200
    local value = math.max(min, max)
    local condition = createConditionObject(CONDITION_REGENERATION)
    condition:setParameter(CONDITION_PARAM_SUBID, 1)
    condition:setParameter(CONDITION_PARAM_BUFF, true)
    condition:setParameter(CONDITION_PARAM_TICKS, 1 * 20 * 1000)
    condition:setParameter(CONDITION_PARAM_HEALTHGAIN, value)
 
    player:addCondition(condition)
    player:sendTextMessage(MESSAGE_HEALED, ("You heal yourself for %d hitpoints."):format(value), player:getPosition(), value, TEXTCOLOR_MAYABLUE)
    return doCombat(cid, combat, var)
    end
02:05 You heal yourself for 24 hitpoints.

but dont show ticks/gain

In that case use an addEvent function with the same interval as the ticks
 
I don't think so since the values are the same, weird formula :p



In that case use an addEvent function with the same interval as the ticks
Yeah, that surely is weird.
However, they're not the same. They're differing with dividing number.
 
Oh didn't notice 200 and 250 :>
real values
local min = player:getMaxHealth() / 100*1.1
local max = player:getMaxHealth() / 100*1.3

I guess it supposed to be math.random instead.



What do you mean it doesn't show ticks/gain?
changend to random, Yes dont show ticks/gains
 
Last edited by a moderator:
real values
local min = player:getMaxHealth() / 100*1.1
local max = player:getMaxHealth() / 100*1.3


changend to random, Yes dont show ticks/gains

Edit your posts, don't double post ...
Rules for the Support board
#2

Lua:
local min = 1
local max = 100
local valueToGive = math.random(min, max)

player:addMana(valueToGive)
player:say(valueToGive, TALKTYPE_SAY)

That is gonna print out the value that was added to the players mana.
Just do the same with your script but add the mana via a condition.

As for it not "repeating" you need to - as I said use addEvent like this;
Lua:
local function showText(playerId, valueToGive)
    local player = Player(playerId)
    if player then
        player:say(valueToGive, TALKTYPE_SAY)
    end
end


addEvent(showText, interval, player:getId(), valueToGive)
 
Edit your posts, don't double post ...
Rules for the Support board
#2

Lua:
local min = 1
local max = 100
local valueToGive = math.random(min, max)

player:addMana(valueToGive)
player:say(valueToGive, TALKTYPE_SAY)

That is gonna print out the value that was added to the players mana.
Just do the same with your script but add the mana via a condition.

As for it not "repeating" you need to - as I said use addEvent like this;
Lua:
local function showText(playerId, valueToGive)
    local player = Player(playerId)
    if player then
        player:say(valueToGive, TALKTYPE_SAY)
    end
end


addEvent(showText, interval, player:getId(), valueToGive)
sorry for double.
dont work :(

23:13 Test [8500]: regrowth
23:13 Test [8500]: 2434.857

ill leave it as it is.
thanks all for help
 
sorry for double.
dont work :(

23:13 Test [8500]: regrowth
23:13 Test [8500]: 2434.857

ill leave it as it is.
thanks all for help

Ups
Lua:
local valueToGive = math.ceil(math.random(min, max))
Lua:
player:say(valueToGive, TALKTYPE_MONSTER_SAY)

That should in that case print 2435 in the same way monsters speak (the orange colour)
 
Solved =)
goldshovel.jpg

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)


function onCastSpell(creature, var)

local min = ((creature:getMaxHealth() / 100) * 2.5)
local max = ((creature:getMaxHealth() / 100) * 2.7)
local value = math.random(min, max)
  
local condition = Condition(CONDITION_REGENERATION)
condition:setParameter(CONDITION_PARAM_SUBID, 1)
condition:setParameter(CONDITION_PARAM_BUFF_SPELL, 1)
condition:setParameter(CONDITION_PARAM_TICKS, 23 * 1000)
condition:setParameter(CONDITION_PARAM_HEALTHGAIN, value)
condition:setParameter(CONDITION_PARAM_HEALTHTICKS, 2000)

    if not combat:execute(creature, var) then
        creature:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
        position:sendMagicEffect(CONST_ME_POFF)
        return false
    end
    creature:addCondition(condition)
  
    return true
end
 
Back
Top