Sign in to follow this  
Followers 0
Jex

Team Fortress 2 Servers list array problem

1 post in this topic

#1 ·  Posted (edited)

My scripts using http://www.game-monitor.com that web site source codes for gather server informations.

If you change "$Var1 and $Var2" that variables you can use for other countries Example :

Global $Var1 = "TR", $Var2 = "Turkey"

Global $Var1 = "JP", $Var2 = "Japan"

Global $Var1 = "RU", $Var2 = "Russian Federation"

Global $Var1 = "DE", $Var2 = "Germany"

but if have +28 server creating problem.

Turkey have 3 servers and working without problem = http://img225.imageshack.us/img225/2848/steam2dp0.jpg

and Japan have 19 servers and again working without problem = http://img216.imageshack.us/my.php?image=steam1tt0.jpg

but rusian federation have 30 servers and in 29. server giving error = http://img225.imageshack.us/img225/3855/steam3za1.jpg

germany have 30 servers and in 30. server giving error = http://img529.imageshack.us/img529/3091/steam4pm0.jpg

Error is that =

(48) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$Result2 = _StringBetween($Search2[$i], ">", "</font>")

$Result2 = _StringBetween(^ ERROR

Maybe _StringBetween have bug ? Because i can't find what is problem. :)

Now giving another errors too.. anyway pass that question. <_<

My second question after press refresh button (Case $msg = $Refresh) program trying connect all servers with steam .

#include <INet.au3>
#include <String.au3>
#include <Array.au3>
#include <GUIConstants.au3>
#include <Color.au3>

Global $Button2, $Button3, $Data, $width = 602, $height = 70, $Index, $Button, $Server, $Title
Global $Close, $Minimize, $Clip, $Refresh, $MouseOver = 1, $First = True, $Input1, $Input2, $Input3, $Input4, $Input5
;Global $Var1 = "TR", $Var2 = "Turkey"
Global $Var1 = "JP", $Var2 = "Japan"
;Global $Var1 = "RU", $Var2 = "Russian Federation"
;Global $Var1 = "DE", $Var2 = "Germany"
Check()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $Close
            Exit
        Case $msg = $Minimize
            GUISetState(@SW_MINIMIZE)
        Case $msg = $Clip
            ClipPut($Data)
        Case $msg = $Refresh
            Check()
        Case Else
            For $i = 1 To $Index + 1
                If $msg = $Button[$i] Then msgbox("","","test for second problem");ShellExecute("steam://connect/" & $Server[$i])
            Next
    EndSelect
WEnd

Func Check()
    If $First = False Then GUICtrlSetData($Title, "Team Fortress 2 Servers list (Servers list refreshing... )")
    $Url = "http://www.game-monitor.com/search.php?game=tf2&country=" & $Var1
    $Source = _INetGetSource($Url)
    $Search = _StringBetween($Source, '</td><td><div class="pres"><a href="/search.php?game=tf2&country=' & $Var1 & '&country=' & $Var1 & '"><img src="/i/f/' & $Var1 & '.gif" width="20" title="' & $Var2 & '" /></a> <a href=', '</a></div></td></tr>')
    $Search2 = _StringBetween($Source, 'color="#', 'href="/MapSearch/')
    $Index = UBound($Search) - 1
    Global $Server[$Index + 2], $Input1[$Index + 2], $Input2[$Index + 2], $Input3[$Index + 2], $Input4[$Index + 2], $Input5[$Index + 2], $Button[$Index + 2], $Data = ""
    If $First = True Then
        Creategui()
        $First = False
    EndIf
    For $i = 0 To $Index
        msgbox("","",$i + 1 & " (for find problem)")
        $Result = StringSplit($Search[$i], ">")
        $Result2 = _StringBetween($Search2[$i], ">", "</font>")
        $Result3 = _StringBetween($Search2[$i], "</td><td></td><td>", "</td><td><a")
        If @error Then $Result3 = _StringBetween($Search2[$i], "</td><td>1</td><td>", "</td><td><a")
        If @error Then $Result3 = _StringBetween($Search2[$i], "</td><td>2</td><td>", "</td><td><a")
        $Result4 = StringSplit($Result3[0], " </td><td>", 1)
        If @error then $Result4 = StringSplit($Result3[0], ' <img src="http://images.game-monitor.com/v2/lock.gif" title="Private"></td><td>', 1)
        $Server[$i + 1] = $Result4[1] & ":" & $Result4[2]
        $Result5 = _StringBetween($Source, '/MapSearch/tf2/', '/">')
        $Write = $i + 1 & ". " & $Result[2] & "  -  " & $Result2[0] & "  -  " & $Server[$i + 1] & "  -  " & $Result5[$i]
        If $Data = "" Then
            $Data = $Write
        Else
            $Data = $Data & @CRLF & $Write
        EndIf
        GUICtrlSetData($Input1[$i + 1], $i + 1)
        GUICtrlSetData($Input2[$i + 1], $Result[2])
        GUICtrlSetData($Input3[$i + 1], $Result2[0])
        GUICtrlSetData($Input4[$i + 1], $Server[$i + 1])
        GUICtrlSetData($Input5[$i + 1], $Result5[$i])
    Next
    If $First = False Then GUICtrlSetData($Title, "Team Fortress 2 Servers list")
EndFunc   ;==>Refresh

Func Creategui()
    $Form = GUICreate("FLEXY", $width, $height + (20 * $Index + 1), -1, -1, $WS_POPUP)
    GUISetBkColor(0x464646)
    $Close = GUICtrlCreateLabel("x", $width - 15, 3, 11, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "Verdana")
    GUICtrlSetColor(-1, 0xffffff)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetCursor(-1, 0)
    GUICtrlSetTip(-1, "Close")
    $Minimize = GUICtrlCreateLabel("_", $width - 30, 1, 11, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "Verdana")
    GUICtrlSetColor(-1, 0xffffff)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetCursor(-1, 0)
    GUICtrlSetTip(-1, "Minimize")
    $Clip = GUICtrlCreateLabel("C", $width - 45, 7, 11, 20)
    GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
    GUICtrlSetColor(-1, 0xffffff)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetCursor(-1, 0)
    GUICtrlSetTip(-1, "Copy servers list to clipboard")
    $Refresh = GUICtrlCreateLabel("~", $width - 60, 7, 11, 20)
    GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
    GUICtrlSetColor(-1, 0xffffff)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetCursor(-1, 0)
    GUICtrlSetTip(-1, "Refresh servers list")
    $Title = GUICtrlCreateLabel("Team Fortress 2 Servers list", 10, 6, 1100, 20, -1, $GUI_WS_EX_PARENTDRAG)
    GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
    GUICtrlSetColor(-1, 0xffffff)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    $Graphic = GUICtrlCreateGraphic(0, 0, 1000, 25)
    GUICtrlSetBkColor(-1, 0x5A6A50)
    _GuiRoundCorners($Form, 0, 0, 5, 5)
    For $i = 1 To $Index + 1
        $Input1[$i] = GUICtrlCreateLabel("", 8, 20 + (20 * $i), 25, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY), 0)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        GUICtrlSetColor(-1, "0xFFFFFF")
        $Input2[$i] = GUICtrlCreateLabel("", 32, 20 + (20 * $i), 233, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY), 0)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        GUICtrlSetColor(-1, "0xFFFFFF")
        $Input3[$i] = GUICtrlCreateLabel("", 264, 20 + (20 * $i), 41, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY), 0)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        GUICtrlSetColor(-1, "0xFFFFFF")
        $Input4[$i] = GUICtrlCreateLabel("", 304, 20 + (20 * $i), 121, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY), 0)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        GUICtrlSetColor(-1, "0xFFFFFF")
        $Input5[$i] = GUICtrlCreateLabel("", 424, 20 + (20 * $i), 89, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY), 0)
        GUICtrlSetColor(-1, "0xFFFFFF")
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        $Button[$i] = GUICtrlCreateLabel("Connect", 518, 19 + (20 * $i), 75, 19, BitOR($SS_CENTER, $SS_CENTERIMAGE, $WS_BORDER))
        GUICtrlSetColor(-1, 0xFFFFFF)
        GUICtrlSetBkColor(-1, 0x7D8078)
        GUICtrlSetCursor(-1, 0)
    Next
    GUISetState()
EndFunc   ;==>Creategui

Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3);==>_GuiRoundCorners
    Dim $pos, $ret, $ret2
    $pos = WinGetPos($h_win)
    $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3, "long", $i_y3)
    If $ret[0] Then
        $ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1)
        If $ret2[0] Then
            Return 1
        Else
            Return 0
        EndIf
    Else
        Return 0
    EndIf
EndFunc   ;==>_GuiRoundCorners

Func Hover()
    For $i = 1 To $Index + 1
        Local $GetCursor = GUIGetCursorInfo()
        If $MouseOver[$i] And $GetCursor[4] = $Button[$i] Then
            GUICtrlSetColor($Button[$i], 0xC4B550)
            $MouseOver[$i] = 0
        ElseIf Not $MouseOver[$i] And Not $GetCursor[4] = $Button[$i] Then
            GUICtrlSetColor($Button[$i], 0xFFFFFF)
            $MouseOver[$i] = 1
        EndIf
    Next
EndFunc   ;==>Hover
Edited by Jex

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0