- Joined
- Jun 16, 2008
- Messages
- 333
So I have this code, I am trying to pass a group through a TriggerRegisterUnitinRangeSimple Event but for some reason it runs in the begging of the map. This is my code
Lua:
function HeroCol()
for i = 0, 14, 1 do
local hero = GetUnitsOfPlayerAll(Player(i))
ForGroup(hero, HeroKillcon)
DestroyGroup(hero)
end
end
function HeroKillcon()
xpcall(function()
local EnumHero = GetEnumUnit()
local heroCollision = CreateTrigger()
TriggerRegisterUnitInRangeSimple(heroCollision, 256, EnumHero)
TriggerAddAction(heroCollision, heroKill(EnumHero))
end, print)
end
function heroKill(a)
print(a)
if GetOwningPlayer(GetTriggerUnit()) == Player(15) then
KillUnit(a)
end
end