SpiffyTek
/
SMACheck
Archived
1
0
Fork 0
This repository has been archived on 2022-05-13. You can view files and clone it, but cannot push or open issues or pull requests.
SMACheck/includes/functions.inc.au3

150 lines
3.9 KiB
AutoIt

#include-once
;; SMAC XML APi
Func lookupSteamId($input)
HttpSetUserAgent("SMACheck/" & FileGetVersion(@ScriptName, "FileVersion"))
;Local $oXML = InetRead("http://api.spiffytek.com/pub/smacheck/-testing/steamid/" & $input, 19)
Local $oXML = InetRead("http://labor.spiffytek.com/smacheck/api/steamid/" & $input, 19)
If @error <> 0 Then
_printError("noapi")
Return "ERROR_HANDELED"
EndIf
$oXML = _XMLLoadXML(BinaryToString($oXML, 4))
If @error <> 0 Then
_printError("noapi")
Return "ERROR_HANDELED"
EndIf
If NOT StringLeft($oXML, 13) = "<?xml version" Then
_printError("noapi")
Return "ERROR_HANDELED"
EndIf
Local $pStatus = _XMLGetValue('/isbanned/status')
If IsArray($pStatus) <> 1 Then
_printError("noapi")
Return "ERROR_HANDELED"
EndIf
If @Compiled <> 0 Then
Local $curVersion = FileGetVersion(@ScriptName, "FileVersion")
Local $pMinVersion = _XMLGetValue("/isbanned/smaCheck/minVersion")
Local $pActVersion = _XMLGetValue("/isbanned/smaCheck/actVersion")
Global $gVersionChecked
If IsArray($pMinVersion) Then
If $curVersion < $pActVersion[1] Then
If $curVersion < $pMinVersion[1] Then
_printError("update_force")
Return "ERROR_HANDELED"
ElseIf $gVersionChecked = 0 Then
_printError("update")
$gVersionChecked = 1
EndIf
EndIf
EndIf
EndIf
If IsArray($pStatus) Then
Local $bReason = _XMLGetValue("/isbanned/reason")
Local $bNick = _XMLGetValue("/isbanned/nickname")
Local $bTime = _XMLGetValue("/isbanned/banTime")
Local $bVac = _XMLGetValue("/isbanned/vacStatus")
Local $bMod = _XMLGetValue("/isbanned/mod")
Local $bCc = _XMLGetValue("/isbanned/country")
Local $bEac = _XMLGetValue("/isbanned/eacStatus")
Local $bEsea = _XMLGetValue("/isbanned/eseaStatus")
;Local $bKac = _XMLGetValue("/isbanned/kacStatus")
If $bCc[1] = "" Then
$bCc[1] = "nocountry"
EndIf
If $pStatus[1] = "Y" Then
Local $oStatus = "SteamID is Banned"
Local $return[11]
$return[0] = $oStatus
$return[1] = $bNick[1]
$return[2] = $bReason[1]
$return[3] = $bTime[1]
$return[4] = $pStatus[1]
$return[5] = $bVac[1]
$return[6] = $bMod[1]
$return[7] = $bCc[1]
$return[8] = $bEac[1]
$return[9] = $bEsea[1]
$return[10] = -1
Else
Local $oStatus = "SteamID is not banned"
Local $return[11]
$return[0] = $oStatus
$return[1] = $bNick[1]
$return[2] = "-"
$return[3] = "-"
$return[4] = $pStatus[1]
$return[5] = $bVac[1]
$return[6] = "-"
$return[7] = "nocountry"
$return[8] = $bEac[1]
$return[9] = $bEsea[1]
$return[10] = -1
EndIf
Else
_printError("noapi")
Return "ERROR_HANDELED"
EndIf
Return $return
EndFunc
;; SteamID Convert
Dim Const $COMM_ID_START = 76561197960265728
Func steamId64ToSteamId($sComID)
$sComID = Number($sComID)
$a = ($sComID - $COMM_ID_START) / 2
$b = Floor($a)
$c = Round( Mod($a,Floor($a)) )
Return "STEAM_0:" & String( $c ) & ":" & String( $b )
EndFunc
Func steamIdToCommunityId($sSteamID)
Local $sResult, $expl, $serverid, $accountid
$expl = StringSplit($sSteamID,":")
if (UBound($expl) == 4) Then
$serverid = Number($expl[2])
$accountid = Number($expl[3])
$sResult = ($accountid * 2) + $COMM_ID_START + $serverid
EndIf
Return $sResult
EndFunc
;; Misc
Func resetInput($iID)
GUICtrlSetData($iID, "")
EndFunc
Func _printError($id = false)
Switch $id
Case "noapi"
MsgBox(16, "ERROR", "API not available.")
Case "update_force"
MsgBox(16, "Required Update available", "Required Update available." & @CRLF & @CRLF & "Please download new Version from smacbans.com.")
Case "update"
MsgBox(48, "Update available", "New Update available." & @CRLF & @CRLF & "Visit smacbans.com for more Info and Download.")
Case Else
MsgBox(16, "ERROR", "Unknown Error occured")
EndSwitch
EndFunc