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

Players still dying

Joined
Apr 11, 2015
Messages
102
Reaction score
6
I'm struggling to implement a feature where a player does not die under certain conditions in TFS 1.3. I'm using onHealthChange to check for the condition and prevent death by restoring the player's health and mana when the incoming damage would be fatal. Here's the script I'm using:

Lua:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if creature:isPlayer() and creature:getStorageValue(98768) > os.time() then
        local totalDamage = primaryDamage + secondaryDamage
        if totalDamage >= creature:getHealth() then
            creature:addHealth(creature:getMaxHealth())
            creature:addMana(creature:getMaxMana())
            return false 
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

However, the player still dies despite meeting the conditions. Any ideas on what might be missing or suggestions on a different approach?
 
Back
Top