That wait 20 you have in there is not very efficient for multi client scripting. Since you're swapping, there's no real need to wait after the attack, just set a timer for that client, which is about the speed you can attack at on multiple clients, and swap, and when you return to that client, check the timer to see if it's up again, and you're able to attack. The whole time, checking for spawn, and monsters you can attack with your pet. Including people. I wrote this very quickly, but it should constantly update your target with either the monster your clients are attacking, or once that monster is dead, it will attack a new monster. Not sure it works, haven't tested, but it's close. To be complete, you probably should set your #ltargetkind also. I'm just a noob and always forget to do that until it messes up.
set %targets ;Put target types here
set %range 10
for %i 1 #cliCnt
{
set %attackTimer . #charid #systime
set %targetFoundTimer . #charid #systime
}
repeat
set %targetFound n/a
set %target1 n/a
finditem %targets g_ , %range
if #findcnt > 0
{
for #findindex 1 #findcnt
{
if #findid = %target
{
if %targetFoundTimer . #charid < #sysTime
set %targetFoundTimer . #charid #systime + 10000
set %targetFound #findid
break
}
set %target1 #findid
}
}
if %target1 <> n/a
set %target %target1
if %targetFound <> n/a
set %target %targetFound
else
set %targetFoundTimer . #charid #sysTime - 1
for %i 1 #clicnt
{
if %target <> n/a && %attackTimer . #charid < #systime && %targetFoundTimer . #charid < #systime
gosub attackTarget
uoxl swap
}
until #false
sub attackTarget
msg $all kill$
set #ltargetid %target
target 1s
event macro 22
if %targetFound <> n/a && %targetFoundTimer . #charid < #systime
set %targetFoundTimer . #charid #systime + 10000
set %attackTimer . #charid #systime + 1000
return