Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

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


  • Please log in to reply
71 replies to this topic
Uberi
  • Moderators
  • 1119 posts
  • Last active: May 02 2015 06:05 PM
  • Joined: 23 Aug 2010

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


If you already have AutoHotkey installed, here are the steps:

[*:3f99eewm]Save the script in the "AutoHotkey.net" link (in the Download section) as "SomeFile.ahk". Ensure it has a .ahk extension, instead of something like "SomeFile.ahk.txt".
[*:3f99eewm]Run the script by opening the .ahk file.
If you do not have AutoHotkey installed, I recommend you download and install it here.

gamax92
  • Members
  • 411 posts
  • Last active: Aug 06 2013 05:00 AM
  • Joined: 05 Dec 2010
Could you seperate the players/max players into two coloums?
And put a button/entry for localhost connection?

Oh and i wanted to drop this code off:
AoS2IP(ip)
{
 ; Chop off the aos:// and convert the reversed decimal IP to a standard 4-dot IP
 ip := RegExReplace(ip, "^.{6}")
 ip := (ip&0xFF) "." ((ip&0xFF00)>>8) "." ((ip&0xFF0000)>>16) "." ((ip&0xFF000000)>>24)
 return ip
}

It turns aos addresses into ip addresses.

Uberi
  • Moderators
  • 1119 posts
  • Last active: May 02 2015 06:05 PM
  • Joined: 23 Aug 2010
Update:

[*:30n9hpxp]Players and server capacity split into two columns.
[*:30n9hpxp]Button added for localhost connection.
[*:30n9hpxp]IP address column (I was unaware of that, thanks gamax92!)
[*:30n9hpxp]Refreshing the list maintains the sort order.

gamax92
  • Members
  • 411 posts
  • Last active: Aug 06 2013 05:00 AM
  • Joined: 05 Dec 2010
<!-- m -->http://aos.mp2.dk/<!-- m -->

pyspades lead me to this server page. You could try using it as a backup or an alternative. For me that page loads faster.

Uberi
  • Moderators
  • 1119 posts
  • Last active: May 02 2015 06:05 PM
  • Joined: 23 Aug 2010
Update:

[*:1l4vjxbo]Current server name is now shown in the window title.
[*:1l4vjxbo]Fixed window and control sizing issue.

Uberi
  • Moderators
  • 1119 posts
  • Last active: May 02 2015 06:05 PM
  • Joined: 23 Aug 2010
Update:

[*:3dok2t2r]Enter key now connects to the currently selected server.
[*:3dok2t2r]Fixed a resizing issue in which refreshing the server list would trigger the GuiSize routine.

Uberi
  • Moderators
  • 1119 posts
  • Last active: May 02 2015 06:05 PM
  • Joined: 23 Aug 2010
Update:

The last update had a bug in which server selection was triggered on any ListView event. This has now been fixed.

Edit: also AutoJoin could not be stopped by using a hotkey. This is now fixed.

##
  • Members
  • 1 posts
  • Last active: Jan 30 2012 02:56 PM
  • Joined: 30 Jan 2012

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


Sorry for the late bump, but you have an AoS portable? I can't seem to find one anywhere. Would you mind pointing me in the direction?

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
Ace of Spades is portable except for the registry-write required to make the aos:// protocol work. So just take the whole AoS folder + the OP script, and change
Run, %Server%,, UseErrorLevel
to
Run, "%A_ScriptDir%\client.exe" %Server%,, UseErrorLevel
Then put the OP script in the AoS folder.
I can upload my folder as a .zip later if you want, but it's just a one-line change

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
Bump. As of 0.75 the address field is broken.

infogulch
  • Moderators
  • 717 posts
  • Last active: Jul 31 2014 08:27 PM
  • Joined: 27 Mar 2008
nimda, this:
Run, "%A_ScriptDir%\client.exe" %Server%,, UseErrorLevel

Needs to be changed to:
Run, "%A_ScriptDir%\client.exe" [color=red]"[/color]%Server%[color=red]"[/color],, UseErrorLevel

