Author Topic: Index out of range on ClientGroup.  (Read 996 times)

Hey, I'm writing a script, and it uses ClientGroup to find out how many players there are on the server, but whenever it's executed, it sends this to the console:

Set::getObject index out of range on ClientGroup. Index = 2, Size = 2 //persuming that the 2 is the playercount, as 2 players were on the serfver when this was in the console.

What does this mean?

Thanks!



Note: I don't want to post the code for the script. Just give me examples of when this can occur.
« Last Edit: June 13, 2012, 03:32:19 PM by LundoomGaming »

Note: I don't want to post the code for the script. Just give me examples of when this can occur.
None of us are going to steal your code, I hope you realize that. We can't help as well without the code.

Anyways, it looks like you're using ClientGroup.getObject(%i); instead of ClientGroup.getCount(); to get the count of all the players.

EDIT: Just saw that edit.
Set::getObject index out of range on ClientGroup. Index = 2, Size = 2 //persuming that the 2 is the playercount, as 2 players were on the serfver when this was in the console.
The object values start at 0, not 1. Therefore, if there are two players and you want to get the first player you need to use ClientGroup.getObject(0); and to get the second player you need to use ClientGroup.getObject(1);.
« Last Edit: June 13, 2012, 03:38:05 PM by Daenth »

Considering the code was uploaded to mediafire, without my knowledge, apparently people are going to steal my code.


The usage of the ClientGroup in the code is

Code: [Select]
%count = ClientGroup.getcount();
for(%a=0;%a<%count;%a++)
{
         applesauce();
        }

basically it allows me to apply code to every player on the server individually.

that code will call applesauce an amount of times equal to the number of players in the server

basically it allows me to apply code to every player on the server individually.

unless applesauce does this no it will not

Considering the code was uploaded to mediafire, without my knowledge, apparently people are going to steal my code.


The usage of the ClientGroup in the code is

Code: [Select]
%count = ClientGroup.getcount();
for(%a=0;%a<%count;%a++)
{
         applesauce();
        }

basically it allows me to apply code to every player on the server individually.
Then I have no idea who you are sharing your code with. You do realize that code is not unique and that anyone could replicate whatever you're coding? Hiding your code just makes it harder for us and accomplishes nothing.

On topic, you're almost there, you just have to define the client.
Code: [Select]
%c = ClientGroup.getCount();
for(%i=0;%i<%c;%i++) {
   %client = ClientGroup.getObject(%i);
   applesauce(%client);
}

Then I have no idea who you are sharing your code with. You do realize that code is not unique and that anyone could replicate whatever you're coding? Hiding your code just makes it harder for us and accomplishes nothing.

Yeah, anyone of us helping you could probably remake your mod, 10x better.

You guys don't really need the whole code though, you have the part of the code thats causing an error.

Edit: Figured out whats wrong. Thanks Daenth.