Author Topic: How can i get server info...  (Read 7926 times)

0 Members and 1 Guest are viewing this topic.

Offline xmRipper

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 742
    • Personal
How can i get server info...
« on: March 17, 2007, 12:42:43 pm »
How can I get server information by using only IP and port? I think it is related with ASE port.

Ex: game-monitor.com, servers.teracities.com...

But I will use Visual Basic 6
Co-Founder / CTO @ Macellan
Founder Turkish Soldat Community

Offline FliesLikeABrick

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 6144
    • Ultimate 13 Soldat
Re: How can i get server info...
« Reply #1 on: March 17, 2007, 01:09:52 pm »
Yeah it is using the ASE port.  It would be nice if some of the coders here helped put together a thread like this one for the REFRESH packet: http://forums.soldat.pl/index.php?topic=212.0


Does anyone have a code snippet that they'd like to share which parses ASE data and/or shows how to connect and retrieve that data?   

Offline xmRipper

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 742
    • Personal
Re: How can i get server info...
« Reply #2 on: March 17, 2007, 01:19:05 pm »
I know refresh packet but I don't know connecting and retrieving info By using ASE data     
Co-Founder / CTO @ Macellan
Founder Turkish Soldat Community

Offline FliesLikeABrick

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 6144
    • Ultimate 13 Soldat
Re: How can i get server info...
« Reply #3 on: March 17, 2007, 01:44:37 pm »
I know refresh packet but I don't know connecting and retrieving info By using ASE data     

yeah, I was just using that as an example of how it'd be nice to have a list of code snippets

Offline chrisgbk

  • Inactive Staff
  • Veteran
  • *****
  • Posts: 1739
Re: How can i get server info...
« Reply #4 on: March 17, 2007, 03:34:51 pm »
I know refresh packet but I don't know connecting and retrieving info By using ASE data     

yeah, I was just using that as an example of how it'd be nice to have a list of code snippets

Don't have a code snippet, but I have a link to the packet structure: http://www.int64.org/docs/gamestat-protocols/ase.html. I might make some samples later.

Offline Frenchie

  • Camper
  • ***
  • Posts: 358
  • SoldatHQ
Re: How can i get server info...
« Reply #5 on: March 17, 2007, 03:40:07 pm »
I remember I posted a snippet I had, it was attached as a txt file.
I can't find it/don't know where it is.. I know mikembm had found it.

But it had unused functions and such, so it isn't too useful to many.

I'll see if I can post a much cleaned up version of it.
Soldat Lobby Avec Players -New Release! - Updated AGAIN!


Offline Blue-ninja

  • Veteran
  • *****
  • Posts: 1419
Re: How can i get server info...
« Reply #6 on: March 17, 2007, 04:02:06 pm »
If you're working inside the server, it could probably help to type /info to get information on the server, I think.

Offline FliesLikeABrick

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 6144
    • Ultimate 13 Soldat
Re: How can i get server info...
« Reply #7 on: March 17, 2007, 04:06:29 pm »
If you're working inside the server, it could probably help to type /info to get information on the server, I think.

he's looking for a way to get the information without being in the game and without having the admin password.

Offline Blue-ninja

  • Veteran
  • *****
  • Posts: 1419
Re: How can i get server info...
« Reply #8 on: March 17, 2007, 04:08:47 pm »
Oh. Just trying to help. =\

Offline xmRipper

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 742
    • Personal
Re: How can i get server info...
« Reply #9 on: March 17, 2007, 06:53:28 pm »
I might make some samples later.

please..
Co-Founder / CTO @ Macellan
Founder Turkish Soldat Community

Offline chrisgbk

  • Inactive Staff
  • Veteran
  • *****
  • Posts: 1739
Re: How can i get server info...
« Reply #10 on: March 17, 2007, 11:17:19 pm »
Code: [Select]
Private Type ASEPlayer
    Name As String
    Team As String
    Skin As String
    Score As String
    Ping As String
    TimePlayed As String
End Type

Private Type ASERule
    Name As String
    Value As String
End Type

Private Function parseASEHeader(packet() As Byte, ByRef offset As Integer) As String
    parseASEHeader = Chr(packet(offset)) + Chr(packet(offset + 1)) + Chr(packet(offset + 2)) + Chr(packet(offset + 3))
    offset = offset + 4
End Function

Private Function parseASEString(packet() As Byte, ByRef offset As Integer) As String
    Dim length As Integer
    Dim i As Integer
    length = packet(offset) - 1
    offset = offset + 1
    For i = offset To offset + length - 1
        parseASEString = parseASEString + Chr(packet(i))
    Next i
    offset = offset + length
End Function

Private Function parseASERule(packet() As Byte, ByRef offset As Integer) As ASERule
    parseASERule.Name = parseASEString(packet, offset)
    parseASERule.Value = parseASEString(packet, offset)
End Function

