Jump to content


Photo

Ace of Spades Server Selector (Updated June 1, 2013)


  • Please log in to reply
65 replies to this topic

#1 Uberi

Uberi
  • Fellows
  • 1062 posts

Posted 13 October 2011 - 01:57 AM

A server selection dialog for Ace of Spades, an independent sandbox building/FPS game.

Ace of Spades has an online server selection page, but I've always found it less usable than a dedicated launcher and server browser. This script is meant as a complete replacement for the server selection webpage.

 

Why should I use this?

  • Automatic joining: if the server is currently full, the launcher offers to keep trying to join until successful. You can also retry joining a server if the connection fails.
  • Better ping: ping from your own machine to get the best possible idea of how well your connection will perform.
  • Username changing: change your username right from the bottom bar!
  • Better availability: server listings are sourced from three different places, so if one goes down, you won't even notice.
  • Map and server name while playing: if you play in windowed mode, the name of the server and the current map will be shown in the title bar, just in case you need that information.
  • Fast browsing with hotkeys: press Alt + R to refresh, Enter to join, Up or Down to move up or down, or start typing to select a server by name.
  • Connect to an IP or localhost easily: any IP address, even your own machine!
  • Fast and light: start playing in seconds!

What are the latest changes?

  • Window minimum size updated.

  • Status indicator for retrieving server lists.

  • More reasonable timeouts for list retrieval so the program doesn't freeze while updating.

What does it look like?

Ace%20of%20Spades%20Server%20Selector.pn

Where do I get this?

 

Use this one if you have AutoHotkey installed:
Script

 

Use this one if you do not have or want to install AutoHotkey:

EXE (Uncompressed)



#2 zzzooo10

zzzooo10
  • Members
  • 236 posts

Posted 13 October 2011 - 02:39 AM

Interesting game, I'll have to check it out.
Your not the only one who wrote a server manager in ahk, and you might want to add yours here.

#3 tidbit

tidbit
  • Moderators
  • 2324 posts

Posted 13 October 2011 - 02:40 AM

Well, that wasn't on your todo list very long.... Great!

here is an idea:
also show the current AOS version number on the website.

#4 nimda

nimda
  • Members
  • 4307 posts

Posted 13 October 2011 - 03:02 AM

With a quick change, this works with AOS Portable too! :)
Now I can remove my hotkey which sent a rightclick, arrow keys, and ran aos with the clipboard :p

#5 Uberi

Uberi
  • Fellows
  • 1062 posts

Posted 13 October 2011 - 11:22 PM

you might want to add yours here.


Done!

also show the current AOS version number on the website.


Done!

Redownload to see the changes.

#6 nimda

nimda
  • Members
  • 4307 posts

Posted 16 November 2011 - 12:09 AM

Broken as of 0.70! Needs an update :wink:

#7 Uberi

Uberi
  • Fellows
  • 1062 posts

Posted 16 November 2011 - 02:53 AM

Fixed (small RegEx tweak) :).

Redownload to get the changes.

#8 nimda

nimda
  • Members
  • 4307 posts

Posted 26 November 2011 - 05:33 PM

figured I'd share:
SetTitleMatchMode RegEx
Loop
{
 run aos://NNNNNNNNN ; replace with server's address
 WinWait ^(ERROR|Ace of Spades)$
 WinGetTitle, T
 If T = ERROR
  WinClose
 Else ExitApp
}
Useful for joining full servers.

#9 Uberi

Uberi
  • Fellows
  • 1062 posts

Posted 26 November 2011 - 08:23 PM

Update:

[*:2kar3p9e]Error dialog boxes are recognized and properly handled.
[*:2kar3p9e]Retrying connections if they fail.
[*:2kar3p9e]Error checking improved.
Thanks for the connection retrying idea, nimda!

#10 nimda

nimda
  • Members
  • 4307 posts

Posted 26 November 2011 - 11:39 PM

You're welcome and thanks for the update, Uberi! :)

It had gotten to the point where I would position the selection dialog so that I could click the server and the OK on the ERROR box without moving the mouse :O
Then I realized AHK could do it faster and even in the background :)
Now with it built in, I don't even need to type in the address each time :D

Can't wait to try it out ;)

#11 nimda

nimda
  • Members
  • 4307 posts

Posted 27 November 2011 - 04:42 PM

WAIT! There's no "auto-connect" option :(
I tried with something like this
#NoEnv

URL := "http://ace-spades.com/play/"

SetTitleMatchMode, RegEx

Gui, Font, s16 Bold, Arial
Gui, Add, Text, x10 y0 h30 vTitle Center, Server List
Gui, Font, s8 Norm
Gui, Add, ListView, x10 y30 vServerList gSelectServer, Name|Players|Ping|Address
Gui, Font, Bold
Gui, Add, Text, x10 w80 h20 vServerCount
Gui, Add, Button, w80 h20 vRefreshList gRefreshList Default, Refresh
Gui, +Resize +MinSize200x150

Gosub, RefreshList
Gosub, GuiSize

Gui, Show, w490 h350
Return

GuiEscape:
GuiClose:
ExitApp

