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

help on CreatureScript function onStatsChange (50% more damage system) on .lua

beenii

Well-Known Member
Joined
Jul 26, 2010
Messages
586
Solutions
1
Reaction score
58
usin TFS 0.3.6

Code:
function onStatsChange(cid, attacker, type, combat, value)
local storage = 23451
if exhaustion.check(attacker, storage) == true then
if type == STATSCHANGE_HEALTHLOSS and isPlayer(cid) and isPlayer(attacker) then
doPlayerSendTextMessage(attacker, 28 , "you give "..value.." damage to " ..getPlayerName(cid).. ", already caused extra damage "..((value)*(0.50)).." is 50% bonus!!" )
doSendMagicEffect(getPlayerPosition(attacker), 13)


doCreatureAddHealth(cid, - value*0.50 )
doSendAnimatedText(getCreaturePosition(cid), '- '..((value)*(0.50))..'', TEXTCOLOR_RED)
doSendMagicEffect(getPlayerPosition(cid), 34)
end
end
return true
end

anyone know how I can create 50% more damage on monsters?
 
Last edited:
You have to register that onStatsChange script to a targeted creature before you deal damage.
Code:
registerCreatureEvent(target, "name")

For players use login.lua

Some cosmetics:
Change:
Code:
doCreatureAddHealth(cid, - value*0.50 )
doSendAnimatedText(getCreaturePosition(cid), '- '..((value)*(0.50))..'', TEXTCOLOR_RED)
doSendMagicEffect(getPlayerPosition(cid), 34)
To:
Code:
return doTargetCombatHealth(attacker, target, type, - value*1.50, - value*1.50, 34)

And value * 0.5 means you deal 50% of normal damage (50% less damage).
Your calculations should looks like this: value * 1.5 this means you deal 150% normal damage (50% more damage, like topic says).
 
Last edited:
i try with
registerCreatureEvent(target, "Dragon")

and
registerCreatureEvent(target, "name")

Code:
[09/04/2014 13:54:03] [Error - CreatureScript Interface]
[09/04/2014 13:54:03] data/creaturescripts/scripts/login.lua:onLogin
[09/04/2014 13:54:03] Description:
[09/04/2014 13:54:03] (luaRegisterCreatureEvent) Creature not found
[09/04/2014 13:54:05] Test Uno Kill has logged out.
[09/04/2014 13:54:06] God Remady has logged in.

[09/04/2014 13:54:06] [Error - CreatureScript Interface]
[09/04/2014 13:54:06] data/creaturescripts/scripts/login.lua:onLogin
[09/04/2014 13:54:06] Description:
[09/04/2014 13:54:06] (luaRegisterCreatureEvent) Creature not found
[09/04/2014 13:54:10] God Remady has logged out.
[09/04/2014 13:54:11] Test Uno Kill has logged in.

[09/04/2014 13:54:11] [Error - CreatureScript Interface]
[09/04/2014 13:54:11] data/creaturescripts/scripts/login.lua:onLogin
[09/04/2014 13:54:11] Description:
[09/04/2014 13:54:11] (luaRegisterCreatureEvent) Creature not found


script:

Code:
local storage = 23451
function onStatsChange(cid, attacker, type, combat, value)


    if not isPlayer(attacker) then
        return true
    end

if type == STATSCHANGE_HEALTHLOSS and exhaustion.check(attacker, storage) == true and isPlayer(cid) and isPlayer(attacker) then
doPlayerSendTextMessage(attacker, 28 , "[+ "..((value)*(0.50)).." Damage To " ..getPlayerName(cid).. "]" )
doSendMagicEffect(getPlayerPosition(attacker), 13)




end
return doTargetCombatHealth(attacker, target, type, - value*1.50, - value*1.50, 34)
end
 
Code:
function onStatsChange(cid, attacker, type, combat, value)
  registerCreatureEvent(target, "Dragon")
  local storage = 23451
    if not isPlayer(attacker) then
      return true
    end
    if type == STATSCHANGE_HEALTHLOSS and exhaustion.check(attacker, storage) == true and isPlayer(cid) and isPlayer(attacker) then
      doPlayerSendTextMessage(attacker, 28 , "[+ "..((value)*(0.50)).." Damage To " ..getPlayerName(cid).. "]" )
      doSendMagicEffect(getPlayerPosition(attacker), 13)
    end
  return doTargetCombatHealth(attacker, target, type, -value*1.50, -value*1.50, 34)
end
 
Back
Top