• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[LUA] TriggerRegister Not working right

Status
Not open for further replies.
Level 8
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
 
Status
Not open for further replies.
Top