I did something similar. A server had hundreds of people in Tanaris so I wrote a script to try and target as many as possible with a spell:
Code:
function IncDuration(self, elapsed)
dur = dur + elapsed;
if dur > 0.01 then
local me = UnitName("player")
if curWho < maxWho then
TargetUnit(who[curWho])
if UnitName("target") then
if UnitName("target") ~= me then
CastSpellByName("Crown Parcel Service Uniform")
end
end
curWho = curWho + 1
else
who_target = who_target + 1
if who_target > #classes_who then
who_target = 1
end
who_target_two = who_target + 1
if who_target_two > #classes_who then
who_target_two = 1
end
who={}
SendWho("z-Tanaris "..classes_who[who_target].." "..classes_who[who_target_two])
for i=1,GetNumWhoResults() do
n=GetWhoInfo(i)
who[i]=n
end
curWho=1
maxWho=#who
end
dur = 0
end
end
who_target = 0
classes_who = {"c-Mage", "c-Warrior", "c-Druid", "c-Warlock", "c-Priest", "c-Paladin", "c-Hunter", "c-Death Knight", "c-Shaman", "c-Rogue"}
You can just store the results instead of using them immediately.