Author Topic: Everyone In Server  (Read 1704 times)

How do you make everyone in the server do a certain thing?
Like for an example, I wanted to kill everyone in the server all at once.
How would I do that?

%count = clientGroup.getCount();

for(%i = 0; %i < %count; %i++)
{
      %player = clientGroup.getObject(%i).player;
      //do other stuff
}

%count = clientGroup.getCount();

for(%i = 0; %i < %count; %i++)
{
      %player = clientGroup.getObject(%i).player;
      //do other stuff
}
Ah, thank you

Kill everyone :cookieMonster:
Code: [Select]
%count = ClientGroup.getCount();

for(%a = 0; %a < %count; %a++)
{
    %player = clientGroup.getObject(%a).player;
    if(isObject(%player))
    {
%player.kill();
    }
}

Loop through the client group object and use the .getObject method to get a child from the client group object (the parent).

Edit: in after the spoon feeding.

Thanks for the help guys.
But while you're still on, how do you make it so that it takes affect on everyone BUT the client who is entering in the command?

That, my friend, is ****ing cray-cray

That, my friend, is ****ing cray-cray
No...
But if no one knows how to do this, I'm okay.

Code: [Select]
%count = ClientGroup.getCount();

for(%a = 0; %a < %count; %a++)
{
    %player = clientGroup.getObject(%a).player;
    if(isObject(%player) && %player.getID() !$= %client.getID())
    {
%player.kill();
    }
}

compare the object in question's ID to the ID of the client doing the command. note this is object ID, not BL_ID.

NAT, keep in mind that otto's code assumes that you have placed it within a server command.

compare the object in question's ID to the ID of the client doing the command. note this is object ID, not BL_ID.
You are comparing a client object ID and a player object ID, you are also using a string comparison for two integers, which isn't really a big deal but using "!=" instead would be faster ;D

But while you're still on, how do you make it so that it takes affect on everyone BUT the client who is entering in the command?

Quote
function serverCmdKillAll(%client)
{
   for(%a=0;%a<ClientGroup.getcount();%a++)
   {
      %all = ClientGroup.getObject(%a);
      
      if(%all != %client && isObject(%all.player))
      {
         %all.player.kill();
      }
   }
}

Edit: Fixed..
« Last Edit: April 18, 2013, 04:23:54 AM by Honorabl3 »

I don't think I made any mistakes. ^^^

%client is an object index, not a member index within the ClientGroup.

%client is an object index, not a member index within the ClientGroup.
Why would you say that?
« Last Edit: April 17, 2013, 10:54:25 PM by Honorabl3 »

%client is an object index, not a member index within the ClientGroup.
%client is presumably a client object and is already in ClientGroup under normal functionality.

He should have "serverCmd"