Hello,
I'm learning Java and I'm relatively new to the scene. I decided to make a small free utility with the hope that it will help somebody. The utility is a Game Server (Call of Duty 4) connector that will help Administrators to connect to the server and execute commands without the need of running the game.
I have made a progress so far by searching these (very useful) forums but I came across a point that I can't by pass.
The only way to learn "Who Is" from the server is the rcon command "status". Using this command the server returns you the current map and the players playing with all their information. This is the part of the code that I need help at:
public static void StatusReader(String StatusInput) throws IOException {
ArrayList line = new ArrayList();
BufferedReader br = new BufferedReader(new StringReader(StatusInput));
String s = null;
int l=0;
dokimi = StatusInput.split("\n");
// for(int j=0;j<9;j++){
// int i=0;
// dokimi2 = new String[0][0];
// dokimi2[0][0] = dokimi[0];
// System.out.println(dokimi2[0][0]);
// }
System.arraycopy(dokimi, 0, dokimi2, 0, 1);
for(int i=0;i<(dokimi.length/9);i++){
for(int j=0;j<9;j++){
dokimi2 = new String[i][j];
System.arraycopy(dokimi, 0, dokimi2[i][j], 0, 1);
System.out.println(dokimi2[i][j]);
}
}
// while ((s = br.readLine()) != null)
// line.add(s);
// StatusOutput = new String[line.size()][];
// for (int i = 0; i < StatusOutput.length; i++) {
// s = (String) line.get(i);
// StringTokenizer st = new StringTokenizer(s, "");
// String[] arr = new String[st.countTokens()];
// for (int j = 0; j < arr.length; j++)
// arr[j] = st.nextToken();
// StatusOutput[i] = arr;
// }
// for (int i = 0; i < StatusOutput.length; i++) {
// for (int j = 0; j < StatusOutput.length; j++)
// System.out.print(StatusOutput[i][j] + " ");
// System.out.println();
// }
}I've been messing a lot with the code. +_What I want to do is to read this string that the server is sending,split it, and then place it in a 2D Array that I will attach on a table._+ So far I've made the StringTokenizer method to be able to , kind of, sort that String and put it in an array. However I usually get outofbounds errors because not always the lines have the same length. This is an example of the format that the server sends after executing the "status" command:
map: mp_crossfire
num score ping guid name lastmsg address qport rate
--- ----- ---- -------------------------------- --------------- ------- --------------------- ----- -----
2 1 84 b5e9d93e88670c6f811a033a7f925117 Davis^7 0 84.185.183.210:-1482 21249 25000
4 15 100 e0d7c91fa7ba9549444ccab3a0e3de62 =HPX= Anogianos^7 0 91.140.25.93:28960 -10752 25000
5 5 68 5d68298d9e16d7491d5700e6e236214f AsChIkUtAbU^7 50 84.60.215.190:17502 26401 25000
6 115 44 cc503f50d990e27eeb990826c2cf1193 Donnergroll^7 50 91.64.153.240:28960 10086 25000
7 141 79 cbd095d37abdc728671e2923296aa9cf souL^7 50 87.78.179.242:-10509 8432 25000
8 116 83 4d0d1a067179516e209ef89cb0a79755 suodeth^7 0 84.250.214.156:27185 -29970 25000
9 11 117 fc3c6777b3d9bf99df1e55b321b75e9e shpalman^7 50 62.101.126.209:-17420 -25455 25000
10 5 82 fb2f20a9f46a212b896baf9ab4ea3eb0 =HPX=Gringo^7 50 213.5.170.94:-619 20175 25000
11 95 68 d3d542b17ab56d9fbf107da39f245269 aga^7 50 78.2.42.253:28960 22173 25000
12 10 100 8e6d08aec08591fb319081d0b40dedd2 madmax^7 0 79.166.47.145:2960 -7933 25000
13 110 77 4fc4d0e24faa634dbce5c4bb4131bc4a Thunderstorm^7 50 87.78.113.218:28960 4512 25000
14 55 67 f789227fcb95853b857115e68741df8d Robbino^7 0 89.217.12.113:28960 -192 25000
15 118 85 b7be8ce58324d0f25c45f5cb372b30a1 Paranoid^7 50 78.1.26.32:28960 27294 25000
16 11 90 38b59f3bbd3aa0ce3c95fccb26858931 $Hockz^7 50 87.181.101.96:-2984 24219 25000
19 16 45 720f2abf81189890851d3e41fcbe4e21 ERASER^7 50 83.236.63.150:-32135 24704 25000
20 145 37 a78f43bc3d3705743a190de45d37fc6a KintaKunte^7 50 88.68.237.239:28960 23539 25000
21 60 49 a96d6a55049d11c5d7cd1c35c4d497c3 #sD|-HaZarD-^7 50 87.78.179.242:-10509 8432 25000
8 116 83 4d0d1a067179516e209ef89cb0a79755 suodeth^7 0 84.250.214.156:27185 -29970 25000
9 11 117 fc3c6777b3d9bf99df1e55b321b75e9e shpalman^7 50 62.101.126.209:-17420 -25455 25000
10 5 82 fb2f20a9f46a212b896baf9ab4ea3eb0 =HPX=Gringo^7 50 213.5.170.94:-619 20175 25000
11 95 68 d3d542b17ab56d9fbf107da39f245269 aga^7 50 78.2.42.253:28960 22173 25000
12 10 100 8e6d08aec08591fb319081d0b40dedd2 madmax^7 0 79.166.47.145:2 0 91.3.110.248:-1185 6274 25000
23 116 109 bfffdf9ff93425d284796532ef214bd0 ze_meedles^7 50 85.243.221.116:28960 24936 25000
95853b857115e68741df8d Robbino^7 0 89.217.12.113:28960 -192 25000
15 118 85 b7be8ce58324d0f25c45f5cb372b30a1 Paranoid^7 50 78.1.26.32:28960 27294 25000
16 11 90 38b59f3bbd3aa0ce3c95fccb26858931 $Hockz^7 50 87.181.101.96:-2984 24219 25000
19 16 45 720f2abf81189890851d3e41fcbe4e21 ERASER^7 50 83.236.63.150:-32135 24704 25000
20 145 37 a78f43bc3d3705743a190de45d37fc6a KintaKunte^7 50 88.68.237.239:28960 23539 25000
21 60 49 a96d6a55049d11c5d7cd1c35c4d497c3 #sD|-HaZarD-^7 50 87.78.179.242:-10509 8432 25000
8 116 83 4d0d1a067179516e209ef89cb0a79755 suodeth^7 0 84.250.214.156:27185 -29970 25000
9 11 117 fc3c6777b3d9bf99df1e55b321b75e9e shpalman^7 50 62.101.126.209:-17420 -25455 25000
10 5 82 fb2f20a9f46a212b896baf9ab4ea3eb0 =HPX=Gringo^7 50 213.5.170.94:-619 20175 25000
11 95 68 d3d542b17ab56d9fbf107da39f245269 aga^7 50 78.2.42.253:28960 22173 25000
12 10 100 8e6d08aec08591fb319081d0b40dedd2 madmax^7 0 79.166.47.145:2As you can see the problem is that the server sends some information twice *but* it splits them with a blank line. In addition some nicknames contain spaces something that makes me wonder how I can set the nicknames to belong to the same position of the array. Something that i know is that all nicknames end with "^7" which is the in-game colour definition. Any help would be much appreciated. Thanks in advance.
Edited by: m33ts4k0z on Dec 21, 2007 11:36 AM
Edited by: m33ts4k0z on Dec 21, 2007 11:43 AM