Mitsuri
日本人だ
I want one doll to drain health points from the enemy.
Firstly I did it as follows:
but it went crazy, even when I wasn't attacking monster (but I had it selected) physically I was receiving health twice a second ! ! !
Then I wanted to check out what the hell is going on by:
Then I did something like this:
But it went even worse! Even after stopping (de-selecting) monster I was reciving info about his health points! Twice a second!
Can someone tell me what the hell is going on with this script ?!
Firstly I did it as follows:
function drainHP(cid, target)
-- GET HEALTH
local CreatureHealth = getCreatureHealth(target)
if (CreatureHealth < 10000) then
if (isPlayer(target)) then
healthToAdd = math.random(CreatureHealth/15, CreatureHealth/13)
else
healthToAdd = math.random(CreatureHealth/12, CreatureHealth/10)
end
roundHealth = math.ceil(healthToAdd)
doCreatureAddHealth(cid, roundHealth)
doCreatureAddHealth(cid, -roundHealth)
end
addEvent(drainHP, 2000, cid, target)
end
function onAttack(cid, target)
if (getPlayerStorageValue(cid, 25000) > -1) then
addEvent(drainHP, 2000, cid, target)
else
stopEvent(drainHP)
end
return TRUE
end
but it went crazy, even when I wasn't attacking monster (but I had it selected) physically I was receiving health twice a second ! ! !
Then I wanted to check out what the hell is going on by:
but it was same as above!function drainHP(cid, target)
-- GET HEALTH
local CreatureHealth = getCreatureHealth(target)
doPlayerSendTextMessage(cid, 25, getCreatureName(target) .. ':' ..CreatureHealth)
addEvent(drainHP, 2000, cid, target, minuteStack)
end
function onAttack(cid, target)
if (getPlayerStorageValue(cid, 25000) > -1) then
addEvent(drainHP, 2000, cid, target)
else
stopEvent(drainHP)
end
return TRUE
end
Then I did something like this:
function drainHP(cid, target, stack)
-- GET HEALTH
local minuteStack = stack
if (minuteStack == 10) then
local CreatureHealth = getCreatureHealth(target)
doPlayerSendTextMessage(cid, 25, getCreatureName(target) .. ':' ..CreatureHealth)
minuteStack = 0
else
minuteStack = (minuteStack + 1)
end
addEvent(drainHP, 2000, cid, target, minuteStack)
end
function onAttack(cid, target)
local minuteStack = 0
if (getPlayerStorageValue(cid, 25000) > -1) then
addEvent(drainHP, 2000, cid, target, minuteStack)
else
stopEvent(drainHP)
end
return TRUE
end
But it went even worse! Even after stopping (de-selecting) monster I was reciving info about his health points! Twice a second!
Can someone tell me what the hell is going on with this script ?!