The address (<!-- m -->aos://*<!-- m -->) needs to be quoted on the command line, otherwise client.exe doesn't recognize it.

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
Actually, that part works fine for me. I was referring to the address field of the listview.

infogulch
  • Moderators
  • 717 posts
  • Last active: Jul 31 2014 08:27 PM
  • Joined: 27 Mar 2008
AoS just updated to version 7.5, so maybe something changed. http://www.ace-spade...-beta-0-75-now/

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
I know.

Bump. As of 0.75 the address field is broken.



infogulch
  • Moderators
  • 717 posts
  • Last active: Jul 31 2014 08:27 PM
  • Joined: 27 Mar 2008
Fixed. Apparently as of 0.75, the aos:// link includes the port. I adjusted for it, and added port column. I also fixed the insane one-space indentation.

Btw, this is for a portable installation (put it in your aos dir). Also, I use ahk_l, I'm not sure if it still works on basic.
#NoEnv
#SingleInstance, Force

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

SetTitleMatchMode, RegEx

AutoJoin := 0

Gui, Font, s16 Bold, Arial
Gui, Add, Text, x10 y0 h30 vTitle Center, Server List
Gui, Font, s8 Norm
SortColumns := [1,0,0,0,0,0]
Gui, Add, ListView, x10 y30 vServerList gListViewEvent, Index|Name|Players|Capacity|Ping|Server|Address|Port
Gui, Font, Bold
Gui, Add, Text, x10 w80 h20 vServerCount
Gui, Add, Button, w80 h20 vLocalServer gLocalServer, &Local Server
Gui, Add, Button, w80 h20 vRefreshList gRefreshList Default, &Refresh
Gui, +Resize +MinSize270x150

Gosub, RefreshList

Gui, Show, Center w600 h450
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, LocalServer, % "x" . (A_GuiWidth - 180) . " y" . (A_GuiHeight - 30)
GuiControl, Move, RefreshList, % "x" . (A_GuiWidth - 90) . " y" . (A_GuiHeight - 30)
WinSet, Redraw
Return

LocalServer:
Gui, Hide
Server := "aos://16777343:32887"
Name := "Local Server"
JoinServer(Server,Name)
Gui, Show
Return

ListViewEvent:
If (A_GuiEvent = "ColClick")
    Gosub, SortColumns
If (A_GuiEvent != "DoubleClick")
    Return
Gosub, SelectServer
Return

SelectServer:
Row := LV_GetNext()
LV_GetText(Server,Row,6) ;retrieve the server from the fourth column of the selected row
LV_GetText(Name,Row,2) ;retrieve the server name from the first column of the selected row
Gui, Hide
JoinServer(Server,Name)
Gui, Show
Return

SortColumns:
If SortColumns[A_EventInfo]
    SortColumns[A_EventInfo] := (SortColumns[A_EventInfo] & 1) + 1 ;toggle sorting types between ascending and descending
Else
    SortColumns[A_EventInfo] := (A_EventInfo = 3 || A_EventInfo = 4) ? 2 : 1 ;enable sorting for the column

For Index In SortColumns ;disable sorting on all other columns
{
    If (Index != A_EventInfo)
        SortColumns[Index] := 0
}
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)
    RegExMatch(Output4, "aos\:\/\/(?<server>\d+)(?:\:(?<port>\d+))", output)
    Server := outputserver
    Port := outputport
    Address := (Server & 0xFF) . "." . ((Server & 0xFF00) >> 8) . "." . ((Server & 0xFF0000) >> 16) . "." . ((Server & 0xFF000000) >> 24)
    LV_Add("",A_Index,Output5,Output1,Output2,Output3,Output4,Address,Port)
}

;adjust column widths to suit their headers and contents
LV_ModifyCol(1,"AutoHdr Integer") ;index
LV_ModifyCol(2,"AutoHdr") ;server name
LV_ModifyCol(3,"AutoHdr Integer Desc") ;players
LV_ModifyCol(4,"AutoHdr Integer Desc") ;capacity
LV_ModifyCol(5,"AutoHdr Integer") ;ping
LV_ModifyCol(6,"AutoHdr") ;server
LV_ModifyCol(7,"AutoHdr") ;address

For Index, Value In SortColumns
{
    If Value
    {
        LV_ModifyCol(Index,"Sort" . ((Value = 1) ? "" : "Desc"))
        Break
    }
}

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

JoinServer(Server,Name = "")
{
    global AutoJoin
    Loop
    {
        ;open Ace of Spades
        run, "%A_ScriptDir%\client.exe" "%Server%", %A_ScriptDir%, UseErrorLevel
        If ErrorLevel
        {
            MsgBox, 16, Error, Could not open server "%Server%".
            Return, 1
        }
        WinWait, Ace of Spades|ERROR ahk_class Ace of Spades|#32770,, 5
        
        ;check for connection errors
        WinGetClass, WindowClass
        If (WindowClass != "Ace of Spades") ;error dialogue
        {
            WinClose
            If !AutoJoin
            {
                MsgBox, 22, Error, Could not connect to "%Name%": server is full or misconfigured.`n`nSelect "Try Again" to retry the connection`, or "Continue" to automaticially join.
                IfMsgBox, Cancel
                {
                    Gosub, StopAutoJoin
                    Break
                }
                IfMsgBox, Continue
                {
                    AutoJoin := 1
                    ToolTip, Press Esc to stop automatic retrying.
                    Hotkey, Esc, StopAutoJoin, On
                }
            }
        }
        Else
        {
            Gosub, StopAutoJoin
            If ErrorLevel ;window wait operation timed out
                Return, 1
            WinSetTitle, Ace of Spades ahk_class Ace of Spades,, Ace of Spades - %Name%
            WinWaitClose
            Break
        }
    }
    Return, 0
    
    StopAutoJoin:
    AutoJoin := 0
    ToolTip
    Hotkey, Esc, StopAutoJoin, Off
    Return
}

#If ListViewFocused()

ListViewFocused()
{
    GuiControlGet, CurrentFocus, FocusV
    Return, CurrentFocus = "ServerList" && LV_GetNext()
}

Enter::Gosub, SelectServer

#If