GuiSize:
GuiControl, Move, Title, % "w" . (A_GuiWidth - 20)
GuiControl, Move, ServerList, % "w" . (A_GuiWidth - 20) . " h" . (A_GuiHeight - 70)
GuiControl, Move, ServerCount, % "y" . (A_GuiHeight - 30)
GuiControl, Move, RefreshList, % "x" . (A_GuiWidth - 90) . " y" . (A_GuiHeight - 30)
WinSet, Redraw
Return

SelectServer:
If (A_GuiEvent != "DoubleClick")
 Return
Row := LV_GetNext()
LV_GetText(Address,Row,4) ;retrieve the address from the fourth column of the selected row
Gui, Hide

Run %A_ScriptDir%\AoS.ahk

Loop
{
 ;open Ace of Spades
 Run, %Address%,, UseErrorLevel
 If ErrorLevel
  MsgBox, 16, Error, Could not open address "%Address%".
 WinWait, Ace of Spades|ERROR ahk_class Ace of Spades|#32770

 ;check for connection errors
 WinGetClass, WindowClass
 If (WindowClass != "Ace of Spades") ;error dialogue
 {
  WinClose
  LV_GetText(ServerName,Row,1) ;retrieve the server name from the first column of the selected row
[color=red]  MsgBox, 26,, Could not connect to "%ServerName%": server is full or misconfigured.`nPress 'Continue' to auto-join.[/color]
  IfMsgBox, Cancel
   Break
  [color=red]IfMsgBox, Continue
  {
   Loop
   {
    Run %Address%
    WinWait, Ace of Spades|ERROR ahk_class Ace of Spades|#32770,, 3
    WinGetTitle, T
    If T = ERROR
     WinClose
    Else break 2
   }[/color]
  }
 }
 Else If !ErrorLevel ;operation did not time out
  WinWaitClose
}

Gui, Show
Return

RefreshList:
;request the server selection page
Try
{
 WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
 WebRequest.Open("GET",URL) ;open request
 WebRequest.Send() ;send request
 ServerPage := WebRequest.ResponseText ;retrieve response
 WebRequest := "" ;free request
}
Catch Error
{
 WebRequest := "" ;free request
 If (Error.Extra = "Send")
  MsgBox, 16, Error, Could not request server list.
 Else If (Error.Extra = "ResponseText")
  MsgBox, 16, Error, Could not retrieve server list.
 ServerPage := ""
}

RegExMatch(ServerPage,"iS)<div\b[^<]*<a\b[^>]*>[^<]*?([\d\.]+)",Output), Version := (Output1 = "") ? "Unknown Version" : ("Version " . Output1) ;find the current version

;retrieve the server list
ServerPage := SubStr(ServerPage,InStr(ServerPage,"<pre>") + 5) ;remove everything before the server list
ServerPage := SubStr(ServerPage,1,InStr(ServerPage,"</pre>") - 1) ;remove everything after the server list
StringReplace, ServerPage, ServerPage, `r,, All ;remove carriage returns
ServerPage := Trim(ServerPage,"`n") ;trim off leading and trailing newlines
ServerPage := SubStr(ServerPage,InStr(ServerPage,"`n") + 1) ;remove the header row

GuiControl, -Redraw, ServerList ;prevent redrawing of the ListView

LV_Delete() ;remove all listview entries

;populate the ListView
Loop, Parse, ServerPage, `n
{
 RegExMatch(A_LoopField,"S)\s*(\d+\s*/\s*\d+)\s*(\d+)\s*[^>]*>\s*[^""]*""([^""]+)[^>]*>([^<]+)",Output)
 LV_Add("Auto",Output4,Output1,Output2,Output3)
}

;adjust column widths to suit their headers and contents
LV_ModifyCol(1,"AutoHdr")
LV_ModifyCol(2,"AutoHdr Integer")
LV_ModifyCol(3,"AutoHdr Integer")
LV_ModifyCol(4,"AutoHdr")

GuiControl, +Redraw, ServerList ;allow the ListView to be redrawn

GuiControl,, ServerCount, % LV_GetCount() . " servers." ;update the server count
Gui, Show,, Ace of Spades (%Version%) Servers
Return
But for some reason the script hits the MsgBox line and there's no MsgBox...

053: if (WindowClass != "Ace of Spades")
055: WinClose (0.13)
056: LV_GetText(ServerName,Row,1)
057: MsgBox,26,,Could not connect to "%ServerName%": server is full or misconfigured.
Press 'Continue' to auto-join. (18.33)

Press [F5] to refresh.


Could you please add an Auto-join option?

#12 Uberi

Uberi
  • Fellows
  • 1062 posts

Posted 27 November 2011 - 05:26 PM

Done.

#13 nimda

nimda
  • Members
  • 4307 posts

Posted 27 November 2011 - 06:00 PM

Thanks :D

#14 gamax92lazy

gamax92lazy
  • Guests

Posted 29 November 2011 - 05:49 AM

This is pretty nice. works just like it says and i can actually sort the servers by players connected!

#15 Strelok

Strelok
  • Guests

Posted 03 December 2011 - 07:41 PM

Okay, I'm new to this, how do I download this?