I’ve got a button where if I click it, it retrieves player information on a game server.
I need to figure out a way to display this in a grid.
When I do a Console.Write(sendRConCommand(“players”))
This is outputted to my console:
Players on server:
[#] [IP Address]:[Port] [Ping] [GUID] [Name]
--------------------------------------------------
0 XXX.XXX.XXX.XXX:XXXX 46 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(OK) [FF]Otto
1 XXX.XXX.XXX.XXX:XXXX 109 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(OK) [BBC] Emma Watson
2 XXX.XXX.XXX.XXX:XXXX 46 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(OK) [FF]Miikka
3 XXX.XXX.XXX.XXX:XXXX 46 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(OK) Bops
4 XXX.XXX.XXX.XXX:XXXX 32 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(OK) [BBC] Wesley Snipes
5 XXX.XXX.XXX.XXX:XXXX 31 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(OK) Pierre
6 XXX.XXX.XXX.XXX:XXXX 46 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(OK) bertrand
7 XXX.XXX.XXX.XXX:XXXX -1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(OK) SIGGI (Lobby)
8 XXX.XXX.XXX.XXX:XXXX 47 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(OK) Min (Lobby)
9 XXX.XXX.XXX.XXX:XXXX 32 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(OK) Frostpwnz
10 XXX.XXX.XXX.XXX:XXXX 31 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(OK) Zulu BASSA (Lobby)
11 XXX.XXX.XXX.XXX:XXXX 31 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(OK) Zardock (Lobby)
14 XXX.XXX.XXX.XXX:XXXX 63 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(OK) plbmas
(13 players in total)
I need to figure out how to display this information in a grid, with the column headers that are shown as well.
Thanks in advance 🙂
You will need to convert the text into a data structure. Currently it is all text, so it will be displayed in only one column.
I suggest, you split the data based on carriage returns, then for each player row (line 3 onwards), split the columns. The following is a rough code outline, edit as required.
Where
mygridviewis your grid.I have put it all into a data table, but custom objects, list etc would also work.