Author Topic: How can i get server info...  (Read 7923 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)