Salut tout le monde voila j'ai encore un petit probleme ^^
La fonction suivante me permet d'extraire l'index,le nom,les kill,les temps de connection de joueur d'un serveur.Sa marche bien en affichant une par une les infos avec des message box mais je n'arrive pas a les mettre dans un tableau pour les retourner ensuite :
J'ai essayer essayer avec ce type de code:Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 Function ParsePlayer(ByVal receivedata() As Byte) Dim index As Integer = 6 Dim phase As Integer = 1 Dim decoder As New ASCIIEncoding Dim TimesBytes(3) As Byte Dim PlayerInfo(64) As Integer Dim PlayerInfoIndex As Integer = 0 Try For index = 6 To receivedata.Length - 1 If phase = 1 Then MessageBox.Show(Convert.ToInt32(receivedata(index))) phase = 2 index = index + 1 End If If phase = 2 Then MessageBox.Show(decoder.GetString(receivedata, index, getNextIndex(receivedata, index) - index)) phase = 3 index = index + getNextIndex(receivedata, index) - index End If If phase = 3 Then MessageBox.Show(Convert.ToUInt32(receivedata(index))) phase = 4 index = index + 1 End If If phase = 4 Then Array.Copy(receivedata, index + 3, TimesBytes, 0, 4) Dim times As New TimeSpan(0, 0, BitConverter.ToSingle(TimesBytes, 0)) MessageBox.Show(times.Hours & "h " & times.Minutes & "min " & times.Seconds & "sec") phase = 1 index = index + 6 End If Next Catch ex As Exception MessageBox.Show(ex.Message) End Try Return Nothing End Function
Mais sa ne marche pas et maffiche un message d'erreur "index was outside of bound array".Code:
1
2
3
4
5
6
7
8
9 dim playerinfo(64) as string dim playerinfoindex as integer = 0 If phase = 1 Then playerinfo(playerinfoindex) = Convert.ToInt32(receivedata(index)) playerinfoindex += 1 phase = 2 index = index + 1 End If
Merci @+