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

Lua TFS 0.4 doStatsChange not work together with doCreatureAddHealth

Valakinhasz

New Member
Joined
Jun 3, 2016
Messages
3
Reaction score
0
wrong title ignore :v

Hello dear Friends I make a Poketibia Server but i have a problem using tfs 0.4

Function in creaturescript It does not work properly, onStatsChange ignoring doCreatureAddHealth

Example:


doCreatureAddHealth <- this function work

onStatsChange not work together with doCreatureAddHealth, it is as if ignored doCreatureAddHealth





srry bad english i speak other language :v
 
Last edited:
Any errors?
Have you tried changing
Code:
doCreatureAddHealth(cid, -math.abs(valor))
to
Code:
doCreatureAddHealth(cid, -100)
to make sure that it actually works first and see if it's valor that is the problem?
Also,
Code:
function onStatsChange(cid, attacker, type, combatee, value)
You put "combatee" for some reason
should be "combat".
 
Any errors?
Have you tried changing
Code:
doCreatureAddHealth(cid, -math.abs(valor))
to
Code:
doCreatureAddHealth(cid, -100)
to make sure that it actually works first and see if it's valor that is the problem?
Also,
Code:
function onStatsChange(cid, attacker, type, combatee, value)
You put "combatee" for some reason
should be "combat".
I've already tried it

I tried the 2 ways you said, not work ;/
 
data\creaturescripts\scripts\test.lua
Code:
function onStatsChange(cid, attacker, type, combat, value)

    if not isCreature(attacker) then
        return false
    end

    if isPlayer(attacker) then
        return false
    end

    if type == STATSCHANGE_HEALTHGAIN then
        return true
    end
    if isSummon(attacker) then
        local random = math.random(85, 100)
        local valor = (((((value/getPokemonDefense(cid))/50)+2)* getValueEffectiveness(getPokemonType(attacker), getPokemonType(cid)) * random)/100)
        print(valor)
        doCreatureAddHealth(cid, -math.abs(valor))
        print("Finish addhealth")
        return false
    end
    print("Finish Script")
return false
end
data\creaturescripts\creaturescripts.xml
Code:
<event type="statschange" name="test" script="test.lua"/>
data\creaturescripts\scripts\login.lua
Code:
registerCreatureEvent(cid, "test")

See if this works?
 
data\creaturescripts\scripts\test.lua
Code:
function onStatsChange(cid, attacker, type, combat, value)

    if not isCreature(attacker) then
        return false
    end

    if isPlayer(attacker) then
        return false
    end

    if type == STATSCHANGE_HEALTHGAIN then
        return true
    end
    if isSummon(attacker) then
        local random = math.random(85, 100)
        local valor = (((((value/getPokemonDefense(cid))/50)+2)* getValueEffectiveness(getPokemonType(attacker), getPokemonType(cid)) * random)/100)
        print(valor)
        doCreatureAddHealth(cid, -math.abs(valor))
        print("Finish addhealth")
        return false
    end
    print("Finish Script")
return false
end
data\creaturescripts\creaturescripts.xml
Code:
<event type="statschange" name="test" script="test.lua"/>
data\creaturescripts\scripts\login.lua
Code:
registerCreatureEvent(cid, "test")

See if this works?
That pink is so jarring on the default white background, it's hard to read. :P
 
Back
Top