| Blockland Forums > Modification Help |
| Index out of range on ClientGroup. |
| (1/2) > >> |
| LundoomGaming:
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. |
| Daenth:
--- Quote from: LundoomGaming on June 13, 2012, 03:28:20 PM ---Note: I don't want to post the code for the script. Just give me examples of when this can occur. --- End quote --- 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. --- Quote from: LundoomGaming on June 13, 2012, 03:28:20 PM ---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. --- End quote --- 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);. |
| LundoomGaming:
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: --- %count = ClientGroup.getcount(); for(%a=0;%a<%count;%a++) { applesauce(); } --- End code --- basically it allows me to apply code to every player on the server individually. |
| otto-san:
that code will call applesauce an amount of times equal to the number of players in the server --- Quote from: LundoomGaming on June 13, 2012, 03:43:46 PM ---basically it allows me to apply code to every player on the server individually. --- End quote --- unless applesauce does this no it will not |
| Daenth:
--- Quote from: LundoomGaming on June 13, 2012, 03:43:46 PM ---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: --- %count = ClientGroup.getcount(); for(%a=0;%a<%count;%a++) { applesauce(); } --- End code --- basically it allows me to apply code to every player on the server individually. --- End quote --- 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: ---%c = ClientGroup.getCount(); for(%i=0;%i<%c;%i++) { %client = ClientGroup.getObject(%i); applesauce(%client); } --- End code --- |
| Navigation |
| Message Index |
| Next page |