Skip to content
User Avatar
#3940
Auto-translated
I don't quite understand this part: ``` for i=0,6 do local type, num = GetObjectArmySlotCreature("ritual", i) if (type >= 30 and type <= 42 and mod(type, 2) == 0) or (type >= 152 and type <= 158) then startThread(NecroRitual) SetObjectOwner("ritual", PLAYER_2) end end. ``` And then in the ritual function: ``` for i=0,6 do local type, num = GetObjectArmySlotCreature("ritual", i) if GetObjectArmySlotCreature("ritual", i) == 30 then RemoveObjectCreatures('ritual', type, num, i) ... ``` Why are you setting the hero as the owner for each slot? It seems like this could be done outside the loop. And why are you starting a new thread for each slot? I haven't run the script, but it looks like you're starting 2 threads for two slots that run in parallel, and when the processing of the second cycle in the ritual function goes through all the slots again, the first slot hasn't been cleared yet (by the first thread). It seems that if you remove the loop in the function or remove the duplicate threads, everything should work. Like this: ``` MakeHeroInteractWithObject(hero, "ritual") sleep(10) startThread(NecroRitual) SetObjectOwner("ritual", PLAYER_2) local x,y = GetObjectPosition(Hero) ... ``` Also, this is purely aesthetic, but since you're getting the hero's name from the function, why are you writing "Hafad" in other places?