• 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!

TFS 1.X+ onHealthChange tfs 1.2

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,188
Solutions
34
Reaction score
200
Hello, i`m using tfs 1.2
I made this script, so when the player has storage 100 of value 1, it will defend all attacks...
but the bug happens when the player uses some heal magic, it does not get heal, because the script is denying even this

Code:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType)

if creature:getStorageValue(100) == 1 then
    creature:getPosition():sendMagicEffect(3)
    return false
end

return true
end

i have tried somethins like this, but not work:

Code:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType)

if primaryType == COMBAT_HEALING then
    return true
end

if creature:getStorageValue(100) == 1 then
    creature:getPosition():sendMagicEffect(3)
    return false
end

return true
end
 
Last edited:
Solution
Lua:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType)
  if primaryType ~= COMBAT_HEALING or secondaryType ~= COMBAT_HEALING then
    local player = creature:getPlayer()
    if player and creature ~= attacker then
      if player:getStorageValue(100) == 1 then
        primaryDamage, secondaryDamage = 0, 0
      end
    end
  end
  return primaryDamage, primaryType, secondaryDamage, secondaryType
end
Lua:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType)
  if primaryType ~= COMBAT_HEALING or secondaryType ~= COMBAT_HEALING then
    local player = creature:getPlayer()
    if player and creature ~= attacker then
      if player:getStorageValue(100) == 1 then
        primaryDamage, secondaryDamage = 0, 0
      end
    end
  end
  return primaryDamage, primaryType, secondaryDamage, secondaryType
end
 
Last edited:
Solution
Lua:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType)
  if primaryType ~= COMBAT_HEALING or secondaryType ~= COMBAT_HEALING then
    local player = creature:getPlayer()
    if player then
      if player:getStorageValue(100) == 1 then
        primaryDamage, secondaryDamage = 0, 0
      end
    end
  end
  return primaryDamage, primaryType, secondaryDamage, secondaryType
end
when the demon hits me, I do not take any damage (OK)
but if I try to heal myself using exura or exura vita, I can not heal
 
Back
Top