Quite a few things:
Eluna API
RegisterUnitEvent is not a valid Eluna function - are you trying to use the ArcEmu API?
I suspect you want: Global:RegisterCreatureEvent - Eluna
CREATURE_EVENT_ON_DAMAGE_TAKEN = 9, // (event, creature, attacker, damage)
Now this documents different parameters and parameter order to what you have specified.
Also you have called a parameter pUnit but you are refering to 'creature' in your script. 'creature' is not defined anywhere, you need to rename one or the other.
You are called RemoveEvents twice - why? RemoveEvents is when you want to remove all events that have been registered with the RegisterEvent function on the object.
I suspect you want something more like:
Code:
local NPC_ID = 43285
local function OnDamageTaken(event, creature, attacker, damage)
if creature:GetHealthPct() < 75 then
creature:SendUnitSay("TESTING TESTING 123", 0)
end
end
RegisterCreatureEvent(NPC_ID, 9, OnDamageTaken)
But this is going to happen every time the creature takes damage while the health is less than 75%. I suspect you want something more like:
Code:
local NPC_ID = 43285
local function CheckHealthPct(_, _, _, creature)
if creature:GetHealthPct() < 75 then
creature:RemoveEvents()
creature:SendUnitSay("TESTING TESTING 123", 0)
end
end
local function CreatureEvents(event, creature)
if event == 1 then
pUnit:RegisterEvent(CheckHealthPct, 1000, 0)
else
pUnit:RemoveEvents()
end
end
RegisterCreatureEvent(NPC_ID, 1, CreatureEvents) -- OnCreatureEnterCombat
RegisterCreatureEvent(NPC_ID, 2, CreatureEvents) -- OnCreatureLeaveCombat
RegisterCreatureEvent(NPC_ID, 4, CreatureEvents) -- OnCreatureDied