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

Need a little bit of help with onCombat function.

Baneczek

うさちゃん
Joined
Nov 13, 2013
Messages
70
Reaction score
4
Location
Pila, Poland
Hello guys. I wrote a really simple script that executes animation (custom) on creature when i attack it. It works, but not as i wanted it to work. It executes the animation when i click on the creature even if i don't hit it and am away from the creature. I want it to execute the animation only when i hit the creature.

Here is the script:
Code:
function onCombat(cid,target)
local pos = getCreaturePosition(target)
if getPlayerVocation(cid) == 4 then
doSendMagicEffect(pos,151)
end
return true
end

EDIT: I tried with onAttack function, but then it continues the animation again and again, even from away.
 
You can use statschange instead of combat, although then someone needs to lose health/mana for the effect to appear.
Code:
function onStatsChange(cid, attacker, type, combat, value)
     if isPlayer(attacker) and getPlayerVocation(attacker) == 4 and (type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS) then
         doSendMagicEffect(getCreaturePosition(cid), 151)
     end
     return true
end
 
Thank you, i'll check it later when i'm back home.

EDIT: It works, but i also had to write onCombat script that registers onStatsChange one.
 
Last edited:
Back
Top