function serverCmdSpawnSpec(%cl) {
for(%i=0;%i<ClientGroup.getCount();%i++) {
%new=ClientGroup.getObject(%i);
if(isObject(%new.player)&&%new!=%cl)
%valid[%j++]=%new;
}
if(!%j)
return;
%temp=%cl.isAdmin;
%cl.isAdmin=1;
serverCmdSpy(%cl,%valid[getRandom(1,%j)]);
%cl.isAdmin=%temp;
}
That's just off the top of my head, but something like that should work.
- Loops through the client group, one by one
- If they have a player object and they're not you, add to list of valid clients
- If no one is on list of valid clients, exits function
- Temporarily makes you an admin to use spy
- Calls serverCmdSpy which targets a random valid client