Private Function parseASEPlayer(packet() As Byte, ByRef offset As Integer) As ASEPlayer
    Dim flags As Byte
    Dim i As Integer
    i = offset
    flags = packet(i)
    i = i + 1
    If (flags And 1) > 0 Then parseASEPlayer.Name = parseASEString(packet, i)
    If (flags And 2) > 0 Then parseASEPlayer.Team = parseASEString(packet, i)
    If (flags And 4) > 0 Then parseASEPlayer.Skin = parseASEString(packet, i)
    If (flags And 8) > 0 Then parseASEPlayer.Score = parseASEString(packet, i)
    If (flags And 16) > 0 Then parseASEPlayer.Ping = parseASEString(packet, i)
    If (flags And 32) > 0 Then parseASEPlayer.TimePlayed = parseASEString(packet, i)
End Function

Private Sub parseASEPacket(packet() As Byte, Optional offset As Integer = 0)
    Dim header As String
    Dim GameName As String
    Dim PortNumber As String
    Dim ServerName As String
    Dim GameType As String
    Dim MapName As String
    Dim Version As String
    Dim Passworded As String
    Dim NumPlayers As String
    Dim MaxPlayers As String
    Dim Rule As ASERule
    Dim Player As ASEPlayer
    Dim i As Integer
   
    i = offset
    header = parseASEHeader(packet, i)
    If header <> "EYE1" Then Exit Sub
    GameName = parseASEString(packet, i)
    PortNumber = parseASEString(packet, i)
    ServerName = parseASEString(packet, i)
    GameType = parseASEString(packet, i)
    MapName = parseASEString(packet, i)
    Version = parseASEString(packet, i)
    Passworded = parseASEString(packet, i)
    NumPlayers = parseASEString(packet, i)
    MaxPlayers = parseASEString(packet, i)
    Do
        Rule = parseASERule(packet, i)
    Loop Until Rule.Name <> ""
    Dim PlayerCount As Integer
    Do
        Player = parseASEPlayer(packet, i)
        PlayerCount = PlayerCount + 1
    Loop Until PlayerCount = CInt(MaxPlayers)
End Sub

This won't show you how to connect to a server and send a query(to query, just connect to the ASE port and send a lowercase S), nor how to recieve the output (those topics are covered on various internet tutorial sites); it will however show you how to parse the output as it comes back to you. I don't guarantee that this is bugfree, nor that it will work as intended as it's mostly untested, but you should get the general idea; it is afterall a simple protocol.

Basically, what you have to do at this point is read up on how winsock works, connect to the ASE port of the desired server, send a lower case S, recieve the data back into an array of bytes, and run it through parseASEPacket (after you modify it to actually do something with the data that is; as it is the data is just discarded in this sub).
« Last Edit: March 17, 2007, 11:20:53 pm by chrisgbk »

Offline xmRipper

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 742
    • Personal
Re: How can i get server info...
« Reply #11 on: March 18, 2007, 03:31:32 pm »
i cant connect to the ASE port of any server :/
« Last Edit: March 18, 2007, 04:00:14 pm by xmRipper »
Co-Founder / CTO @ Macellan
Founder Turkish Soldat Community

Offline chrisgbk

  • Inactive Staff
  • Veteran
  • *****
  • Posts: 1739
Re: How can i get server info...
« Reply #12 on: March 18, 2007, 06:01:51 pm »
i cant connect to the ASE port of any server :/

Servers need to have the port forwarded to be able to connect to it, so it won't work with every server. Check with a server that supports it, ie, those listed on Frenchie's ASE Lobby.

Offline FliesLikeABrick

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 6144
    • Ultimate 13 Soldat
Re: How can i get server info...
« Reply #13 on: March 18, 2007, 07:51:22 pm »
Any server hosted on U13.net will support this if you want to try it.  Any soldat server on game-monitor will also support it

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: How can i get server info...
« Reply #14 on: March 18, 2007, 08:12:05 pm »
i cant connect to the ASE port of any server :/
Ofcourse you can't. No one can.

Because ASE uses the UDP Protocol. Which is connectionless. Not TCP.

Offline chrisgbk

  • Inactive Staff
  • Veteran
  • *****
  • Posts: 1739
Re: How can i get server info...
« Reply #15 on: March 18, 2007, 10:01:42 pm »
i cant connect to the ASE port of any server :/
Ofcourse you can't. No one can.

Because ASE uses the UDP Protocol. Which is connectionless. Not TCP.

I guess it is a bit of a misnomer to say "connect".

Offline xmRipper

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 742
    • Personal
Re: How can i get server info...
« Reply #16 on: March 19, 2007, 12:15:00 pm »
Okay, thanks for everything.  I've connected.  chrisgbk, how can I use the codes you gave? Can you help me? The data I receive is this;

Code: [Select]
EYE1soldat23073xmRipper ServerCapture the Flag ctf_Death21.3.1005
Respawn Time5 SecsBonus Frequency Very Few SurvivalNo
RealisticNoSystemWindows
Time Left
4:49 Minutes Time Limit
5 Minutes Next Map
ctf_Kampf
ProtectedNo
Co-Founder / CTO @ Macellan
Founder Turkish Soldat Community

