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

CreatureEvent What the hell is going on?!

Mitsuri

日本人だ
Joined
Sep 14, 2008
Messages
34
Reaction score
1
Location
茅ヶ崎「神奈川県」, Japan
I want one doll to drain health points from the enemy.

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:
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
but it was same as above!

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 ?!
 
Back
Top