• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

doCreatureAddHealth

Sigoles

Discord: @sigoles
Joined
Nov 20, 2015
Messages
1,209
Solutions
2
Reaction score
154
Why this dont working?

LUA:
local bossa = Game.createMonster('Demon', Position(30136, 30859, 15), false, true)
        if bossa then
            doCreatureAddHealth(bossa, -(getCreatureMaxHealth(bossa)-10000))
        end

the script is only creating the boss, this are not changing their HP

tfs 1.2
 
Solution
print(bossa) ; is it a creatureid and the correct one?

try this otherwise? not sure if your code is allowed in tfs 1.0+ (i know very little about tfs 1.0+)
LUA:
 if bossa then
     bossa:addHealth(-(bossa:getMaxHealth()-10000))
 end
print(bossa) ; is it a creatureid and the correct one?

try this otherwise? not sure if your code is allowed in tfs 1.0+ (i know very little about tfs 1.0+)
LUA:
 if bossa then
     bossa:addHealth(-(bossa:getMaxHealth()-10000))
 end
 
Solution
Demon has 8200 of health.

bossa:addHealth(-(bossa:getMaxHealth() - 10000))

Means:
bossa:addHealth(-(8200 - 10000))
bossa:addHealth(-(-1800))
bossa:addHeath(1800)

You are healing instead removing the Demon's health.
 
Demon has 8200 of health.

bossa:addHealth(-(bossa:getMaxHealth() - 10000))

Means:
bossa:addHealth(-(8200 - 10000))
bossa:addHealth(-(-1800))
bossa:addHeath(1800)

You are healing instead removing the Demon's health.

How its should work?
 
Will work?

LUA:
local specs, spec = Game.getSpectators(Position(30130, 30923, 15), false, false, 12, 12, 12, 12)
    for i = 1, #specs do
        spec = specs[i]
        if spec:isMonster() and spec:getName():lower() == 'demon' then     
            local posA = spec:getPosition()
            local creatureHealth=getCreatureHealth(spec)
            spec:addHealth(-1800)
        end
    end
 
Back
Top