Offline chrisgbk

  • Inactive Staff
  • Veteran
  • *****
  • Posts: 1739
Re: How can i get server info...
« Reply #17 on: March 19, 2007, 12:48:30 pm »
Okay, thanks for everything.  I've connected.  chrisgbk, how can I use the codes you gave? Can you help me? The data I receive is this;

Code: [Select]
EYE1soldat23073xmRipper ServerCapture the Flag ctf_Death21.3.1005
Respawn Time5 SecsBonus Frequency Very Few SurvivalNo
RealisticNoSystemWindows
Time Left
4:49 Minutes Time Limit
5 Minutes Next Map
ctf_Kampf
ProtectedNo

Recieve the data into an array of bytes as opposed to a string, then pass that array into parseASEPacket. You simply need to modify that procedure to actually do something with the data it parses. (currently, it reads it, then discards it)

Offline xmRipper

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 742
    • Personal
Re: How can i get server info...
« Reply #18 on: March 19, 2007, 02:16:30 pm »
Please can you explain that how can I pass that array into parseASEPacket? :)
I will be glad if you give a fragment of a code. I am a beginner at Visual Basic. I need help.
Co-Founder / CTO @ Macellan
Founder Turkish Soldat Community

Offline FliesLikeABrick

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 6144
    • Ultimate 13 Soldat
Re: How can i get server info...
« Reply #19 on: March 19, 2007, 02:45:29 pm »
I'm pretty sure you just call it as a function parseASEPacket(that array)

Offline xmRipper

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 742
    • Personal
Re: How can i get server info...
« Reply #20 on: March 21, 2007, 10:33:05 am »
Code: [Select]
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
  Dim Buffer() As Byte
  Winsock1.GetData Buffer
  parseASEPacket Buffer
  Text2.Text = MapName
End Sub

what's wrong ::)
Co-Founder / CTO @ Macellan
Founder Turkish Soldat Community

Offline chrisgbk

  • Inactive Staff
  • Veteran
  • *****
  • Posts: 1739
Re: How can i get server info...
« Reply #21 on: March 21, 2007, 04:52:51 pm »
Code: [Select]
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
  Dim Buffer() As Byte
  Winsock1.GetData Buffer
  parseASEPacket Buffer
  Text2.Text = MapName
End Sub

what's wrong ::)

The code I provided has all the variables private to the function; to make them accessible outside the function you would need to make them global instead. Also, I highly recommend that any code you write in VB uses the Option Explicit directive, otherwise if you use a variable that doesn't exist VB creates it for you automatically; this has the effect of making your code run without errors, but not functioning the way you intend.

Offline FliesLikeABrick

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 6144
    • Ultimate 13 Soldat
Re: How can i get server info...
« Reply #22 on: March 25, 2007, 02:53:10 pm »
Can anyone post an ASE parser in PHP (if they already have one) ?

edit: I'm writing one now, I'll have it done in a few hours (I'm at work and its quite busy, so I'm not sure how long it'll actually take)
« Last Edit: March 25, 2007, 04:33:52 pm by FliesLikeABrick »

Offline chrisgbk

  • Inactive Staff
  • Veteran
  • *****
  • Posts: 1739
Re: How can i get server info...
« Reply #23 on: March 25, 2007, 05:53:11 pm »
Can anyone post an ASE parser in PHP (if they already have one) ?

edit: I'm writing one now, I'll have it done in a few hours (I'm at work and its quite busy, so I'm not sure how long it'll actually take)

You can use the one Frenchie used as the base of his ASE lobby which is available here: http://www.tuts.net/~titulaer/rcon-0.38.0.tar.gz
then modify it as I detail here: http://forums.soldat.pl/index.php?topic=2928.msg34131#msg34131
or here: http://forums.soldat.pl/index.php?topic=2928.msg34172#msg34172
(or go one step further and modify it to be generic and parse the flag byte and use the value of it to determine what to parse.

However, it's rather trivial to write your own, as it's a simple protocol; particularily when you have visual basic code to follow since VB is reasonably close to psuedo-code.

Also, a followup to xmRipper:

Code: [Select]
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
  Dim Buffer() As Byte
  ReDim Buffer(bytesTotal - 1)
  Winsock1.GetData Buffer
  parseASEPacket Buffer
End Sub

should work; I didn't notice the lack of ReDim when I last looked at it.
« Last Edit: March 25, 2007, 06:05:29 pm by chrisgbk »

Offline FliesLikeABrick

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 6144
    • Ultimate 13 Soldat
Re: How can i get server info...
« Reply #24 on: March 25, 2007, 09:54:08 pm »
I made another PHP one, I think it is more efficient a bit more featureful than Frenchie's.  It provides some "fixed" versions of things like time remaining, time limit, and other values (strips text so they're int-only and ready for use)
http://forums.soldat.pl/index.php?topic=12200
« Last Edit: March 25, 2007, 09:58:15 pm by FliesLikeABrick »