Code:
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=Triggerbot\Source\Icons\AFK.ico
#AutoIt3Wrapper_outfile=AFKBot.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Opt("MustDeclareVars", 1)
#RequireAdmin
#include <file.au3>
#Region ;ScriptSettings
#Region ;UserSetSettings
Global $Width = InputBox("Game Resolution Width", "Please input your game resolution width", @DesktopWidth)
Global $Height = InputBox("Game Resolution Height", "Please input your game resolution height", @DesktopHeight)
Global $Q = Msgbox(4, "Login System", "Would you like to use the bot's automatic login system?" & @LF & @LF & "Note: ONLY WORKS WITH CRIMINALS AS OF RIGHT NOW!")
If $Q = 6 then
Global $Email = InputBox("Email", "Please input your email")
Global $Password = InputBox("Password", "Please input your password", "", "*")
Global $Character = InputBox("Character Selection", "Which character slot should be botted?", "1")
Do
Global $District = StringUpper(InputBox("District Select", "Type WF for waterfront district, or Finan for financial district", "Finan"))
Until $District == "WF" OR $District == "FINAN"
EndIf
Global $PauseKey = InputBox("Pause key", "What key should pause the bot?" & @LF & @LF & "Note: Modifier keys alone will not work", "`")
Global $PhrasesFile = "Phrases.txt"
#EndRegion ;UserSetSettings
#Region ;InternalSettings
Global $Sleep1[2] = [5,15]
;Controls first sleep timer, with the timer being a number between the first number and the second number, in seconds
Global $Sleep2[2] = [0,10]
;Controls second sleep timer, with the timer being a number between the first number and the second number, in seconds
Global $Sleep3[2] = [5,15]
;Controls third sleep timer, with the timer being a number between the first number and the second number, in seconds
Global $RandomAddition[2] = [1,3]
;Controls the adder that adds to the "ForceRandomPhrase" variable. It adds a random number between the two values to the $ForceRandomPhrase var.
Global $TriggerNumber = 6
;When the adder makes the "ForceRandomPhrase" variable greater than this number, a random phrase is typed in game.
Global $TimeToMove = 2
;Timer in seconds that the bot should move your character randomly
Global $EnableSound = True
;Enable beeps on pause/unpause of bot
Global $EnableTrayPopup = False
;Enable "Toasts" from notification tray indicating status of bot on pause/unpause
#EndRegion ;InternalSettings
#EndRegion ;ScriptSettings
#Region ;Internal Vars
Global $LoginEmail[2] = [0.432291666666667,0.482407407407407]
Global $LoginPass[2] = [0.432291666666667,0.528703703703704]
Global $LoginButton[2] = [0.566666666666667,0.570370370370370]
Global $CharacterSlots[2] = [0.089062500000000,0.210185185185185]
Global $CharacterSpacing = 0.0388888888888888
Global $SelectCharacter[2] = [0.942187500000000,0.979629629629630]
Global $FinanDistrict[2] = [0.496354166666667,0.483333333333333]
Global $WFDistrict[2] = [0.632291666666667,0.473148148148148]
Global $JoinDistrict[2] = [0.947916666666667,0.980555555555556]
Global $DoubleB[2] = [0.524479166666667,0.501851851851852]
Global $StregaBloodrose[2] = [0.387500000000000,0.146296296296296]
Global $Suji[2] = [0.258333333333333,0.438888888888889]
Global $ArlonBenjamin[2] = [0.330208333333333,0.485185185185185]
Global $GraysonFell[2] = [0.416145833333333,0.855555555555556]
Global $Javez[2] = [0.252083333333333,0.883333333333333]
Global $VeronikaLee[2] = [0.651562500000000,0.601851851851852]
Global $TerriQuan[2] = [0.171354166666667,0.660185185185185]
Global $TyronSennet[2] = [0.339062500000000,0.656481481481481]
Global $PaganBloodrose[2] = [0.431770833333333,0.579629629629630]
Global $ByronBloodrose[2] = [0.480729166666667,0.469444444444444]
Global $HarmonBenjamin[2] = [0.549479166666667,0.474074074074074]
Global $BritneyBloodrose[2]= [0.621354166666667,0.231481481481481]
Global $PremiumMsg[2] = [0.398958333333333,0.699074074074074]
Global $Paused
Global $Phrases[1]
#EndRegion ;Internal Vars
#Region ;Main
Global $RandomPhraseEnable = False
Global $ForceRandomPhrase = 0
HotkeySet($PauseKey, "_TogglePause")
_LoginSystem($Q, $Email, $Password, $Character, $District, $Height, $Width)
While 1
While WinActive("APB Reloaded")
_RandomTimer($Sleep1)
Send("k")
Send("b")
_RandomTimer($Sleep2)
Send("{Enter}")
Sleep(2000)
Send("/AbandonMission")
Sleep(2000)
Send("{Enter}")
_RandomTimer($Sleep3)
_MoveCharacter($TimeToMove, Number(Random(1, 4, 1)))
_RandomPhrase($RandomPhraseEnable, $RandomAddition, $TriggerNumber, $PhrasesFile)
_Click($PremiumMsg, $Height, $Width)
Wend
WEnd
#EndRegion ;Main
#Region ;Functions
;_LoginSystem(True/False [On/Off], Login Email, Login Password, Character to Bot, District Selection)
Func _LoginSystem($Enable, $LE, $LP, $Ch, $DS, $W = @DesktopWidth, $H = @DesktopHeight)
If $Enable Then
WinSetState("APB Reloaded", "", @SW_MAXIMIZE)
Sleep(10000)
_Click($LoginEmail, $W, $H)
Send("^a" & $LE)
_Click($LoginPass, $W, $H)
Send("^a" & $LP)
_Click($LoginButton, $W, $H)
Sleep(15000)
_CharacterSelect($CharacterSlots, $CharacterSpacing, $Ch, $W, $H)
Sleep(10000)
_Click($SelectCharacter, $W, $H)
Sleep(10000)
If $DS == "FINAN" Then
_Click($FinanDistrict, $W, $H)
_Click($JoinDistrict, $W, $H)
Sleep(60000)
_Click($DoubleB, $W, $H)
ElseIf $DS == "WF" Then
_Click($WFDistrict, $W, $H)
_Click($JoinDistrict, $W, $H)
Sleep(60000)
_Click($PaganBloodrose, $W, $H)
Else
MsgBox(0,"Error", "No district selected")
EndIf
EndIf
EndFunc
;_Click(Button, Height, Width, Click count)
Func _Click(ByRef $ClickLocation, $W = @DesktopWidth, $H = @DesktopHeight, $Clicks = 1)
MouseClick("Left", $ClickLocation[0] * $Width, $ClickLocation[1] * $H, $Clicks)
EndFunc
;_CharacterSelect(Character Slot 1 Location, Spacing between click points on boxes, Character To Select, Height, Width)
Func _CharacterSelect(ByRef $ClickLocation, $aS, $Character, $W = @DesktopWidth, $H = @DesktopHeight)
MouseClick("Left", $ClickLocation[0] * $W, ($ClickLocation[1] + ($aS * ($Character-1))) * $H, 1)
EndFunc
;_RandomTimer(Sleep Time Array)
Func _RandomTimer(ByRef $SA)
Sleep(Number(Random($SA[0], $SA[1], 1) * 1000))
EndFunc
;_MoveCharacter(Time to move character in seconds, Direction to Move [1 = W | 2 = S | 3 = A | 4 = S])
Func _MoveCharacter($TTM, $Direction)
Opt("SendKeyDownDelay", $TTM * 1000)
Switch $Direction
Case 1
Send("w")
Case 2
Send("d")
Case 3
Send("a")
Case 4
Send("s")
EndSwitch
Opt("SendKeyDownDelay", 5)
EndFunc
;_RandomPhrase(True/False [On/Off], Phrases File, Random Addition Array, Trigger Number)
Func _RandomPhrase($RPE, ByRef $RA, $TN, $PF)
If $RPE Then
Global $PhrasesArray
If Not IsDeclared("FRP") Then
Global $FRP = 0
EndIf
If (Not IsDeclared("PhrasesArray")) Or (Not IsArray($PhrasesArray)) Then
If FileExists($PF) Then
_FileReadToArray($PF, $PhrasesArray)
EndIf
EndIf
$FRP += Number(Random($RA[0], $RA[1]))
If $FRP > Number($TN) Then
Send("{Enter}")
Sleep(2000)
Send("/d " & $PhrasesArray[Random(1, $PhrasesArray[0], 1)])
Sleep(2000)
Send("{Enter}")
$FRP = 0
EndIf
EndIf
EndFunc ;==>_RandomPhrase
;_TogglePause(N/A)
Func _TogglePause()
$Paused = Not $Paused
If $Paused Then
If Number($EnableSound) Then
Beep(300, 100)
Beep(200, 100)
EndIf
If Number($EnableTrayPopup) Then TrayTip("", "AFK Bot has been paused", 1, 16)
Else
If Number($EnableSound) Then
Beep(200, 100)
Beep(300, 100)
EndIf
If Number($EnableTrayPopup) Then TrayTip("", "AFK Bot has been unpaused", 1, 16)
EndIf
While $Paused
ToolTip('AFK Bot is paused', 0, 0)
Sleep(100)
WEnd
ToolTip("")
EndFunc ;==>_TogglePause
#EndRegion ;Functions
I've cleaned it up quite a bit, made the functions easier to understand, and made them a bit more modular (excluding _TogglePause()) so you can use them as you see fit in a personal AFK Bot made in AutoIt.