|
-
Nov 29th, 2001, 08:50 AM
#1
Thread Starter
New Member
How do i get this to make sense ?
Ive made a little app that contacts a CounterStrike server and requests some info, the problem is that i can´t get it to make any sense....
what i do is to send 4 consecutive bytes of 255 (32-bit integer -1) and then the string command followed by a zero byte to terminate it
( winsock1.SendData( chr(255) & chr(255) & chr(255) & chr(255) & "info" & chr(0) ) )
and the result i should get back is as folows:
Server responds with the following packet:
(int32) -1
(byte) ASCII 'C' (info response, S2A_INFO)
(string) net address of server
(string) name of the host / server
(string) name of the map
(string) game directory (i.e. valve/)
(string) Game description (e.g. "half-life multiplay")
(byte) active client count
(byte) maximum clients allowed
(byte) protocol version (currently 7)
but all i get now is "???????????5??????7???E??????e -" so i need help on how to get this to make sense... as you can see the response is both strings and byte data...
i would really appriciate the help...
-
Nov 29th, 2001, 11:07 PM
#2
Good Ol' Platypus
For bytes, parse the string at the specified location using Asc(Mid(Response,#,1)). This will give you integer values. For Strings I believe you parse until you get a Chr(0). Although it appears you aren't getting the correct information back.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Nov 30th, 2001, 04:37 AM
#3
Thread Starter
New Member
Thanx for the tip, the reply i get now is bad because i get it as a string...
-
Nov 30th, 2001, 08:33 AM
#4
Good Ol' Platypus
Looking at your list you could go through it like this:
VB Code:
Function ValString(Response As String)
Dim BL As Byte
Dim Q As String
BL = Asc(Mid(Response, 1, 1))
If BL <> 255 Then Exit Function
BL = Asc(Mid(Response, 2, 1))
If BL <> Asc("C") Then Exit Function
... etc.
That's how you would do bytes. For strings, start where they would be and look until you find a Chr(0). Then, read all data from the start point to the Chr(0) and take away the Chr(0). This is a null character and you won't need it.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Nov 30th, 2001, 09:22 AM
#5
Thread Starter
New Member
uhhhh
didn´t get that... i´m kind of a nebie... what´s the purpose?
well here´s the return i get when running this code:
For i = 1 To Len(strdata)
strdata2 = strdata2 & Asc(Mid(strdata, i, 1))
Next
resullt:
2552552552556749575146495146504855465158505548495308410611711410111009911595555255067838482737569067 11111711011610111483116114105107101003245
now i just need to get the values of everything....
that should contain an ip, an server port, server name... well everything in the list of my first post....
how do i get the string useful ?
-
Nov 30th, 2001, 10:00 AM
#6
Your data seems to be correct. To get it inot a usable form, you have to know the sizes of each data type:
Code:
int32 : 4 bytes
byte : 1 byte
string: Series of 1 or 2 bytes, terminated by 0
If I am not mistaken, "49 57 51 46 49 51 46 5" is the net address of the server. The problem with VB is that it uses Unicdoe strings, which are 2 bytes for each character, instead of 1. You have to write a function that parses through the result string, and turns it into the data type you want. I dont know if HL uses unicode, but i imagine it would. You got all of those question marks because the string couldnt display a valid character. Do what Sas, Said, but as you parse, keep track of what section of the data you should be in (net addr, hostname, etc). Then just fill out the correct variables with the bytes as you parse.
Z.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|