Jump to content

help with socket


Recommended Posts

hi all im using autoit for like a year and a friendof mine gave me his script and he closed his project and when i try to use it ive founded this :

UDPStartup()

; Open a "SOCKET"
;==============================================

$socket = UDPOpen("193.188.0.102", 65532)
If @error <> 0 Then Exit

$n = 0
While 1
    $BotAccount = GUICtrlRead($Account)
    $BotPass = GUICtrlRead($Pass)
    $msg = GUIGetMsg()
    If $msg = $Check Then
        $status = UDPSend($socket, GUICtrlRead($Account) & "|" & GUICtrlRead($Pass) & "|" & "OK")
        If $status = 0 Then
            MsgBox(0, "ERROR", "Error while connecting " & @error)
            Exit
        EndIf
        Sleep(1000)
        $Response = UDPRecv($socket, 50)
        If $Response = "Accepted" Then
            GUISetState(@SW_HIDE)
            MainGUI()
        EndIf
        If $Response = "Denied" Then
        EndIf
        If $Response = "Exit" Then
            Exit
        EndIf
    EndIf

    If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd

Func OnAutoItExit()
    $DC = UDPSend($socket, $Account & "|" & $Pass & "|" & "DC")
    UDPCloseSocket($socket)
    UDPShutdown()

so if any of you now anything about what i should replace to make it work for me or how to delete this kind of connection and use the script normally or if any of you now where i can find a tutorial irt will be very useful and im a noob in socket lol

Edited by REDbot
Link to comment
Share on other sites

First of all this is not a complete script. In addition this is only the client part. It communicates with another script (the server part) which probably you don't have. So this script itself is totally useless to you.

Link to comment
Share on other sites

#include <GUIListView.au3>
#include <GUIConstants.au3>
#include <GuiList.au3>


Opt("MouseCoordMode", 0)
Opt("PixelCoordMode", 0)
;-------------HotKeys-----------------------------------------------------------------------------------------------------
HotKeySet("{Home}", "Start")
HotKeySet("{END}", "stop")
HotKeySet("{PAUSE}", "Pause")
HotKeySet("{F11}", "SaveCoords")
HotKeySet("{F8}", "WalkPath")
;----------------------------------------------------------------------------------------------------------------------------

;---------------------------------------------------------------------------------------------------------------------------
Global $MonsterLightNotFound
Global $MonsterNotFound
Global $MonsterDead
Global $mobFind
Global $PartyLeader
Global $autoParty
Global $Wait
Global $Paused
Global $Coordsystem
Global $east
Global $west
Global $south
Global $north
Global $SavedX
Global $SavedY
Global $CurrentCoord
Global $DestinationY
Global $DestinationX
Global $WalkToY
Global $WalkToX
Global $walktoSystem
Global $walkback
Global $CastSkill
Global $Buff1Timer
Global $Buff2Timer
Global $Buff3Timer
Global $Buff4Timer
Global $Buff5Timer
Global $ChatTimer
Global $GetStuckCoords
Global $Timer1
Dim $BotName = "ProBot"
Global $BotAccount
Global $BotPass
Global $ProcessID = WinGetProcess("SRO_Client","");
Global $XAddress
Global $YAddress
Global $YC
Global $XC
Global $Name
Global $result
Global $ItemText
Global $Wait
Global $pos
Global $poscoord
Dim $Sensitivity = 8
Global $SellingItem
Dim $SpamMessage1 = "SELLING ELEXIRS BY STORAGE WEP = 280k, PRO = 100k, SHEILD = 50K, ACC = 40K"
Dim $SpamDelay = 50000


#Include <GuiConstants.au3>

GUICreate("ProBot Login Server", 300, 100)
GUICtrlCreateLabel("Username", 10, 20)
$Account = GUICtrlCreateInput("", 60, 18, 60, 20)
GUICtrlCreateLabel("Password", 130, 20)
$Pass = GUICtrlCreateInput("", 180, 18, 60, 20)

$Check = GUICtrlCreateButton("Login", 120, 50, 50, 30)
GUISetState()
;;This is the UDP Client
;;Start the server first

; Start The UDP Services
;==============================================
UDPStartup()

; Open a "SOCKET"
;==============================================

$socket = UDPOpen("192.168.0.101", 65532)
If @error <> 0 Then Exit

$n = 0
While 1
    $BotAccount = GUICtrlRead($Account)
    $BotPass = GUICtrlRead($Pass)
    $msg = GUIGetMsg()
    If $msg = $Check Then
        $status = UDPSend($socket, GUICtrlRead($Account) & "|" & GUICtrlRead($Pass) & "|" & "OK")
        If $status = 0 Then
            MsgBox(0, "ERROR", "Error while connecting " & @error)
            Exit
        EndIf
        Sleep(1000)
        $Response = UDPRecv($socket, 50)
        If $Response = "Accepted" Then
            GUISetState(@SW_HIDE)
           MainGUI()
        EndIf
        If $Response = "Denied" Then
        EndIf
        If $Response = "Exit" Then
            Exit
        EndIf
    EndIf

    If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd

Func OnAutoItExit()
    $DC = UDPSend($socket, $BotAccount & "|" & $BotPass & "|" & "DC")
    UDPCloseSocket($socket)
    UDPShutdown()
EndFunc   ;==>OnAutoItExit
Func MainGUI()
    #include <GUIConstants.au3>
    Global $Name

    #include <GUIConstants.au3>

    #Region ### START Koda GUI section ### Form=c:\program files\autoit3\scite\koda\forms\botproject v 1.04 gui.kxf
    $Form1_1 = GUICreate("ProBot    Beta  Version 1.07", 549, 276, -1, -1)
    $Group1 = GUICtrlCreateGroup("Auto Login", 8, 8, 193, 97)
    GUICtrlSetColor(-1, 0x0000FF)
    $Label1 = GUICtrlCreateLabel("UserName", 16, 24, 54, 17)
x
x
x
x
x

x
x
x
x
x
x
x
x
x

x
    $MenuItem3 = TrayCreateItem("Exit")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###


    While 1
        $Response = UDPRecv($socket, 50)
        If $Response = "Exit" Then
            Exit
        EndIf
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit

x
x
x
x

x
x
x
x
x
x
x

x
x
x
x
x
x
                    GUICtrlSetState($WolfHPBelt, $GUI_DISABLE)
                    GUICtrlSetState($WolfHPKey, $GUI_DISABLE)
                EndIf
            Case $Save
                $UserName1 = GUICtrlRead($UserName)
                $Name = $UserName1 & ".ini"

                IniWrite($Name, "login", "UserName", GUICtrlRead($UserName))
                IniWrite($Name, "login", "PassWord", GUICtrlRead($PassWord))
                IniWrite($Name, "login", "Char", GUICtrlRead($char))
                IniWrite($Naxx
                x
                x
                x
                x
                
                x
                x
                x
                x
                
                x
                xx
                
                x
                x
                IniWrite($Name, "Other", "ChampSkills", GUICtrlRead($ChampSkills))
                MsgBox(64, "BotProject", "Settings Saved")
            Case $Load
                $Name = FileOpenDialog("Open a File", @ScriptDir, "(*.ini)", 1 + 2)
                If @error Then
                    MsgBox(4096, "", "No File(s) chosen")
                Else
                    $Name = StringReplace($Name, "|", @CRLF)
                EndIf

                ;$Name = InputBox("BotProject","Enter The Name of the ini file")

                If @error <> 1 And $Name <> "" Then
                    $_UserName = IniRead($Name, "login", "UserName", "")
                    $_PassWord = IniRead($Name, "login", "PassWord", "")
                    $_Char = IniRead($Name, "login", "Char", "")
                    $_Skill1Belt = IniRead($Name, "Skills", "Skill1Belt", "")
x
x
x

x
x
x
x
x

x
x

x
                    GUICtrlSetData($UserName, $_UserName)
                    GUICtrlSetData($PassWord, $_PassWord)
                    GUICtrlSetData($char, $_Char)
                    GUICtrlSetData($Camera, $_Camera)
                    GUICtrlSetData($Skill1Belt, $_Skill1Belt)
                    GUICtrlSetData($Skill2Belt, $_Skill2Belt)
                    GUICtrlSetData($Skill3Belt, $_Skill3Belt)
                    GUICtrlSetData($Skill4Belt, $_Skill4Belt)
                    GUICtrlSetData($Skill5Belt, $_Skill5Belt)
                    GUICtrlSetData($Skill1Key, $_Skill1Key)
                    GUICtrlSetData($Skill2Key, $_Skill2Key)
                    GUICtrlSetData($Skill3Key, $_Skill3Key)
                    GUICtrlSetData($Skill4Key, $_Skill4Key)
                    GUICtrlSetData($Skill5Key, $_Skill5Key)
                    If $_UseSkill1 = 1 Then
                        GUICtrlSetState($UseSkill1, $GUI_CHECKED)
                        GUICtrlSetState($Skill1Belt, $GUI_ENABLE)
                        GUICtrlSetState($Skill1Key, $GUI_ENABLE)
                    Else
                        GUICtrlSetState($UseSkill1, $GUI_UNCHECKED)
                        GUICtrlSetState($Skill1Belt, $GUI_DISABLE)
                        GUICtrlSetState($Skill1Key, $GUI_DISABLE)
                    EndIf
                    If $_UseSkill2 = 1 Then
                        GUICtrlSetState($UseSkill2, $GUI_CHECKED)
                        GUICtrlSetState($Skill2Belt, $GUI_ENABLE)
                        GUICtrlSetState($Skill2Key, $GUI_ENABLE)
                    Else
                        GUICtrlSetState($UseSkill1, $GUI_UNCHECKED)
                        GUICtrlSetState($Skill2Belt, $GUI_DISABLE)
                        GUICtrlSetState($Skill2Key, $GUI_DISABLE)
                    EndIf
                    If $_UseSkill3 = 1 Then
                        GUICtrlSetState($UseSkill3, $GUI_CHECKED)
                        GUICtrlSetState($Skill3Belt, $GUI_ENABLE)
                        GUICtrlSetState($Skill3Key, $GUI_ENABLE)
                    Else
                        GUICtrlSetState($UseSkill3, $GUI_UNCHECKED)
                        GUICtrlSetState($Skill3Belt, $GUI_DISABLE)
                        GUICtrlSetState($Skill3Key, $GUI_DISABLE)
                    EndIf
                    If $_UseSkill4 = 1 Then
                x
                x
                x
                
                x
                x
                x
                
                x
                x
                x
                x
                x
                
                x
                        GUICtrlSetState($Buff2Key, $GUI_ENABLE)
                        GUICtrlSetState($Buff2Delay, $GUI_ENABLE)
                    Else
                        GUICtrlSetState($UseBuff1, $GUI_UNCHECKED)
                        GUICtrlSetState($Buff2Belt, $GUI_DISABLE)
                        GUICtrlSetState($Buff2Key, $GUI_DISABLE)
                        GUICtrlSetState($Buff2Delay, $GUI_DISABLE)
                    EndIf
                    If $_UseBuff3 = 1 Then
                        GUICtrlSetState($UseBuff3, $GUI_CHECKED)
                        GUICtrlSetState($Buff3Belt, $GUI_ENABLE)
                        GUICtrlSetState($Buff3Key, $GUI_ENABLE)
                        GUICtrlSetState($Buff3Delay, $GUI_ENABLE)
                    Else
                        GUICtrlSetState($UseBuff3, $GUI_UNCHECKED)
                        GUICtrlSetState($Buff3Belt, $GUI_DISABLE)
                        GUICtrlSetState($Buff3Key, $GUI_DISABLE)
                        GUICtrlSetState($Buff3Delay, $GUI_DISABLE)
                    EndIf
                    If $_UseBuff4 = 1 Then
                        GUICtrlSetState($UseBuff4, $GUI_CHECKED)
                        GUICtrlSetState($Buff4Belt, $GUI_ENABLE)
                        GUICtrlSetState($Buff4Key, $GUI_ENABLE)
                        GUICtrlSetState($Buff4Delay, $GUI_ENABLE)
                    Else
                        GUICtrlSetState($UseBuff1, $GUI_UNCHECKED)
                        GUICtrlSetState($Buff4Belt, $GUI_DISABLE)
                        GUICtrlSetState($Buff4Key, $GUI_DISABLE)
                        GUICtrlSetState($Buff4Delay, $GUI_DISABLE)
                    EndIf
                    If $_UseBuff5 = 1 Then
                        GUICtrlSetState($UseBuff5, $GUI_CHECKED)
        x
        x
        x
        x
        
        x
        x
        x
        x
        x
        x
        x

                    If $_PickUpItems = 1 Then
                        GUICtrlSetState($PickUpItems, $GUI_CHECKED)
                    Else
                        GUICtrlSetState($PickUpItems, $GUI_UNCHECKED)
                    EndIf
                    If $_UseBeserk = 1 Then
                        GUICtrlSetState($UseBeserk, $GUI_CHECKED)
                        GUICtrlSetState($UseBeserkWhen, $GUI_ENABLE)
                    Else
                        GUICtrlSetState($UseBeserk, $GUI_UNCHECKED)
                        GUICtrlSetState($UseBeserkWhen, $GUI_DISABLE)
                    EndIf
                    If $_TownHP = 1 Then
                        GUICtrlSetState($TownHP, $GUI_CHECKED)
                    Else
                        GUICtrlSetState($TownHP, $GUI_UNCHECKED)
                    EndIf
                    If $_TownMP = 1 Then
                        GUICtrlSetState($TownMP, $GUI_CHECKED)
                    Else
                        GUICtrlSetState($TownMP, $GUI_UNCHECKED)
                    EndIf
                    If $_TownRepair = 1 Then
                        GUICtrlSetState($TownRepair, $GUI_CHECKED)
                        GUICtrlSetState($DuraItems, $GUI_ENABLE)
                        GUICtrlSetData($DuraItems, $_DuraItems)
                    Else
                        GUICtrlSetState($TownRepair, $GUI_UNCHECKED)
                        GUICtrlSetState($DuraItems, $GUI_DISABLE)
                    EndIf
                    If $_LogHP = 1 Then
                        GUICtrlSetState($LogHP, $GUI_CHECKED)
                    Else
                        GUICtrlSetState($LogHP, $GUI_UNCHECKED)
                    EndIf
                    If $_LogMP = 1 Then
                        GUICtrlSetState($LogMP, $GUI_CHECKED)
                    Else
                        GUICtrlSetState($LogMP, $GUI_UNCHECKED)
                    EndIf
                    If $_LogDurability = 1 Then
                        GUICtrlSetState($LogDurability, $GUI_CHECKED)
                        GUICtrlSetState($DurItems, $GUI_ENABLE)
                        GUICtrlSetData($DurItems, $_DurItems)
                    Else
                        GUICtrlSetState($LogDurability, $GUI_UNCHECKED)
                        GUICtrlSetState($DurItems, $GUI_ENABLE)
                    EndIf
                    GUICtrlSetData($BlueSkills, $_BlueSkills)
                    GUICtrlSetData($GreenSkills, $_GreenSkills)
                    GUICtrlSetData($WhiteSkills, $_WhiteSkills)
                    GUICtrlSetData($OrangeSkills, $_OrangeSkills)
                    GUICtrlSetData($RedSkills, $_RedSkills)
                    GUICtrlSetData($AreaX, $_AreaX)
                    GUICtrlSetData($AreaY, $_AreaY)
                    GUICtrlSetData($Area, $_Area)
                    GUICtrlSetData($WhenDead, $_WhenDead)
                    If $_RunFromRed = 1 Then
                        GUICtrlSetState($RunFromRed, $GUI_CHECKED)
                    Else
                        GUICtrlSetState($RunFromRed, $GUI_UNCHECKED)
                    EndIf
                    If $_SitHeal = 1 Then
                        GUICtrlSetState($SitHeal, $GUI_CHECKED)
                        GUICtrlSetState($SitAt, $GUI_ENABLE)
                        GUICtrlSetData($SitAt, $_SitAt)
                    Else
                        GUICtrlSetState($SitHeal, $GUI_UNCHECKED)
                        GUICtrlSetState($SitAt, $GUI_DISABLE)
                    EndIf
                    If $_UseWolf = 1 Then
                        GUICtrlSetState($UseWolf, $GUI_CHECKED)
                        GUICtrlSetState($WolfBelt, $GUI_ENABLE)
                        GUICtrlSetState($WolfKey, $GUI_ENABLE)
                        GUICtrlSetState($HGPBelt, $GUI_ENABLE)
                        GUICtrlSetState($HGPKey, $GUI_ENABLE)
                        GUICtrlSetState($WolfHPBelt, $GUI_ENABLE)
                        GUICtrlSetState($WolfHPKey, $GUI_ENABLE)
                    Else
                        GUICtrlSetState($UseWolf, $GUI_UNCHECKED)
                        GUICtrlSetState($WolfBelt, $GUI_DISABLE)
                        GUICtrlSetState($WolfKey, $GUI_DISABLE)
                        GUICtrlSetState($HGPBelt, $GUI_DISABLE)
                        GUICtrlSetState($HGPKey, $GUI_DISABLE)
                        GUICtrlSetState($WolfHPBelt, $GUI_DISABLE)
                        GUICtrlSetState($WolfHPKey, $GUI_DISABLE)
                    EndIf
                    GUICtrlSetData($WolfBelt, $_WolfBelt)
                    GUICtrlSetData($WolfKey, $_WolfKey)
                    GUICtrlSetData($HGPBelt, $_HGPBelt)
                    GUICtrlSetData($HGPKey, $_HGPKey)
                    GUICtrlSetData($WolfHPBelt, $_WolfHPBelt)
                    GUICtrlSetData($WolfHPKey, $_WolfHPKey)
                    If $_NuBotPickup = 1 Then
                        GUICtrlSetState($NuBotPickup, $GUI_CHECKED)
                    EndIf
                    If $_NuBotSearch = 1 Then
                        GUICtrlSetState($NuBotSearch, $GUI_CHECKED)
                    EndIf
                    If $_AlertGM = 1 Then
                        GUICtrlSetState($AlertGM, $GUI_CHECKED)
                    EndIf
                    If $_AlertPM = 1 Then
                        GUICtrlSetState($AlertPM, $GUI_CHECKED)
                    EndIf
                    GUICtrlSetData($GiantSkills, $_GiantSkills)
                    GUICtrlSetData($ChampSkills, $_ChampSkills)
                    MsgBox(64, "ProBot", "Settings Loaded")
                EndIf

            Case $Start
                GUISetState(@SW_HIDE)
                Readyy()
        EndSwitch
    WEnd
EndFunc   ;==>MainGUI


Func Pause()
    $Paused = Not $Paused
    While $Paused
        $Response = UDPRecv($socket, 50)
        If $Response = "Exit" Then
            Exit
        EndIf
        ToolTip($BotName & ": Paused ", 2, 0)
        Sleep(400)
    WEnd
EndFunc   ;==>Pause

Func stop()
    $DC = UDPSend($socket, $BotAccount & "|" & $BotPass & "|" & "DC")
    ToolTip($BotName & ": Shutting Down ", 2, 0)
    Sleep(2000)
    MsgBox(64, $BotName, "Thanks for using " & $BotName & ", Made By The BotProject Team.")
    Exit
EndFunc   ;==>stop

Func Wait()
    Global $Message
    $Wait = Not $Wait
    While $Wait
        $Response = UDPRecv($socket, 50)
        If $Response = "Exit" Then
            Exit
        EndIf
        ToolTip($BotName & ": Press the HOME key to start ", 2, 0)
        Sleep(400)
    WEnd
EndFunc   ;==>Wait


Func Readyy()
    If Not WinExists("SRO_Client") Then
        $Launch = MsgBox(4, $BotName, "Silkroad is not running, Would you like to launch it?")
        Select
            Case $Launch = 6 ;Yes

            Case $Launch = 7 ;No
        EndSelect
        If $Launch = 6 Then
            Run("c:/program files/silkroad/silkroad.exe")
            WinWait("Silkroad Online Launcher")
            WinActivate("Silkroad Online Launcher")
            ControlClick("Silkroad Online Launcher", "Start", "1000")
            WinWaitActive("SRO_Client")
            Sleep(500)
        EndIf
    EndIf
    Wait()
EndFunc   ;==>Readyy

Func Start()
    $Monsterlvl = 0
    $tookmoblvl = 0
    WinActivate('SRO_Client')
    CameraSetup()
    $TimerC = TimerInit()
    $PartyTimer = TimerInit()
    $PotTimer = TimerInit()
    $Buff1Timer = TimerInit()
    $Buff2Timer = TimerInit()
    $Buff3Timer = TimerInit()
    $Buff4Timer = TimerInit()
    $Buff5Timer = TimerInit()
    $ChatTimer = TimerInit()
    $BotOpenTimer = TimerInit()
    While 1
        $Response = UDPRecv($socket, 50)
        If $Response = "Exit" Then
            Exit
        EndIf
        If $AlertGM = 1 Or $AlertPM = 1 Then
            ChatCheck()
        EndIf
        DisconnectCheck()
        CheckIfDead()
        $MonsterDead = 0
        If TimerDiff($PartyTimer) > 10 * 1000 Then
            ToolTip($BotName & ": Party Check ", 2, 0)
            PartyCheck()
            $PartyTimer = TimerInit()
        EndIf
        If TimerDiff($PotTimer) > 5 * 1000 Then
            If $LogHP = 1 Or $LogMP = 1 Or $TownHP = 1 Or $TownMP = 1 Or $TownRepair = 1 Or $LogDurability = 1 Then
                ToolTip($BotName & ": Pot Check ", 2, 0)
                PotCheck()
                $PotTimer = TimerInit()
            EndIf
        EndIf
        If $SitHeal = 1 Then
            Sit()
        EndIf
        WolfStuff()
        If $Coordsystem = 1 Then
            If TimerDiff($TimerC) > 8 * 1000 Then
                ToolTip($BotName & ": Check coords ", 2, 0)
                CheckCoords()
                $TimerC = TimerInit()
            EndIf
        EndIf
        If $UseBuff1 = 1 Or $UseBuff2 = 1 Or $UseBuff3 = 1 Or $UseBuff4 = 1 Or $UseBuff5 = 1 Then
            Buff()
        EndIf
        If $NuBotSearch = 1 Then
            NuBotSearch()
        Else
            ToolTip($BotName & ": Searching for monsters ", 2, 0)
            CheckMonster()
        EndIf
    WEnd
EndFunc   ;==>AutoTrain

;-------------------------------Camera Setup------------------------------------------------------------------------------
Func CameraSetup()
    ToolTip($BotName & ": Setting Camera ", 2, 0)
    WinActivate('SRO_Client')
    Send("{F9}")
    $nRotation = PixelGetColor(961, 104)
    Sleep(500)
    While $nRotation <> 16711680
        Send("{right down}")
        $nRotation = PixelGetColor(961, 114)
    WEnd
    Send("{right up}")
    Send("{F9}")
    Send("{F9}")
    MouseMove(500, 90, 0)
    Sleep(500)
    MouseClickDrag("right", 500, 90, 500, 610, 10)
    Sleep(500)
    MouseWheel("Up", 25)
    MouseWheel("down", $Camera)
    Sleep(100)
EndFunc   ;==>CameraSetup


;----------------------------Checks----------------------------------------------------------------------------------------
Func ChatCheck()
    If TimerDiff($ChatTimer) > 5500 Then
        If $AlertGM = 1 Then
            $ChatTimer = TimerInit()
            $ChatCoord = PixelSearch(23, 566, 396, 690, 0xFFAEC3, 2)
            If Not @error Then
                SoundPlay("C:\Windows\media\notify.wav")
            EndIf
        EndIf
        If $AlertPM = 1 Then
            $ChatTimer = TimerInit()
            $ChatCoord = PixelSearch(23, 566, 396, 690, 0x9FFFFE, 2)
            If Not @error Then
                SoundPlay("C:\Windows\media\notify.wav")
            EndIf
        EndIf
    EndIf
EndFunc   ;==>ChatCheck


Func CheckIfDead()
    If PixelGetColor(539, 494) = 0xFEFBD8 Then
        ToolTip($BotName & ": You Died ", 2, 0)
        Sleep(1000)
        If $WhenDead = "Log Out" Then
            Send("{ESC}")
            Sleep(250)
            MouseClick("left", 500, 450, 2)
            Exit
        EndIf
        If $WhenDead = "Return To Town" Then
            MouseClick("Left", 473, 490)
            Sleep(1000)
        EndIf
        If $WhenDead = "Ask For Res" Then
            MouseClick("Left", 627, 489)
            Sleep(1000)
            MouseClick("Left", 69, 553)
            Sleep(1000)
            Send("{Enter}")
            Send("{BackSpace Down}")
            Sleep(2000)
            Send("{BackSpace Up}")
            $ResTimer = TimerInit()

            While 1
                $ResMessage = Random(0, 7, 1)
                If $ResMessage = 0 Then
                    Send("can someone please res me")
                    Send("{Enter}")
                    Sleep(16000)
                EndIf
                If $ResMessage = 1 Then
                    Send("please res me")
                    Send("{Enter}")
                    Sleep(16000)
                EndIf
                If $ResMessage = 2 Then
                    Send("please someone res me")
                    Send("{Enter}")
                    Sleep(16000)
                EndIf
                If $ResMessage = 3 Then
                    Send("hey could you res me plz")
                    Send("{Enter}")
                    Sleep(16000)
                EndIf
                If $ResMessage = 4 Then
                    Send("can i get a res please")
                    Send("{Enter}")
                    Sleep(16000)
                EndIf
                If $ResMessage = 5 Then
                    Send("can someone please res me")
                    Send("{Enter}")
                    Sleep(16000)
                EndIf
                If $ResMessage = 6 Then
                    Send("res please")
                    Send("{Enter}")
                    Sleep(16000)
                EndIf
                If $ResMessage = 7 Then
                    Send("anyone wanna resurect me")
                    Send("{Enter}")
                    Sleep(16000)
                EndIf
                If PixelGetColor(539, 494) = 0xFEFBD8 Then
                    MouseClick("Left", 473, 490)
                    Sleep(1000)
                    $RandMes = Random(1, 4, 1)
                    If $RandMes = 1 Then
                        Send("thanks")
                    EndIf
                    If $RandMes = 2 Then
                        Send("thx")
                    EndIf
                    If $RandMes = 3 Then
                        Send("awsome thx")
                    EndIf
                    If $RandMes = 4 Then
                        Send("Thank you")
                    EndIf
                    ExitLoop
                EndIf
                If TimerDiff($ResTimer) > 350000 Then
                    Send("{ESC}")
                    Sleep(250)
                    MouseClick("left", 500, 450, 2)
                    Exit
                EndIf
            WEnd
        EndIf
    EndIf
EndFunc   ;==>CheckIfDead


Func DisconnectCheck()
    ToolTip($BotName & ": Disconnect Check ", 2, 0)
    PixelSearch(376, 323, 381, 328, 0x1F1F1F, 10)
    If Not @error Then
        PixelSearch(397, 377, 402, 382, 0x292421, 5)
        If Not @error Then
            PixelSearch(480, 422, 485, 427, 0x7B6B4A, 10)
            If Not @error Then
                MouseMove(510, 421)
                Sleep(1000)
            EndIf

            PixelSearch(480, 422, 485, 427, 0x9C4A31, 10)
            If Not @error Then
                MouseClick("Left", 510, 421) ;Closes Disconnect Box
                Reconnect()
            EndIf
        EndIf
    EndIf
EndFunc   ;==>DisconnectCheck


Func PotCheck()
    Send("{F1}")
    Sleep(500)
    If $LogHP = 1 Then
        ToolTip($BotName & ": Checking Pots ", 2, 0)
        PixelSearch(692, 731, 716, 754, 0x080008, 15)
        If @error Then
            ToolTip($BotName & ": Pots not found , check once more ", 2, 0)
            PixelSearch(692, 731, 716, 754, 0x000831, 15)
            If @error Then
                Send("{ESC}")
                Sleep(250)
                MouseClick("left", 500, 450, 2)
                Exit
            EndIf
        EndIf
    EndIf
    If $LogMP = 1 Then
        PixelSearch(728, 732, 752, 754, 0x1942EF, 15)
        If @error Then
            ToolTip($BotName & ": Pots not found , check once more ", 2, 0)
            PixelSearch(728, 732, 752, 754, 0x1942EF, 15)
            If @error Then
                Send("{ESC}")
                Sleep(250)
                MouseClick("left", 500, 450, 2)
                Exit
            EndIf
        EndIf
    EndIf
    If $LogDurability = 1 Then
        $BrokenItems = 0
        If PixelGetColor(984, 240) = 0xD40E00 Then
            $BrokenItems = $BrokenItems + 1
        EndIf
        If PixelGetColor(984, 278) = 0xD40E00 Then
            $BrokenItems = $BrokenItems + 1
        EndIf
        If PixelGetColor(984, 310) = 0xD40E00 Then
            $BrokenItems = $BrokenItems + 1
        EndIf
        If PixelGetColor(984, 345) = 0xD40E00 Then
            $BrokenItems = $BrokenItems + 1
        EndIf
        If PixelGetColor(984, 380) = 0xD40E00 Then
            $BrokenItems = $BrokenItems + 1
        EndIf

        If $BrokenItems >= $DurItems Then
            Send("{esc}")
            Sleep(300)
            MouseMove(500, 450, 0)
            Sleep(250)
            MouseClick("left", 500, 450, 2)
            MsgBox(0, "NOTICE", "Durability CRITICAL, Silkroad Shutdown")
            Exit
        EndIf
    EndIf


    If $TownHP = 1 Then
        ToolTip($BotName & ": Checking Pots ", 2, 0)
        PixelSearch(692, 731, 716, 754, 0xCE0000, 15)
        If @error Then
            ToolTip($BotName & ": Pots not found , check once more ", 2, 0)
            PixelSearch(692, 731, 716, 754, 0xCE0000, 15)
            If @error Then
                GoToTown()
            EndIf
        EndIf
    EndIf

    If $TownMP = 1 Then
        PixelSearch(728, 732, 752, 754, 0x1942EF, 15)
        If @error Then
            ToolTip($BotName & ": Pots not found , check once more ", 2, 0)
            PixelSearch(728, 732, 752, 754, 0x1942EF, 15)
            If @error Then
                GoToTown()
            EndIf
        EndIf
    EndIf

    If $TownRepair = 1 Then
        $BrokenItems = 0
        If PixelGetColor(984, 240) = 0xD40E00 Then
            $BrokenItems = $BrokenItems + 1
        EndIf
        If PixelGetColor(984, 278) = 0xD40E00 Then
            $BrokenItems = $BrokenItems + 1
        EndIf
        If PixelGetColor(984, 310) = 0xD40E00 Then
            $BrokenItems = $BrokenItems + 1
        EndIf
        If PixelGetColor(984, 345) = 0xD40E00 Then
            $BrokenItems = $BrokenItems + 1
        EndIf
        If PixelGetColor(984, 380) = 0xD40E00 Then
            $BrokenItems = $BrokenItems + 1
        EndIf

        If $BrokenItems >= $DurItems Then
            GoToTown()
        EndIf
    EndIf
EndFunc   ;==>PotCheck


Func PartyCheck()
    If $PartyLeader = 1 Then
        PixelSearch(437, 457, 442, 465, 0x73634A, 1)
        If Not @error Then
            MouseClick("left", 464, 459)
            Sleep(500)
        EndIf
    EndIf
    PixelSearch(12, 151, 14, 156, 0x000000, 5)
    If @error Then
        AutoParty()
    Else
        $autoParty = 0
    EndIf
EndFunc   ;==>PartyCheck

;-----------------------------------------------------------------------------------------------------------------------------


;-------------Sit--------------------------------------------------------------------------------------------------------------
Func Sit()
    ToolTip($BotName & ": Sitting ", 2, 0)
    If $SitAt = "75%" Then
        PixelSearch(184, 34, 186, 42, 0x181618, 12)
        If Not @error Then
            Send("{n}")
        EndIf
    EndIf
    If $SitAt = "50%" Then
        PixelSearch(138, 34, 140, 42, 0x181618, 12)
        If Not @error Then
            Send("{n}")
        EndIf
    EndIf
    If $SitAt = "25%" Then
        PixelSearch(104, 34, 106, 42, 0x181618, 12)
        If Not @error Then
            Send("{n}")
        EndIf
    EndIf
    While PixelGetColor(205, 37) = 0x181618
        Sleep(1000)
        If PixelGetColor(539, 494) = 0xFEFBD8 Then
            ToolTip($BotName & ": You Died ", 2, 0)
            CheckIfDead()
        EndIf
    WEnd
    Send("{n}")
EndFunc   ;==>Sit
;-----------------------------------------------------------------------------------------------------------------------------


;------------------Login, reconnect, restart------------------------------------------------------------------------------------
Func loginn()
    ToolTip($BotName & ": Logging In ", 2, 0)
    Sleep(2000)
    WinActivate("SRO_Client")
    Sleep(250)
    MouseClick("left", 456, 232)
    Sleep(4000)
    ControlSend("SRO_Client", "", "", "{ENTER}")
    Sleep(1000)
    Sleep(1000)
    ControlSend("SRO_Client", "", "", "{TAB}")
    Sleep(1000)
    Send($UserName)
    Sleep(1000)
    ControlSend("SRO_Client", "", "", "{TAB}")
    Sleep(1000)
    Send($PassWord)
    Sleep(1000)
    ControlSend("SRO_Client", "", "", "{Enter}")
    While PixelGetColor(500, 755) = 0xFFFFFF
        $disconnect = PixelSearch(410, 360, 420, 370, 0x313131, 25, 1)
        If Not @error Then
            Sleep(250)
            MouseMove(505, 425, 0)
            MouseClick("left", 510, 425)
            Sleep(250)
            MouseClick("left", 510, 425)
            Sleep(2000)
            DisconnectCheck()
        EndIf
        ControlSend("SRO_Client", "", "", "{ENTER}")
        Sleep(1000)
    WEnd
    charselect()
EndFunc   ;==>loginn


Func charselect()
    ToolTip($BotName & ": Selecting Char ", 2, 0)
    Sleep(4000)
    $char = PixelSearch(185, 70, 265, 95, 0xD5BC89, 25)
    If Not @error Then
        Sleep(2000)
        If $char = 1 Then
            MouseMove(325, 348, 0)
            MouseClick("left", 325, 348, 2)
            MouseClick("left", 325, 348, 2)
        EndIf
        If $char = 2 Then
            MouseMove(521, 362, 0)
            MouseClick("left", 521, 362, 2)
            MouseClick("left", 521, 362, 2)
        EndIf
        If $char = 3 Then
            MouseMove(704, 374, 0)
            MouseClick("left", 704, 374, 2)
            MouseClick("left", 704, 374, 2)
        EndIf
        Sleep(800)
        If PixelGetColor(857, 204) = 16737131 Then
            Sleep(2200)
            MouseMove(791, 710, 0)
            MouseClick("left", 791, 710, 2)
        EndIf
        While PixelGetColor(922, 41) = 0x000000
            Sleep(2000)
        WEnd
        Sleep(2000)
        CameraSetup()
    EndIf
EndFunc   ;==>charselect

Func Reconnect()
    Sleep(8000)
    Run("C:\Program Files\Silkroad\silkroad.exe")
    WinActivate("Silkroad Online Launcher")
    Sleep(250)
    MouseMove(680, 435, 0)
    Sleep(250)
    $Start = PixelSearch(625, 430, 670, 440, 0xFFFFFF)
    If Not @error Then
        Sleep(250)
        MouseClick("Left", 746, 520, 2)
        Sleep(500)
        WinWaitActive("SRO_Client")
        MouseClick("left", 830, 436, 2)
        loginn()
    Else
        Sleep(3000)
        $Start = PixelSearch(625, 430, 670, 440, 0xFFFFFF)
        If Not @error Then
            Sleep(250)
            MouseClick("Left", 746, 520, 2)
            Sleep(500)
            WinWaitActive("SRO_Client")
            MouseClick("left", 830, 436, 2)
            loginn()
        Else
            ProcessClose("Silkroad Online Launcher")
            Sleep(2000)
            Reconnect()
        EndIf
    EndIf
EndFunc   ;==>Reconnect


;------------------------------------Party Functions-------------------------------------------------------------------------------
Func AutoParty()
    ToolTip($BotName & ": Looking for a party", 2, 0)
    Sleep(2000)
    Send("e")
    Sleep(3000)
    MouseClick("Left", 520, 588) ; Next Page
    Sleep(3000)
    MouseClick("Left", 392, 586) ; Auto Match
    Sleep(500)
    MouseClick("Left", 462, 523) ; Click Confirm Button
    Sleep(500)
    Send("e")
    Sleep(1500)
    $autoParty = $autoParty + 1
    If $autoParty = 6 Then
        MakeParty()
    EndIf
EndFunc   ;==>AutoParty

Func MakeParty()
    ToolTip($BotName & ": Making a party", 2, 0)
    Sleep(2000)
    Send("e")
    Sleep(3000)
    MouseClick("Left", 614, 589) ; Form Party
    Sleep(3000)
    MouseClick("Left", 461, 539) ; Click Confirm Button
    Sleep(500)
    Send("e")
    Sleep(1500)
    $PartyLeader = 1
EndFunc   ;==>MakeParty


Func PartyAccept()
    PixelSearch(437, 457, 442, 465, 0x73634A, 1) ;Invite Party Box
    If Not @error Then
        MouseClick("left", 464, 459)
        Sleep(500)
    EndIf
EndFunc   ;==>PartyAccept


;------------------------------------------------------------------------------------------------------------------------------


;------------Wolf--------------------------------------------------------------------------------------------------------------
Func WolfStuff()
    If PixelGetColor(106, 94) <> 0x8C5B00 Then ; If wolf not summoned
        If $WolfBelt = 1 Then
            Send("{F1}")
        EndIf
        If $WolfBelt = 2 Then
            Send("{F2}")
        EndIf
        If $WolfBelt = 3 Then
            Send("{F3}")
        EndIf
        If $WolfBelt = 4 Then
            Send("{F4}")
        EndIf
        Send($WolfKey)
    EndIf
    If PixelGetColor(106, 94) = 0x8C5B00 Then ; If wolf is summoned then
        If (PixelGetColor(152, 93) <> 16766546) Then
            If $HGPBelt = 1 Then
                Send("{F1}")
            EndIf
            If $HGPBelt = 2 Then
                Send("{F2}")
            EndIf
            If $HGPBelt = 3 Then
                Send("{F3}")
            EndIf
            If $HGPBelt = 4 Then
                Send("{F4}")
            EndIf
            Send($HGPKey)
            Sleep(1000)
        EndIf

        If (PixelGetColor(152, 87) <> 16724273) Then
            If $WolfHPBelt = 1 Then
                Send("{F1}")
            EndIf
            If $WolfHPBelt = 2 Then
                Send("{F2}")
            EndIf
            If $WolfHPBelt = 3 Then
                Send("{F3}")
            EndIf
            If $WolfHPBelt = 4 Then
                Send("{F4}")
            EndIf
            Send($WolfHPKey)
            Sleep(1000)
        EndIf
    EndIf
EndFunc   ;==>WolfStuff


;---------------------Monster Search--------------------------------------------------------------------------------------------
Func CheckMonster()
    $CastSkill = 0
    $fight = PixelSearch(437, 44, 439, 46, 0xFFC6C6, 10) ; Check Monster HP
    If Not @error Then
        Attack()
    EndIf
    $MonsterLightNotFound = 0
    ;MONSTRZ light
    MonsterNearCheck()
    $fight = PixelSearch(437, 44, 439, 46, 0xFFC6C6, 10) ; Check Monster HP
    If Not @error Then
        Attack()
    EndIf
    $fight = PixelSearch(437, 44, 439, 46, 0xFFC6C6, 10) ; Check Monster HP
    If Not @error Then
        Attack()
    EndIf
    $coord = PixelSearch(672, 220, 953, 676, 0xFF00FF, 25, 0)
    If Not @error Then
        MouseClick("left", $coord[0] + 5, $coord[1] + 5, 1, 0)
        Attack()
    Else
        $fight = PixelSearch(437, 44, 439, 46, 0xFFC6C6, 10) ; Check Monster HP
        If Not @error Then
            Attack()
        EndIf
        $coord = PixelSearch(127, 220, 361, 539, 0xFF00FF, 25, 0)
        If Not @error Then
            MouseClick("left", $coord[0] + 5, $coord[1] + 5, 1, 0)
            Attack()
        Else
            MonsterNearCheck()
            $fight = PixelSearch(437, 44, 439, 46, 0xFFC6C6, 10) ; Check Monster HP
            If Not @error Then
                Attack()
            EndIf
            $coord = PixelSearch(125, 79, 362, 219, 0xFF00FF, 25, 0)
            If Not @error Then
                MouseClick("left", $coord[0] + 2, $coord[1] + 2, 1, 0)
                Attack()
            Else
                $fight = PixelSearch(437, 44, 439, 46, 0xFFC6C6, 10) ; Check Monster HP
                If Not @error Then
                    Attack()
                EndIf
                $coord = PixelSearch(671, 78, 894, 220, 0xFF00FF, 25, 0)
                If Not @error Then
                    MouseClick("left", $coord[0] + 2, $coord[1] + 2, 1, 0)
                    Attack()
                Else
                    $MonsterLightNotFound = 1
                    $MonsterNotFound = $MonsterNotFound + 1
                EndIf
            EndIf
        EndIf
    EndIf

    If $MonsterNotFound = 5 Then
        Send("{right down}") ;Holds the A key down
        Sleep(500)
        Send("{right up}") ;Releases the A key
        Send("{up down}")
        Sleep(4000)
        Send("{up up}")
        $MonsterNotFound = 0
    EndIf

    If $MonsterLightNotFound = 1 Then
        ;MONSTRZ dark
        MonsterNearCheck()
        $fight = PixelSearch(437, 44, 439, 46, 0xFFC6C6, 10) ; Check Monster HP
        If Not @error Then
            Attack()
        EndIf
        $coord = PixelSearch(672, 220, 953, 676, 0x5E006D, 25, 0)
        If Not @error Then
            MouseClick("left", $coord[0] + 5, $coord[1] + 5, 1, 0)
            Attack()
        Else
            $fight = PixelSearch(437, 44, 439, 46, 0xFFC6C6, 10) ; Check Monster HP
            If Not @error Then
                Attack()
            EndIf
            $coord = PixelSearch(127, 220, 361, 539, 0x5E006D, 25, 0)
            If Not @error Then
                MouseClick("left", $coord[0] + 5, $coord[1] + 5, 1, 0)
                Attack()
            Else
                MonsterNearCheck()
                $fight = PixelSearch(437, 44, 439, 46, 0xFFC6C6, 10) ; Check Monster HP
                If Not @error Then
                    Attack()
                EndIf
                $coord = PixelSearch(125, 79, 362, 219, 0x5E006D, 25, 0)
                If Not @error Then
                    MouseClick("left", $coord[0] + 2, $coord[1] + 2, 1, 0)
                    Attack()
                Else
                    $fight = PixelSearch(437, 44, 439, 46, 0xFFC6C6, 10) ; Check Monster HP
                    If Not @error Then
                        Attack()
                    EndIf
                    $coord = PixelSearch(671, 78, 894, 220, 0x5E006D, 25, 0)
                    If Not @error Then
                        MouseClick("left", $coord[0] + 2, $coord[1] + 2, 1, 0)
                        Attack()
                    EndIf
                    $fight = PixelSearch(437, 44, 439, 46, 0xFFC6C6, 10) ; Check Monster HP
                    If Not @error Then
                        Attack()
                    EndIf
                EndIf
            EndIf
        EndIf

    EndIf
EndFunc   ;==>CheckMonster

Func MonsterNearCheck()
    ;Monster Light
    $fight = PixelSearch(437, 44, 439, 46, 0xFFC6C6, 10) ; Check Monster HP
    If Not @error Then
        Attack()
    EndIf
    $coord = PixelSearch(364, 444, 671, 714, 0xFF00FF, 25, 0)
    If Not @error Then
        MouseClick("left", $coord[0] + 10, $coord[1] + 10, 1, 0)
        Attack()
    Else
        $fight = PixelSearch(437, 44, 439, 46, 0xFFC6C6, 10) ; Check Monster HP
        If Not @error Then
            Attack()
        EndIf
        $coord = PixelSearch(362, 78, 671, 442, 0xFF00FF, 25, 0)
        If Not @error Then
            MouseClick("left", $coord[0] + 5, $coord[1] + 5, 1, 0)
            Attack()
        Else
            ;Monster Dark
            $fight = PixelSearch(437, 44, 439, 46, 0xFFC6C6, 10) ; Check Monster HP
            If Not @error Then
                Attack()
            EndIf
            $coord = PixelSearch(364, 444, 671, 714, 0x5E006D, 25, 0)
            If Not @error Then
                MouseClick("left", $coord[0] + 10, $coord[1] + 10, 1, 0)
                Attack()
            Else
                $fight = PixelSearch(437, 44, 439, 46, 0xFFC6C6, 10) ; Check Monster HP
                If Not @error Then
                    Attack()
                EndIf
                $coord = PixelSearch(362, 78, 671, 442, 0x5E006D, 25, 0)
                If Not @error Then
                    MouseClick("left", $coord[0] + 5, $coord[1] + 5, 1, 0)
                    Attack()
                EndIf
                $fight = PixelSearch(437, 44, 439, 46, 0xFFC6C6, 10) ; Check Monster HP
                If Not @error Then
                    Attack()
                EndIf
            EndIf
        EndIf
    EndIf
EndFunc   ;==>MonsterNearCheck

Func NuBotSearch()
    $fight = PixelSearch(437, 44, 439, 46, 0xFFC6C6, 10) ; Check Monster HP
    If Not @error Then
        Attack()
    Else
        Sleep(500)
    EndIf
EndFunc   ;==>NuBotSearch

;-----------------------------------------------------------------------------------------------------------------------------

Func RunAway()
    Send("{up down}")
    Sleep(8000)
    Send("{up up}")
    MouseClick("Left", 598, 24)
EndFunc   ;==>RunAway


;--------------------Attack and pickup-------------------------------------------------------------------------------------------
Func Attack()
    ToolTip($BotName & ": Checking Mob", 2, 0)
    If $UseBeserkWhen = "Ready" Then
        PixelSearch(18, 4, 35, 16, 0xFFC3ED, 15)
        If Not @error Then
            Send("{TAB}")
        EndIf
    EndIf
    While $MonsterDead <> 1
        $fight = PixelSearch(437, 44, 439, 46, 0xFFC6C6, 10) ; Check Monster HP
        If Not @error Then
            $stuck = TimerInit()


            ToolTip($BotName & ": Checking Mob Lvl...", 2, 0)
            ;1st lvl mob
            $mobcolor = PixelSearch(434, 18, 444, 25, 0x084364, 20)
            If Not @error Then
                $Monsterlvl = 1
                $champion = PixelGetColor(495, 69)
                $giant = PixelGetColor(496, 70)
                If $champion = 1642577 Then
                    $MonsterChamp = 1
                Else
                    $MonsterChamp = 0
                EndIf
                If $giant = 543364 Then
                    $MonsterGiant = 1
                Else
                    $MonsterGiant = 0
                EndIf
                $tookmoblvl = 1
            EndIf
            $mobcolor = PixelSearch(434, 18, 444, 25, 0x2A7855, 20)
            ;2nd lvl mob
            If Not @error Then
                $Monsterlvl = 2
                $champion = PixelGetColor(495, 69)
                $giant = PixelGetColor(496, 70)
                If $champion = 1642577 Then
                    $MonsterChamp = 1
                Else
                    $MonsterChamp = 0
                EndIf
                If $giant = 543364 Then
                    $MonsterGiant = 1
                Else
                    $MonsterGiant = 0
                EndIf
                $tookmoblvl = 1
            EndIf
            $mobcolor = PixelSearch(434, 18, 444, 25, 0x717171, 20)
            ;3rd lvl mob
            If Not @error Then
                $Monsterlvl = 3
                $champion = PixelGetColor(495, 69)
                $giant = PixelGetColor(496, 70)
                If $champion = 1642577 Then
                    $MonsterChamp = 1
                Else
                    $MonsterChamp = 0
                EndIf
                If $giant = 543364 Then
                    $MonsterGiant = 1
                Else
                    $MonsterGiant = 0
                EndIf
                $tookmoblvl = 1
            EndIf
            $mobcolor = PixelSearch(435, 18, 442, 25, 15644512, 20)
            ;4th lvl mob
            If Not @error Then
                $Monsterlvl = 4
                $champion = PixelGetColor(495, 69)
                $giant = PixelGetColor(496, 70)
                If $champion = 1642577 Then
                    $MonsterChamp = 1
                Else
                    $MonsterChamp = 0
                EndIf
                If $giant = 543364 Then
                    $MonsterGiant = 1
                Else
                    $MonsterGiant = 0
                EndIf
                $tookmoblvl = 1
            EndIf
            $mobcolor = PixelSearch(435, 18, 442, 25, 14832443, 20)
            ;5th lvl mob
            If Not @error Then
                $Monsterlvl = 5
                $champion = PixelGetColor(495, 69)
                $giant = PixelGetColor(496, 70)
                If $champion = 1642577 Then
                    $MonsterChamp = 1
                Else
                    $MonsterChamp = 0
                EndIf
                If $giant = 543364 Then
                    $MonsterGiant = 1
                Else
                    $MonsterGiant = 0
                EndIf
                $tookmoblvl = 1
                If $Monsterlvl = 0 Then
                    NormalAttack()
                EndIf
            EndIf
            ToolTip($BotName & ": Attacking...", 2, 0)

            ;-------------------LVL 1 MOB--------------------------------------------------------------------------------------------

            If $BlueSkills > $CastSkill Then
                $RandomSkill = Random(1, 5, 1)
                If $UseSkill1 = 1 Then
                    If $RandomSkill = 1 Then
                        If $Skill1Belt = 1 Then
                            Send("{F1}")
                        EndIf
                        If $Skill1Belt = 2 Then
                            Send("{F2}")
                        EndIf
                        If $Skill1Belt = 3 Then
                            Send("{F3}")
                        EndIf
                        If $Skill1Belt = 4 Then
                            Send("{F4}")
                        EndIf
                        Send($Skill1Key)
                        Sleep(500)
                        $CastSkill = $CastSkill + 1
                    EndIf
                EndIf

                If $UseSkill2 = 1 Then
                    If $RandomSkill = 2 Then
                        If $Skill2Belt = 1 Then
                            Send("{F1}")
                        EndIf
                        If $Skill2Belt = 2 Then
                            Send("{F2}")
                        EndIf
                        If $Skill2Belt = 3 Then
                            Send("{F3}")
                        EndIf
                        If $Skill2Belt = 4 Then
                            Send("{F4}")
                        EndIf
                        Send($Skill2Key)
                        Sleep(500)
                        $CastSkill = $CastSkill + 1
                    EndIf
                EndIf

                If $UseSkill3 = 1 Then
                    If $RandomSkill = 3 Then
                        If $Skill3Belt = 1 Then
                            Send("{F1}")
                        EndIf
                        If $Skill3Belt = 2 Then
                            Send("{F2}")
                        EndIf
                        If $Skill3Belt = 3 Then
                            Send("{F3}")
                        EndIf
                        If $Skill3Belt = 4 Then
                            Send("{F4}")
                        EndIf
                        Send($Skill3Key)
                        Sleep(500)
                        $CastSkill = $CastSkill + 1
                    EndIf

                    If $RandomSkill = 4 Then
                        If $Skill4Belt = 1 Then
                            Send("{F1}")
                        EndIf
                        If $Skill4Belt = 2 Then
                            Send("{F2}")
                        EndIf
                        If $Skill4Belt = 3 Then
                            Send("{F3}")
                        EndIf
                        If $Skill4Belt = 4 Then
                            Send("{F4}")
                        EndIf
                        Send($Skill4Key)
                        Sleep(500)
                        $CastSkill = $CastSkill + 1
                    EndIf
                EndIf

                If $UseSkill5 = 1 Then
                    If $RandomSkill = 5 Then
                        If $Skill5Belt = 1 Then
                            Send("{F1}")
                        EndIf
                        If $Skill5Belt = 2 Then
                            Send("{F2}")
                        EndIf
                        If $Skill5Belt = 3 Then
                            Send("{F3}")
                        EndIf
                        If $Skill5Belt = 4 Then
                            Send("{F4}")
                        EndIf
                        Send($Skill5Key)
                        Sleep(500)
                        $CastSkill = $CastSkill + 1
                    EndIf
                EndIf
            EndIf
            If $Monsterlvl = 1 Then
                If $ImbueBelt = 1 Then
                    Send("{F1}")
                    Send($ImbueKey)
                    Sleep(500)
                EndIf
                If $ImbueBelt = 2 Then
                    Send("{F2}")
                    Send($ImbueKey)
                    Sleep(500)
                EndIf
                If $ImbueBelt = 3 Then
                    Send("{F3}")
                    Send($ImbueKey)
                    Sleep(500)
                EndIf
                If $ImbueBelt = 4 Then
                    Send("{F4}")
                    Send($ImbueKey)
                    Sleep(500)
                EndIf

                If $AttackBelt = 1 Then
                    Send("{F1}")
                    Send($AttackKey)
                    Sleep(500)
                EndIf
                If $AttackBelt = 2 Then
                    Send("{F2}")
                    Send($AttackKey)
                    Sleep(500)
                EndIf
                If $AttackBelt = 3 Then
                    Send("{F3}")
                    Send($AttackKey)
                    Sleep(500)
                EndIf
                If $AttackBelt = 4 Then
                    Send("{F4}")
                    Send($AttackKey)
                    Sleep(500)
                EndIf
            EndIf


            ;-------------------LVL 2 MOB--------------------------------------------------------------------------------------------
            If $Monsterlvl = 2 Then
                If $MonsterChamp = 1 Then
                    $GreenSkills = $GreenSkills + $ChampSkills
                EndIf
                If $MonsterGiant = 1 Then
                    $GreenSkills = $GreenSkills + $GiantSkills
                EndIf
                If $GreenSkills > $CastSkill Then
                    $RandomSkill = Random(1, 5, 1)
                    If $UseSkill1 = 1 Then
                        If $RandomSkill = 1 Then
                            If $Skill1Belt = 1 Then
                                Send("{F1}")
                            EndIf
                            If $Skill1Belt = 2 Then
                                Send("{F2}")
                            EndIf
                            If $Skill1Belt = 3 Then
                                Send("{F3}")
                            EndIf
                            If $Skill1Belt = 4 Then
                                Send("{F4}")
                            EndIf
                            Send($Skill1Key)
                            Sleep(500)
                            $CastSkill = $CastSkill + 1
                        EndIf
                    EndIf

                    If $UseSkill2 = 1 Then
                        If $RandomSkill = 2 Then
                            If $Skill2Belt = 1 Then
                                Send("{F1}")
                            EndIf
                            If $Skill2Belt = 2 Then
                                Send("{F2}")
                            EndIf
                            If $Skill2Belt = 3 Then
                                Send("{F3}")
                            EndIf
                            If $Skill2Belt = 4 Then
                                Send("{F4}")
                            EndIf
                            Send($Skill2Key)
                            Sleep(500)
                            $CastSkill = $CastSkill + 1
                        EndIf
                    EndIf

                    If $UseSkill3 = 1 Then
                        If $RandomSkill = 3 Then
                            If $Skill3Belt = 1 Then
                                Send("{F1}")
                            EndIf
                            If $Skill3Belt = 2 Then
                                Send("{F2}")
                            EndIf
                            If $Skill3Belt = 3 Then
                                Send("{F3}")
                            EndIf
                            If $Skill3Belt = 4 Then
                                Send("{F4}")
                            EndIf
                            Send($Skill3Key)
                            Sleep(500)
                            $CastSkill = $CastSkill + 1
                        EndIf
                    EndIf

                    If $UseSkill4 = 1 Then
                        If $RandomSkill = 4 Then
                            If $Skill4Belt = 1 Then
                                Send("{F1}")
                            EndIf
                            If $Skill4Belt = 2 Then
                                Send("{F2}")
                            EndIf
                            If $Skill4Belt = 3 Then
                                Send("{F3}")
                            EndIf
                            If $Skill4Belt = 4 Then
                                Send("{F4}")
                            EndIf
                            Send($Skill4Key)
                            Sleep(500)
                            $CastSkill = $CastSkill + 1
                        EndIf
                    EndIf

                    If $UseSkill5 = 1 Then
                        If $RandomSkill = 5 Then
                            If $Skill5Belt = 1 Then
                                Send("{F1}")
                            EndIf
                            If $Skill5Belt = 2 Then
                                Send("{F2}")
                            EndIf
                            If $Skill5Belt = 3 Then
                                Send("{F3}")
                            EndIf
                            If $Skill5Belt = 4 Then
                                Send("{F4}")
                            EndIf
                            Send($Skill5Key)
                            Sleep(500)
                            $CastSkill = $CastSkill + 1
                        EndIf
                    EndIf
                EndIf
                If $ImbueBelt = 1 Then
                    Send("{F1}")
                    Send($ImbueKey)
                    Sleep(500)
                EndIf
                If $ImbueBelt = 2 Then
                    Send("{F2}")
                    Send($ImbueKey)
                    Sleep(500)
                EndIf
                If $ImbueBelt = 3 Then
                    Send("{F3}")
                    Send($ImbueKey)
                    Sleep(500)
                EndIf
                If $ImbueBelt = 4 Then
                    Send("{F4}")
                    Send($ImbueKey)
                    Sleep(500)
                EndIf
                If $AttackBelt = 1 Then
                    Send("{F1}")
                    Send($AttackKey)
                    Sleep(500)
                EndIf
                If $AttackBelt = 2 Then
                    Send("{F2}")
                    Send($AttackKey)
                    Sleep(500)
                EndIf
                If $AttackBelt = 3 Then
                    Send("{F3}")
                    Send($AttackKey)
                    Sleep(500)
                EndIf
                If $AttackBelt = 4 Then
                    Send("{F4}")
                    Send($AttackKey)
                    Sleep(500)
                EndIf
            EndIf


            ;-------------------LVL 3 MOB--------------------------------------------------------------------------------------------
            If $Monsterlvl = 3 Then
                If $MonsterChamp = 1 Then
                    $WhiteSkills = $WhiteSkills + $ChampSkills
                EndIf
                If $MonsterGiant = 1 Then
                    $WhiteSkills = $WhiteSkills + $GiantSkills
                EndIf
                If $WhiteSkills > $CastSkill Then
                    $RandomSkill = Random(1, 5, 1)
                    If $UseSkill1 = 1 Then
                        If $RandomSkill = 1 Then
                            If $Skill1Belt = 1 Then
                                Send("{F1}")
                            EndIf
                            If $Skill1Belt = 2 Then
                                Send("{F2}")
                            EndIf
                            If $Skill1Belt = 3 Then
                                Send("{F3}")
                            EndIf
                            If $Skill1Belt = 4 Then
                                Send("{F4}")
                            EndIf
                            Send($Skill1Key)
                            Sleep(500)
                            $CastSkill = $CastSkill + 1
                        EndIf
                    EndIf

                    If $UseSkill2 = 1 Then
                        If $RandomSkill = 2 Then
                            If $Skill2Belt = 1 Then
                                Send("{F1}")
                            EndIf
                            If $Skill2Belt = 2 Then
                                Send("{F2}")
                            EndIf
                            If $Skill2Belt = 3 Then
                                Send("{F3}")
                            EndIf
                            If $Skill2Belt = 4 Then
                                Send("{F4}")
                            EndIf
                            Send($Skill2Key)
                            Sleep(500)
                            $CastSkill = $CastSkill + 1
                        EndIf
                    EndIf

                    If $UseSkill3 = 1 Then
                        If $RandomSkill = 3 Then
                            If $Skill3Belt = 1 Then
                                Send("{F1}")
                            EndIf
                            If $Skill3Belt = 2 Then
                                Send("{F2}")
                            EndIf
                            If $Skill3Belt = 3 Then
                                Send("{F3}")
                            EndIf
                            If $Skill3Belt = 4 Then
                                Send("{F4}")
                            EndIf
                            Send($Skill3Key)
                            Sleep(500)
                            $CastSkill = $CastSkill + 1
                        EndIf
                    EndIf

                    If $UseSkill4 = 1 Then
                        If $RandomSkill = 4 Then
                            If $Skill4Belt = 1 Then
                                Send("{F1}")
                            EndIf
                            If $Skill4Belt = 2 Then
                                Send("{F2}")
                            EndIf
                            If $Skill4Belt = 3 Then
                                Send("{F3}")
                            EndIf
                            If $Skill4Belt = 4 Then
                                Send("{F4}")
                            EndIf
                            Send($Skill4Key)
                            Sleep(500)
                            $CastSkill = $CastSkill + 1
                        EndIf
                    EndIf

                    If $UseSkill5 = 1 Then
                        If $RandomSkill = 5 Then
                            If $Skill5Belt = 1 Then
                                Send("{F1}")
                            EndIf
                            If $Skill5Belt = 2 Then
                                Send("{F2}")
                            EndIf
                            If $Skill5Belt = 3 Then
                                Send("{F3}")
                            EndIf
                            If $Skill5Belt = 4 Then
                                Send("{F4}")
                            EndIf
                            Send($Skill5Key)
                            Sleep(500)
                            $CastSkill = $CastSkill + 1
                        EndIf
                    EndIf
                EndIf
                If $ImbueBelt = 1 Then
                    Send("{F1}")
                    Send($ImbueKey)
                    Sleep(500)
                EndIf
                If $ImbueBelt = 2 Then
                    Send("{F2}")
                    Send($ImbueKey)
                    Sleep(500)
                EndIf
                If $ImbueBelt = 3 Then
                    Send("{F3}")
                    Send($ImbueKey)
                    Sleep(500)
                EndIf
                If $ImbueBelt = 4 Then
                    Send("{F4}")
                    Send($ImbueKey)
                    Sleep(500)
                EndIf
                If $AttackBelt = 1 Then
                    Send("{F1}")
                    Send($AttackKey)
                    Sleep(500)
                EndIf
                If $AttackBelt = 2 Then
                    Send("{F2}")
                    Send($AttackKey)
                    Sleep(500)
                EndIf
                If $AttackBelt = 3 Then
                    Send("{F3}")
                    Send($AttackKey)
                    Sleep(500)
                EndIf
                If $AttackBelt = 4 Then
                    Send("{F4}")
                    Send($AttackKey)
                    Sleep(500)
                EndIf
            EndIf


            ;-------------------LVL 4 MOB--------------------------------------------------------------------------------------------
            If $Monsterlvl = 4 Then
                If $MonsterChamp = 1 Then
                    $OrangeSkills = $OrangeSkills + $ChampSkills
                EndIf
                If $MonsterGiant = 1 Then
                    $OrangeSkills = $OrangeSkills + $GiantSkills
                EndIf
                If $OrangeSkills > $CastSkill Then
                    $RandomSkill = Random(1, 5, 1)
                    If $UseSkill1 = 1 Then
                        If $RandomSkill = 1 Then
                            If $Skill1Belt = 1 Then
                                Send("{F1}")
                            EndIf
                            If $Skill1Belt = 2 Then
                                Send("{F2}")
                            EndIf
                            If $Skill1Belt = 3 Then
                                Send("{F3}")
                            EndIf
                            If $Skill1Belt = 4 Then
                                Send("{F4}")
                            EndIf
                            Send($Skill1Key)
                            Sleep(500)
                            $CastSkill = $CastSkill + 1
                        EndIf
                    EndIf

                    If $UseSkill2 = 1 Then
                        If $RandomSkill = 2 Then
                            If $Skill2Belt = 1 Then
                                Send("{F1}")
                            EndIf
                            If $Skill2Belt = 2 Then
                                Send("{F2}")
                            EndIf
                            If $Skill2Belt = 3 Then
                                Send("{F3}")
                            EndIf
                            If $Skill2Belt = 4 Then
                                Send("{F4}")
                            EndIf
                            Send($Skill2Key)
                            Sleep(500)
                            $CastSkill = $CastSkill + 1
                        EndIf
                    EndIf

                    If $UseSkill3 = 1 Then
                        If $RandomSkill = 3 Then
                            If $Skill3Belt = 1 Then
                                Send("{F1}")
                            EndIf
                            If $Skill3Belt = 2 Then
                                Send("{F2}")
                            EndIf
                            If $Skill3Belt = 3 Then
                                Send("{F3}")
                            EndIf
                            If $Skill3Belt = 4 Then
                                Send("{F4}")
                            EndIf
                            Send($Skill3Key)
                            Sleep(500)
                            $CastSkill = $CastSkill + 1
                        EndIf
                    EndIf

                    If $UseSkill4 = 1 Then
                        If $RandomSkill = 4 Then
                            If $Skill4Belt = 1 Then
                                Send("{F1}")
                            EndIf
                            If $Skill4Belt = 2 Then
                                Send("{F2}")
                            EndIf
                            If $Skill4Belt = 3 Then
                                Send("{F3}")
                            EndIf
                            If $Skill4Belt = 4 Then
                                Send("{F4}")
                            EndIf
                            Send($Skill4Key)
                            Sleep(500)
                            $CastSkill = $CastSkill + 1
                        EndIf
                    EndIf

                    If $UseSkill5 = 1 Then
                        If $RandomSkill = 5 Then
                            If $Skill5Belt = 1 Then
                                Send("{F1}")
                            EndIf
                            If $Skill5Belt = 2 Then
                                Send("{F2}")
                            EndIf
                            If $Skill5Belt = 3 Then
                                Send("{F3}")
                            EndIf
                            If $Skill5Belt = 4 Then
                                Send("{F4}")
                            EndIf
                            Send($Skill5Key)
                            Sleep(500)
                            $CastSkill = $CastSkill + 1
                        EndIf
                    EndIf
                EndIf
                If $ImbueBelt = 1 Then
                    Send("{F1}")
                    Send($ImbueKey)
                    Sleep(500)
                EndIf
                If $ImbueBelt = 2 Then
                    Send("{F2}")
                    Send($ImbueKey)
                    Sleep(500)
                EndIf
                If $ImbueBelt = 3 Then
                    Send("{F3}")
                    Send($ImbueKey)
                    Sleep(500)
                EndIf
                If $ImbueBelt = 4 Then
                    Send("{F4}")
                    Send($ImbueKey)
                    Sleep(500)
                EndIf
                If $AttackBelt = 1 Then
                    Send("{F1}")
                    Send($AttackKey)
                    Sleep(500)
                EndIf
                If $AttackBelt = 2 Then
                    Send("{F2}")
                    Send($AttackKey)
                    Sleep(500)
                EndIf
                If $AttackBelt = 3 Then
                    Send("{F3}")
                    Send($AttackKey)
                    Sleep(500)
                EndIf
                If $AttackBelt = 4 Then
                    Send("{F4}")
                    Send($AttackKey)
                    Sleep(500)
                EndIf
            EndIf


            ;-------------------LVL 5 MOB--------------------------------------------------------------------------------------------
            If $Monsterlvl = 5 Then
                If $RunFromRed = 1 Then
                    RunAway()
                Else
                    If $MonsterChamp = 1 Then
                        $RedSkills = $RedSkills + $ChampSkills
                    EndIf
                    If $MonsterGiant = 1 Then
                        $RedSkills = $RedSkills + $GiantSkills
                    EndIf
                    If $RedSkills > $CastSkill Then
                        $RandomSkill = Random(1, 5, 1)
                        If $UseSkill1 = 1 Then
                            If $RandomSkill = 1 Then
                                If $Skill1Belt = 1 Then
                                    Send("{F1}")
                                EndIf
                                If $Skill1Belt = 2 Then
                                    Send("{F2}")
                                EndIf
                                If $Skill1Belt = 3 Then
                                    Send("{F3}")
                                EndIf
                                If $Skill1Belt = 4 Then
                                    Send("{F4}")
                                EndIf
                                Send($Skill1Key)
                                $CastSkill = $CastSkill + 1
                            EndIf
                        EndIf
                    EndIf

                    If $UseSkill2 = 1 Then
                        If $RandomSkill = 2 Then
                            If $Skill2Belt = 1 Then
                                Send("{F1}")
                            EndIf
                            If $Skill2Belt = 2 Then
                                Send("{F2}")
                            EndIf
                            If $Skill2Belt = 3 Then
                                Send("{F3}")
                            EndIf
                            If $Skill2Belt = 4 Then
                                Send("{F4}")
                            EndIf
                            Send($Skill2Key)
                            $CastSkill = $CastSkill + 1
                        EndIf
                    EndIf

                    If $UseSkill3 = 1 Then
                        If $RandomSkill = 3 Then
                            If $Skill3Belt = 1 Then
                                Send("{F1}")
                            EndIf
                            If $Skill3Belt = 2 Then
                                Send("{F2}")
                            EndIf
                            If $Skill3Belt = 3 Then
                                Send("{F3}")
                            EndIf
                            If $Skill3Belt = 4 Then
                                Send("{F4}")
                            EndIf
                            Send($Skill3Key)
                            $CastSkill = $CastSkill + 1
                        EndIf
                    EndIf

                    If $UseSkill5 = 1 Then
                        If $RandomSkill = 4 Then
                            If $Skill4Belt = 1 Then
                                Send("{F1}")
                            EndIf
                            If $Skill4Belt = 2 Then
                                Send("{F2}")
                            EndIf
                            If $Skill4Belt = 3 Then
                                Send("{F3}")
                            EndIf
                            If $Skill4Belt = 4 Then
                                Send("{F4}")
                            EndIf
                            Send($Skill4Key)
                            $CastSkill = $CastSkill + 1
                        EndIf
                    EndIf

                    If $UseSkill5 = 1 Then
                        If $RandomSkill = 5 Then
                            If $Skill5Belt = 1 Then
                                Send("{F1}")
                            EndIf
                            If $Skill5Belt = 2 Then
                                Send("{F2}")
                            EndIf
                            If $Skill5Belt = 3 Then
                                Send("{F3}")
                            EndIf
                            If $Skill5Belt = 4 Then
                                Send("{F4}")
                            EndIf
                            Send($Skill5Key)
                            $CastSkill = $CastSkill + 1
                        EndIf
                    EndIf
                EndIf
                If $ImbueBelt = 1 Then
                    Send("{F1}")
                    Send($ImbueKey)
                    Sleep(500)
                EndIf
                If $ImbueBelt = 2 Then
                    Send("{F2}")
                    Send($ImbueKey)
                    Sleep(500)
                EndIf
                If $ImbueBelt = 3 Then
                    Send("{F3}")
                    Send($ImbueKey)
                    Sleep(500)
                EndIf
                If $ImbueBelt = 4 Then
                    Send("{F4}")
                    Send($ImbueKey)
                    Sleep(500)
                EndIf
                If $AttackBelt = 1 Then
                    Send("{F1}")
                    Send($AttackKey)
                    Sleep(500)
                EndIf
                If $AttackBelt = 2 Then
                    Send("{F2}")
                    Send($AttackKey)
                    Sleep(500)
                EndIf
                If $AttackBelt = 3 Then
                    Send("{F3}")
                    Send($AttackKey)
                    Sleep(500)
                EndIf
                If $AttackBelt = 4 Then
                    Send("{F4}")
                    Send($AttackKey)
                    Sleep(500)
                EndIf
            EndIf
        Else
            $MonsterDead = 1
            Pickup()
        EndIf
        If TimerDiff($Timer1) > 35000 Then
            If PixelGetColor(539, 494) = 0xFEFBD8 Then
                ToolTip($BotName & ": You Died ", 2, 0)
                CheckIfDead()
            EndIf
        EndIf
        If PixelGetColor(419, 138) = 0xFFFFFF And PixelGetColor(480, 139) = 0xFFFFFF And PixelGetColor(595, 138) = 0xFFFFFF Then
            Stuck()
        EndIf
    WEnd
EndFunc   ;==>Attack





Func NormalAttack()
    ToolTip($BotName & ": Fighting...", 2, 0)
    While $MonsterDead <> 1
        $fight = PixelSearch(437, 44, 439, 46, 0xFFC6C6, 10)
        If Not @error Then
            If $AttackBelt = 1 Then
                Send("{F1}")
                Send($AttackKey)
            EndIf
            If $AttackBelt = 2 Then
                Send("{F2}")
                Send($AttackKey)
            EndIf
            If $AttackBelt = 3 Then
                Send("{F3}")
                Send($AttackKey)
            EndIf
            If $AttackBelt = 4 Then
                Send("{F4}")
                Send($AttackKey)
            EndIf
            If $ImbueBelt = 1 Then
                Send("{F1}")
                Send($ImbueKey)
            EndIf
            If $ImbueBelt = 2 Then
                Send("{F2}")
                Send($ImbueKey)
            EndIf
            If $ImbueBelt = 3 Then
                Send("{F3}")
                Send($ImbueKey)
            EndIf
            If $ImbueBelt = 4 Then
                Send("{F4}")
                Send($ImbueKey)
            EndIf
        Else
            $MonsterDead = 1
            Pickup()
        EndIf
    WEnd
EndFunc   ;==>NormalAttack


Func Pickup()
    $Monsterlvl = 0
    $tookmoblvl = 0
    If $NuBotPickup = 0 Then
        If $PickUpItems = 1 Then
            $ItemSearch = PixelSearch(375, 287, 665, 506, 0x00FFFF, 4)
            If Not @error Then
                MouseClick("Left", $ItemSearch[0], $ItemSearch[1], 2)
            EndIf
            Sleep(450)
            Send("gg")
            Send("gg")
            Sleep(250)
            Send("gg")
            Send("gg")
            Sleep(100)
            Send("gg")
            Send("gg")
            Sleep(100)
            Send("gg")
            Send("gg")
            Sleep(100)
            Send("gg")
            Send("gg")
            Sleep(100)
            Send("gg")
            Send("gg")
        ElseIf $NuBotPickup = 1 Then
            Sleep(1000)
        EndIf
    EndIf
EndFunc   ;==>Pickup


;------------------------------------------------------------------------------------------------------------------------------

;----------------------------------BUFF----------------------------------------------------------------------------------------
Func Buff()
    If $UseBuff1 = 1 Then
        If TimerDiff($Buff1Timer) > $Buff1Delay + 1000 Then
            If $Buff1Belt = 1 Then
                Send("{F1}")
            EndIf
            If $Buff1Belt = 2 Then
                Send("{F2}")
            EndIf
            If $Buff1Belt = 3 Then
                Send("{F3}")
            EndIf
            If $Buff1Belt = 4 Then
                Send("{F4}")
            EndIf
            Send($Buff1key)
            Sleep(2500)
            $Buff1Timer = TimerInit()
        EndIf
    EndIf
    If $UseBuff2 = 1 Then
        If TimerDiff($Buff2Timer) > $Buff2Delay + 2000 Then
            If $Buff2Belt = 1 Then
                Send("{F1}")
            EndIf
            If $Buff2Belt = 2 Then
                Send("{F2}")
            EndIf
            If $Buff2Belt = 3 Then
                Send("{F3}")
            EndIf
            If $Buff2Belt = 4 Then
                Send("{F4}")
            EndIf
            Send($Buff2Key)
            Sleep(2500)
            $Buff2Timer = TimerInit()
        EndIf
    EndIf
    If $UseBuff3 = 1 Then
        If TimerDiff($Buff3Timer) > $Buff3Delay + 3000 Then
            If $Buff3Belt = 1 Then
                Send("{F1}")
            EndIf
            If $Buff3Belt = 2 Then
                Send("{F2}")
            EndIf
            If $Buff3Belt = 3 Then
                Send("{F3}")
            EndIf
            If $Buff3Belt = 4 Then
                Send("{F4}")
            EndIf
            Send($Buff3Key)
            Sleep(2500)
            $Buff3Timer = TimerInit()
        EndIf
    EndIf
    If $UseBuff4 = 1 Then
        If TimerDiff($Buff4Timer) > $Buff4Delay + 1500 Then
            If $Buff4Belt = 1 Then
                Send("{F1}")
            EndIf
            If $Buff4Belt = 2 Then
                Send("{F2}")
            EndIf
            If $Buff4Belt = 3 Then
                Send("{F3}")
            EndIf
            If $Buff4Belt = 4 Then
                Send("{F4}")
            EndIf
            Send($Buff4Key)
            Sleep(2500)
            $Buff4Timer = TimerInit()
        EndIf
    EndIf
    If $UseBuff5 = 1 Then
        If TimerDiff($Buff5Timer) > $Buff5Delay + 2500 Then
            If $Buff5Belt = 1 Then
                Send("{F1}")
            EndIf
            If $Buff5Belt = 2 Then
                Send("{F2}")
            EndIf
            If $Buff5Belt = 3 Then
                Send("{F3}")
            EndIf
            If $Buff5Belt = 4 Then
                Send("{F4}")
            EndIf
            Send($Buff5Key)
            Sleep(2500)
            $Buff5Timer = TimerInit()
        EndIf
    EndIf
EndFunc   ;==>Buff

;------------------------------------------------------------------------------------------------------------------------------

;--------------GoToTown--------------------------------------------------------------------------------------------------------
Func GoToTown()
    MsgBox(64, "Error", "Go To Town hasnt been added yet")
    ;If $X1 = "" Then
    ;MsgBox(64,"Error", "You have not set up the walk to town coords properly")
    ;WalkTo($X1,Y1)
    ;WalkTo($X2,Y2)
EndFunc   ;==>GoToTown

;--------------------------------------------------------------------------------------------------------------------------------

;---------------------------WalkBack--------------------------------------------------------------------------------------------
Func SaveCoords()
    $SavedX = _NCR(923, 34, 950, 45)
    $SavedY = _NCR(982, 34, 1009, 45)
    $Coordsystem = 1
    $walkback = InputBox($BotName, "Walkback, set how far before walkback starts", "", "")
    MsgBox(64, $BotName, "Coords Saved", 3)
EndFunc   ;==>SaveCoords

Func CheckCoords()
    Sleep(1500)
    $CoordX = _NCR(923, 34, 950, 45)
    $FinalX = $SavedX - $CoordX
    If $FinalX < -$walkback Then
        ToolTip($BotName & ": you have wondered off East", 2, 0)
        $east = 1
    EndIf
    If $FinalX > $walkback Then
        ToolTip($BotName & ": you have wondered off West", 2, 0)
        $west = 1
    EndIf

    $CoordY = _NCR(982, 34, 1009, 45)
    $FinalY = $SavedY - $CoordY
    If $FinalY < -$walkback Then
        ToolTip($BotName & ": you have wondered off North", 2, 0)
        $north = 1
    EndIf
    If $FinalY > $walkback Then
        ToolTip($BotName & ": you have wondered off South", 2, 0)
        $south = 1
    EndIf
    Direction()
EndFunc   ;==>CheckCoords

Func Direction()
    $Timer1 = TimerInit()
    If $east = 1 Then
        While 1
            If TimerDiff($Timer1) > 30 * 1000 Then
                Stuck()
                $Timer1 = TimerInit()
            EndIf
            MouseClick("left", 680, 425)
            Sleep(1000)
            ToolTip($BotName & ": walking West ", 2, 0)
            $walkCoord = _NCR(923, 34, 950, 45)
            $TempCoord = $walkCoord - $SavedX
            If $TempCoord > 6 Then
                ToolTip($BotName & ": Keep on walking West ", 2, 0)
            EndIf
            If $TempCoord < -0 Then
                ToolTip($BotName & ": OK, back to training ", 2, 0)
                ExitLoop
            EndIf
        WEnd
    EndIf
    $east = 0
    If $west = 1 Then
        While 1
            If TimerDiff($Timer1) > 30 * 1000 Then
                Stuck()
                $Timer1 = TimerInit()
            EndIf
            MouseClick("left", 350, 425)
            Sleep(1000)
            ToolTip($BotName & ": walking East ", 2, 0)
            $walkCoord = _NCR(923, 34, 950, 45)
            $TempCoord = $walkCoord - $SavedX
            If $TempCoord < -6 Then
                ToolTip($BotName & ": Keep on walking East ", 2, 0)
            EndIf
            If $TempCoord > 0 Then
                ToolTip($BotName & ": OK, back to training ", 2, 0)
                ExitLoop
            EndIf
        WEnd
    EndIf
    $west = 0
    If $north = 1 Then
        While 1
            If TimerDiff($Timer1) > 30 * 1000 Then
                Stuck()
                $Timer1 = TimerInit()
            EndIf
            MouseClick("left", 514, 256)
            Sleep(1000)
            ToolTip($BotName & ": walking South ", 2, 0)
            $walkCoord = _NCR(982, 34, 1009, 45)
            $TempCoord = $walkCoord - $SavedY
            If $TempCoord > 6 Then
                ToolTip($BotName & ": Keep on walking South ", 2, 0)
            EndIf
            If $TempCoord < -0 Then
                ToolTip($BotName & ": OK, back to training ", 2, 0)
                ExitLoop
            EndIf
        WEnd
    EndIf
    $north = 0
    If $south = 1 Then
        While 1
            If TimerDiff($Timer1) > 30 * 1000 Then
                Stuck()
                $Timer1 = TimerInit()
            EndIf
            MouseClick("left", 505, 567)
            Sleep(1000)
            ToolTip($BotName & ": walking North ", 2, 0)
            $walkCoord = _NCR(982, 34, 1009, 45)
            $TempCoord = $walkCoord - $SavedY
            If $TempCoord < -6 Then
                ToolTip($BotName & ": Keep on walking North ", 2, 0)
            EndIf
            If $TempCoord > 0 Then
                ToolTip($BotName & ": OK, back to training ", 2, 0)
                ExitLoop
            EndIf
        WEnd
    EndIf
    $south = 0
EndFunc   ;==>Direction

Func _NCR($Ax, $Ay, $Dx, $Dy)

    $width = $Dx - $Ax
    $length = $Dy - $Ay

    Dim $char[$width][$length]

    For $xwidth = 0 To $width - 1
        For $xlength = 0 To $length - 1
            $char[$xwidth][$xlength] = Hex(PixelGetColor($Ax, $Ay), 6)
            $Ay = $Ay + 1
        Next
        $Ax = $Ax + 1
        $Ay = $Ay - $length
    Next
    ;scans entire area


    $p = 1
    Dim $row[$width]
    For $xwidth = 0 To $width - 1

        For $xlength = 0 To $length - 1
            If $char[$xwidth][$xlength] = "FFFFFF" Then
                If $p = 1 Then
                    $div = $xwidth
                    $p += 2
                EndIf
                $x = $xwidth - $div
                $row[$x] += 1

            EndIf

        Next
    Next
    ;seriales the array

    Dim $result
    For $xwidth = 0 To $width - 1

        If $row[$xwidth + 0] = 7 And $row[$xwidth + 1] = 2 And $row[$xwidth + 2] = 2 And $row[$xwidth + 3] = 2 And $row[$xwidth + 4] = 7 Then
            $result &= "0"
        EndIf

        If $row[$xwidth + 0] = 1 And $row[$xwidth + 1] = 1 And $row[$xwidth + 2] = 9 Then
            $result &= "1"
        EndIf


        If $row[$xwidth + 0] = 2 And $row[$xwidth + 1] = 3 And $row[$xwidth + 2] = 3 And $row[$xwidth + 3] = 4 And $row[$xwidth + 4] = 4 Then
            $result &= "2"
        EndIf


        If $row[$xwidth + 0] = 2 And $row[$xwidth + 1] = 2 And $row[$xwidth + 2] = 3 And $row[$xwidth + 3] = 3 And $row[$xwidth + 4] = 6 Then
            $result &= "3"
        EndIf


        If $row[$xwidth + 0] = 2 And $row[$xwidth + 1] = 3 And $row[$xwidth + 2] = 3 And $row[$xwidth + 3] = 9 And $row[$xwidth + 4] = 1 Then
            $result &= "4"
        EndIf


        If $row[$xwidth + 0] = 4 And $row[$xwidth + 1] = 4 And $row[$xwidth + 2] = 3 And $row[$xwidth + 3] = 3 And $row[$xwidth + 4] = 5 Then
            $result &= "5"
        EndIf


        If $row[$xwidth + 0] = 7 And $row[$xwidth + 1] = 3 And $row[$xwidth + 2] = 3 And $row[$xwidth + 3] = 3 And $row[$xwidth + 4] = 5 Then
            $result &= "6"
        EndIf


        If $row[$xwidth + 0] = 1 And $row[$xwidth + 1] = 4 And $row[$xwidth + 2] = 4 And $row[$xwidth + 3] = 3 And $row[$xwidth + 4] = 1 Then
            $result &= "7"
        EndIf


        If $row[$xwidth + 0] = 6 And $row[$xwidth + 1] = 3 And $row[$xwidth + 2] = 3 And $row[$xwidth + 3] = 3 And $row[$xwidth + 4] = 6 Then
            $result &= "8"
        EndIf


        If $row[$xwidth + 0] = 5 And $row[$xwidth + 1] = 3 And $row[$xwidth + 2] = 3 And $row[$xwidth + 3] = 3 And $row[$xwidth + 4] = 7 Then
            $result &= "9"
        EndIf



    Next
    $len = StringLen($result)
    Return $result

EndFunc   ;==>_NCR

;----------------------------------------------------------------------------------------------------------------------------------

Func Stuck()
    ToolTip($BotName & ": i think were stuck ", 2, 0)
    MouseClick("left", 227, 97)
    Sleep(1000)
    MouseClick("left", 847, 93)
    Sleep(1000)
    MouseClick("left", 80, 512)
    Sleep(1000)
    MouseClick("left", 958, 532)
    Sleep(1000)
EndFunc   ;==>Stuck


;--------------------------WalkTo----------------------------------------------------------------------------------------------
Func WalkTo($WalkToX, $WalkToY)
    $walktoSystem = 1
    $Coordsystem = 0
    $CoordX = _NCR(923, 34, 950, 45)
    $DestinationX = $WalkToX - $CoordX
    If $DestinationX < -2 Then
        $east = 1
    EndIf
    If $DestinationX > 2 Then
        $west = 1
    EndIf

    $CoordY = _NCR(982, 34, 1009, 45)
    $DestinationY = $WalkToY - $CoordY
    If $DestinationY < -2 Then
        $north = 1
    EndIf
    If $DestinationY > 2 Then
        $south = 1
    EndIf
    $Timer1 = TimerInit()
    If $east = 1 Then
        While 1
            If TimerDiff($Timer1) > 45 * 1000 Then
                Stuck()
                $Timer1 = TimerInit()
            EndIf
            MouseClick("left", 680, 425)
            Sleep(1000)
            ToolTip($BotName & ": walking West ", 2, 0)
            $walkCoord = _NCR(923, 34, 950, 45)
            $TempCoord = $walkCoord - $WalkToX
            If $TempCoord > 2 Then
                ToolTip($BotName & ": Keep on walking West ", 2, 0)
            EndIf
            If $TempCoord < 0 Then
                ExitLoop
            EndIf
        WEnd
    EndIf
    $east = 0
    If $west = 1 Then
        While 1
            If TimerDiff($Timer1) > 45 * 1000 Then
                Stuck()
            EndIf
            MouseClick("left", 350, 425)
            Sleep(1000)
            ToolTip($BotName & ": walking East ", 2, 0)
            $walkCoord = _NCR(923, 34, 950, 45)
            $TempCoord = $walkCoord - $WalkToX
            If $TempCoord > -2 Then
                ToolTip($BotName & ": Keep on walking East ", 2, 0)
            EndIf
            If $TempCoord > 0 Then
                ExitLoop
            EndIf
        WEnd
    EndIf
    $west = 0
    If $north = 1 Then
        While 1
            If TimerDiff($Timer1) > 45 * 1000 Then
                Stuck()
            EndIf
            MouseClick("left", 514, 256)
            Sleep(1000)
            ToolTip($BotName & ": walking South ", 2, 0)
            $walkCoord = _NCR(982, 34, 1009, 45)
            $TempCoord = $walkCoord - $WalkToY
            If $TempCoord > 2 Then
                ToolTip($BotName & ": Keep on walking South ", 2, 0)
            EndIf
            If $TempCoord < 0 Then
                ExitLoop
            EndIf
        WEnd
    EndIf
    $north = 0
    If $south = 1 Then
        While 1
            If TimerDiff($Timer1) > 45 * 1000 Then
                Stuck()
            EndIf
            MouseClick("left", 505, 567)
            Sleep(1000)
            ToolTip($BotName & ": walking North ", 2, 0)
            $walkCoord = _NCR(982, 34, 1009, 45)
            $TempCoord = $walkCoord - $WalkToY
            If $TempCoord < -2 Then
                ToolTip($BotName & ": Keep on walking North ", 2, 0)
            EndIf
            If $TempCoord > 0 Then
                ExitLoop
            EndIf
        WEnd
    EndIf
    $south = 0
EndFunc   ;==>WalkTo

;--------------------------------------------------------------------------------------------------------------------------------


Func OpenMem()
Local $DllInformation = _MemoryOpen($ProcessID)
If @Error Then
MsgBox(4096, "ERROR", "Failed to open memory.")
Exit
EndIf
EndFunc

Func ReadMem()
$X = _MemoryRead("0x" & $XAddress, $DllInformation)
$Y = _MemoryRead("0x" & $YAddress, $DllInformation)
EndFunc



Func _MemoryOpen($iv_Pid, $iv_DesiredAccess = 0x1F0FFF, $if_InheritHandle = 1)

If Not ProcessExists($iv_Pid) Then
SetError(1)
Return 0
EndIf

Local $ah_Handle[2] = [DllOpen('kernel32.dll')]

If @Error Then
SetError(2)
Return 0
EndIf

Local $av_OpenProcess = DllCall($ah_Handle[0], 'int', 'OpenProcess', 'int', $iv_DesiredAccess, 'int', $if_InheritHandle, 'int', $iv_Pid)

If @Error Then
DllClose($ah_Handle[0])
SetError(3)
Return 0
EndIf

$ah_Handle[1] = $av_OpenProcess[0]

Return $ah_Handle

EndFunc


Func _MemoryRead($iv_Address, $ah_Handle, $sv_Type = 'char[5]')

If Not IsArray($ah_Handle) Then
SetError(1)
Return 0
EndIf

Local $v_Buffer = DllStructCreate($sv_Type)

If @Error Then
SetError(@Error + 1)
Return 0
EndIf

DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')

If Not @Error Then
Local $v_Value = DllStructGetData($v_Buffer, 1)
Return $v_Value
Else
SetError(6)
Return 0
EndIf

EndFunc


Func _MemoryWrite($iv_Address, $ah_Handle, $v_Data, $sv_Type = 'dword')

If Not IsArray($ah_Handle) Then
SetError(1)
Return 0
EndIf

Local $v_Buffer = DllStructCreate($sv_Type)

If @Error Then
SetError(@Error + 1)
Return 0
Else
DllStructSetData($v_Buffer, 1, $v_Data)
If @Error Then
SetError(6)
Return 0
EndIf
EndIf

DllCall($ah_Handle[0], 'int', 'WriteProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')

If Not @Error Then
Return 1
Else
SetError(7)
Return 0
EndIf

EndFunc


Func _MemoryClose($ah_Handle)

If Not IsArray($ah_Handle) Then
SetError(1)
Return 0
EndIf

DllCall($ah_Handle[0], 'int', 'CloseHandle', 'int', $ah_Handle[1])
If Not @Error Then
DllClose($ah_Handle[0])
Return 1
Else
DllClose($ah_Handle[0])
SetError(2)
Return 0
EndIf

EndFunc


Func _MemoryPointerRead ($iv_Address, $ah_Handle, $av_Offset, $sv_Type = 'dword')

If IsArray($av_Offset) Then
If IsArray($ah_Handle) Then
Local $iv_PointerCount = UBound($av_Offset) - 1
Else
SetError(2)
Return 0
EndIf
Else
SetError(1)
Return 0
EndIf

Local $iv_Data[2], $i
Local $v_Buffer = DllStructCreate('dword')

For $i = 0 to $iv_PointerCount

If $i = $iv_PointerCount Then
$v_Buffer = DllStructCreate($sv_Type)
If @Error Then
SetError(@Error + 2)
Return 0
EndIf

$iv_Address = '0x' & hex($iv_Data[1] + $av_Offset[$i])
DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
If @Error Then
SetError(7)
Return 0
EndIf

$iv_Data[1] = DllStructGetData($v_Buffer, 1)

ElseIf $i = 0 Then
DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
If @Error Then
SetError(7)
Return 0
EndIf

$iv_Data[1] = DllStructGetData($v_Buffer, 1)

Else
$iv_Address = '0x' & hex($iv_Data[1] + $av_Offset[$i])
DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
If @Error Then
SetError(7)
Return 0
EndIf

$iv_Data[1] = DllStructGetData($v_Buffer, 1)

EndIf

Next

$iv_Data[0] = $iv_Address

Return $iv_Data

EndFunc

Func _MemoryPointerWrite ($iv_Address, $ah_Handle, $av_Offset, $v_Data, $sv_Type = 'dword')

If IsArray($av_Offset) Then
If IsArray($ah_Handle) Then
Local $iv_PointerCount = UBound($av_Offset) - 1
Else
SetError(2)
Return 0
EndIf
Else
SetError(1)
Return 0
EndIf

Local $iv_StructData, $i
Local $v_Buffer = DllStructCreate('dword')

For $i = 0 to $iv_PointerCount
If $i = $iv_PointerCount Then
$v_Buffer = DllStructCreate($sv_Type)
If @Error Then
SetError(@Error + 3)
Return 0
EndIf

DllStructSetData($v_Buffer, 1, $v_Data)
If @Error Then
SetError(8)
Return 0
EndIf

$iv_Address = '0x' & hex($iv_StructData + $av_Offset[$i])
DllCall($ah_Handle[0], 'int', 'WriteProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
If @Error Then
SetError(9)
Return 0
Else
Return $iv_Address
EndIf
ElseIf $i = 0 Then
DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
If @Error Then
SetError(3)
Return 0
EndIf

$iv_StructData = DllStructGetData($v_Buffer, 1)

Else
$iv_Address = '0x' & hex($iv_StructData + $av_Offset[$i])
DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
If @Error Then
SetError(3)
Return 0
EndIf

$iv_StructData = DllStructGetData($v_Buffer, 1)

EndIf
Next

EndFunc


Func MemSaveCoords()
    Global $ProcessID = WinGetProcess("SRO_Client")


Global $DllInformation = _MemoryOpen($ProcessID)
If @Error Then
MsgBox(4096, "ERROR", "Failed to open memory.")
Exit
EndIf
$SavedX = _MemoryRead($XMemory, $DllInformation)
$SavedY = _MemoryRead($YMemory, $DllInformation)
MsgBox(4096, "X", $SavedX)
MsgBox(4096, "Y", $SavedY)
$Coordsystem = 1
_MemoryClose($DllInformation)
EndFunc

    Func MemWalkStuck()
            Global $ProcessID = WinGetProcess("SRO_Client")


Global $DllInformation = _MemoryOpen($ProcessID)
If @Error Then
MsgBox(4096, "ERROR", "Failed to open memory.")
Exit
EndIf
    $CurrentCoord = _MemoryRead($XMemory, $DllInformation)
        if $walkCoord = $CurrentCoord Or $walkcoord1 = $CurrentCoord Or $walkcoord2 = $CurrentCoord Then
            ToolTip("HelBot: Shit im stuck ", 2, 0)
            MouseClick( "left", 227,97)
            Sleep(1000)
            MouseClick( "left", 847,93)
            Sleep(1000)
            MouseClick( "left", 80,512)
            Sleep(1000)
            MouseClick( "left", 958,532)
            Sleep(1000)
            _MemoryClose($DllInformation)
            MemWalkToDirection()
        EndIf
        EndFunc



    Func MemWalkTo($WalkToX,$WalkToY)
        Global $ProcessID = WinGetProcess("SRO_Client")


Global $DllInformation = _MemoryOpen($ProcessID)
If @Error Then
MsgBox(4096, "ERROR", "Failed to open memory.")
Exit
EndIf
        $walktoSystem = 1
        $Coordsystem = 0
        $CoordX = _MemoryRead($XMemory, $DllInformation)
$Destination = $WalkToX - $CoordX
If $DestinationX < -5 Then
    $east = 1
    EndIf
    If $DestinationX > 5 Then
        $west = 1
    EndIf

$CoordY = _MemoryRead($YMemory, $DllInformation)
$DestinationY = $WalkToY - $CoordY
If $DestinationY < -5 Then
    $north = 1
    EndIf
    If $DestinationY > 5 Then
        $south = 1
    EndIf
    _MemoryClose($DllInformation)
        MemWalkToDirection()
    EndFunc
    
    


    Func MemWalkToDirection()
    $Timer1 = TimerInit()
    If $east = 1 Then
        While 1
            if timerdiff($timer1) > 45 * 1000 then
                Stuck()
                $Timer1 = TimerInit()
                EndIf
        MouseClick("left",676,425)
        Sleep(500)
        ToolTip("HelBot: walking West ", 2, 0)
        $walkCoord = _MemoryRead($XMemory, $DllInformation)
        $TempCoord = $walkCoord - $WalkToX
        If $TempCoord > 5 Then
                ToolTip("HelBot: Keep on walking West ", 2, 0)
                Endif
        If $TempCoord < -5 Then
            ExitLoop
        EndIf
        Wend
    EndIf
$east = 0
;------------------------------------------------------------------------------------------------------------------------
If $west = 1 Then
        While 1
            if timerdiff($timer1) > 45 * 1000 then
                Stuck()
                EndIf
        MouseClick("left",369,409)
        Sleep(500)
        ToolTip("HelBot: walking East ", 2, 0)
        $walkCoord = _MemoryRead($XMemory, $DllInformation)
        $TempCoord = $walkCoord - $WalkToX
        If $TempCoord < -5 Then
                ToolTip("HelBot: Keep on walking East ", 2, 0)
                Endif
        If $TempCoord > 5 Then
            ExitLoop
        EndIf
        Wend
    EndIf
$west = 0
;------------------------------------------------------------------------------------------------------------------------
If $north = 1 Then
        While 1
            if timerdiff($timer1) > 45 * 1000 then
                Stuck()
                EndIf
        MouseClick("left",510,253)
        Sleep(500)
        ToolTip("HelBot: walking South ", 2, 0)
        $walkCoord = _MemoryRead($YMemory, $DllInformation)
        $TempCoord = $walkCoord - $WalkToY
        MsgBox(64,"WalkCoord",$WalkCoord)
        MsgBox(64,"temp",$TempCoord)
        If $TempCoord > 5 Then
                ToolTip("HelBot: Keep on walking South ", 2, 0)
                Endif
        If $TempCoord < -5 Then
            ExitLoop
        EndIf
        Wend
    EndIf
$north = 0
;------------------------------------------------------------------------------------------------------------------------
If $south = 1 Then
        While 1
            if timerdiff($timer1) > 45 * 1000 then
                Stuck()
                EndIf
        MouseClick("left",510,548)
        Sleep(500)
        ToolTip("HelBot: walking North ", 2, 0)
        $walkCoord = _MemoryRead($YMemory, $DllInformation)
        $TempCoord = $walkCoord - $WalkToY
        If $TempCoord < -5 Then
                ToolTip("HelBot: Keep on walking North ", 2, 0)
                Endif
        If $TempCoord > 5 Then
            ExitLoop
        EndIf
        Wend
    EndIf
$south = 0
;------------------------------------------------------------------------------------------------------------------------
_MemoryClose($DllInformation)
    EndFunc

Func WalkPath()
Global $CoordListItem[101]
#Region ### START Koda GUI section ### Form=C:\Program Files\AutoIt3\SciTE\Koda\Forms\save.kxf
$Form1 = GUICreate("coords", 219, 300, 193, 115)
$XC = GUICtrlCreateInput("", 40, 216, 33, 21)
$Label1 = GUICtrlCreateLabel("X", 24, 216, 12, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Y", 80, 216, 13, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$YC = GUICtrlCreateInput("", 96, 216, 33, 21)
$Enter = GUICtrlCreateButton("Enter", 136, 216, 59, 25, 0)
$CoordList = GUICtrlCreateListView("#|X|Y", 24, 40, 171, 163, BitOR($LVS_REPORT,$LVS_SINGLESEL,$LVS_SHOWSELALWAYS,$WS_BORDER))
For $i = 1 To UBound($CoordListItem)-1
    $CoordListItem[$i] = GUICtrlCreateListViewItem($i & "||",$CoordList)
Next
$Save = GUICtrlCreateButton("Save", 16, 256, 59, 25, 0)
$Load = GUICtrlCreateButton("Load", 88, 256, 51, 25, 0)
$OK = GUICtrlCreateButton("OK", 152, 256, 51, 25, 0)
$WalkToName = GUICtrlCreateInput("", 24, 8, 169, 21)
_GUICtrlListViewSetColumnWidth ($CoordList, 1, 60)
_GUICtrlListViewSetColumnWidth ($CoordList, 2, 60)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $CoordList
            
        Case $Enter
            If GUICtrlRead($XC) = "" Or GUICtrlRead($YC) = "" Then
                    MsgBox(0,"Error","Fill In X & Y Inputs Please")
                    Else
            GUICtrlSetData($CoordListItem[_GUICtrlListViewGetSelectedIndices($CoordList)+1],_GUICtrlListViewGetSelectedIndices($CoordList)+1 & "|" & GUICtrlRead($XC) & "|" & GUICtrlRead($YC))
            EndIf

        Case $OK
            $Name = GUICtrlRead($WalkToName)
            If $Name = "" Then 
                MsgBox(64,"Error", "You must have a path loaded or it wont work")
            Else
               $X1 = _GUICtrlListViewGetItemText ($CoordList, 1,1)
               $Y1 = _GUICtrlListViewGetItemText ($CoordList, 1,2)
               
               MsgBox(64,"ProBot", "You are using the walkback path named : " & $Name)
               GUISetState(@SW_HIDE)
            EndIf
   
       Case $Save
           $Name = GUICtrlRead($WalkToName)
           If $Name = "" Then 
               $Name = "default.txt"
           EndIf
            For $x = 1 to UBound($CoordListItem)-1
                IniWrite ($Name, "Coordinates", "coord" & $x, GuiCtrlRead($CoordListItem[$x]))
            Next
         
        Case $Load
            $Name2 = InputBox ("Enter name of .ini file", "Enter name of WalkTo .ini file")
            If $Name2 = "" Then
                $Name2 = "default.txt"
            EndIf
            GUICtrlSetData($WalkToName,$Name2)
            $LoadRecords = IniReadSection($Name2, "Coordinates")
            If @error Then 
                MsgBox(4096, "", "Error occurred, probably no INI file.")
            Else
                For $i = 1 To $LoadRecords[0][0]
                    GuiCtrlSetData($CoordListItem[$i], $LoadRecords[$i][1])
                    ;MsgBox(4096, "", "Key: " & $LoadRecords[$i][0] & @CRLF & "Value: " & $LoadRecords[$i][1])
                Next
            EndIf

    EndSwitch

WEnd
EndFunc

Func GetItem()
    WinActivate("SRO_Client")
Sleep(500)
;-----------------------------------------FIND ITEM MARKER---------------------------------------------
    While 1 
        ToolTip("Get Item : Searching for item marker ", 2, 0)
        ;---------------------------Determine search coords----------------------------------------
        $pos = MouseGetPos()
        If $pos[0] < 656 Thexxxxx
            
            x
            x
            x
            
            x
            x
            
            x
            xx
        If $pos[1] < 624 And $pos[1] > 587 Then ; hori row 8
            $poscoord2 = 624
        EndIf
        
$coords = PixelSearch($poscoord1,330,783,$poscoord2,0xC2BDB6,$Sensitivity) ;search for marker
If Not @error Then
    MsgBox(0,"Found Item Marker","Found") ; when marker found
    WinActivate("SRO_Client")
$SearchCoord1 = $coords[1] - 13 ;set ocr coords
$SearchCoord2 = $coords[1] + 29 ; set ocr coords
$ItemMarkerFound = 1
Else
WinActivate("SRO_Client")
$ItemMarkerFound = 0
EndIf
If $ItemMarkerFound = 1 Then
    ExitLoop
    EndIf
WEnd
;----------------------------------------------ANALYZE ITEM---------------------------------------------------
$result = ""
ToolTip("Get Item : Analyzing Item ", 2, 0)
$ItemText = _ItemCR($coords[0],$SearchCoord1,910,$SearchCoord2)
MsgBox(0,"Result is",$ItemText)
WinActivate("SRO_Client")
$Item = StringInStr( $ItemText, "(+)",1)
;-----------------------------------------------ITEM RESULT-----------------------------------------------
If $Item <> 0 Then
MsgBox(0,"Item","Item is a + item")
WinActivate("SRO_Client")
$ItemType = "+ Item"
EndIf
$Item = StringInStr( $ItemText, "MP",1)
If $Item <> 0 Then
MsgBox(0,"Item","Item is a MP pot")
WinActivate("SRO_Client")
$ItemType = "MP Pot"
EndIf
$Item = StringInStr( $ItemText, "HP",1)
If $Item <> 0 Then
MsgBox(0,"Item","Item is a HP pot")
WinActivate("SRO_Client")
$ItemType = "HP Pot"
EndIf
$Item = StringInStr( $ItemText, "Retu",1)
If $Item <> 0 Then
MsgBox(0,"Item","Item is a Return Scroll")
WinActivate("SRO_Client")
$ItemType = "Return Scroll"
EndIf
$Item = StringInStr( $ItemText, "Rub",1)
If $Item <> 0 Then
MsgBox(0,"Item","Item is a alchemy tablet")
WinActivate("SRO_Client")
$ItemType = "Ruby Tablet"
EndIf
$Item = StringInStr( $ItemText, "Jade",1)
If $Item <> 0 Then
MsgBox(0,"Item","Item is a alchemy tablet")
WinActivate("SRO_Client")
$ItemType = "Jade Tablet"
EndIf
PixelSearch($coords[0],$SearchCoord1,835,$SearchCoord2,0x72BFFF)
If Not @error Then
    MsgBox(0,"Item","Item is a Blue")
WinActivate("SRO_Client")
$ItemType = "Blue Item"
EndIf
;PixelSearch($coords[0],$SearchCoord1,835,$SearchCoord2,0x72BFFF)  edit this for sos items
;If Not @error Then
;   MsgBox(0,"Item","Item is a Sealed Item")
;WinActivate("SRO_Client")
;$ItemType = "Sealed Item"
;EndIf
WinActivate("SRO_Client")
EndFunc





Func _ItemCR($Ax, $Ay, $Dx, $Dy)

    $width = $Dx - $Ax
    $length = $Dy - $Ay

    Dim $char[$width][$length]

    For $xwidth = 0 To $width - 1
        For $xlength = 0 To $length - 1
            $char[$xwidth][$xlength] = Hex(PixelGetColor($Ax, $Ay), 6)
            $Ay = $Ay + 1
        Next
        $Ax = $Ax + 1
        $Ay = $Ay - $length
    Next
    ;scans entire area


    $p = 1
    Dim $row[$width]
    For $xwidth = 0 To $width - 1

        For $xlength = 0 To $length - 1
            If $char[$xwidth][$xlength] = "FFFFFF" Then
                If $p = 1 Then
                    $div = $xwidth
                    $p += 2
                EndIf
                $x = $xwidth - $div
                $row[$x] += 1

            EndIf

        Next
    Next
    ;seriales the array

    Dim $result
    For $xwidth = 0 To $width - 1
        
        If $row[$xwidth + 0] = 5 And $row[$xwidth + 1] = 9 And $row[$xwidth + 2] = 4 Then
            $result &= "("
        EndIf
        
        
        If $row[$xwidth + 0] = 4 And $row[$xwidth + 1] = 9 And $row[$xwidth + 2] = 5 Then
            $result &= ")"
        EndIf
        
        
        If $row[$xwidth + 0] = 1 And $row[$xwidth + 1] = 1 And $row[$xwidth + 2] = 5 And $row[$xwidth + 3] = 5 And $row[$xwidth + 4] = 1 And $row[$xwidth + 5] = 1 Then
            $result &= "+"
        EndIf
        
        
        If $row[$xwidth + 0] = 9 And $row[$xwidth + 1] = 9 And $row[$xwidth + 2] = 1 And $row[$xwidth + 3] = 1 And $row[$xwidth + 4] = 1 And $row[$xwidth + 5] = 9 And $row[$xwidth + 6] = 9 Then
            $result &= "H"
        EndIf
        
        
        If $row[$xwidth + 0] = 9 And $row[$xwidth + 1] = 9 And $row[$xwidth + 2] = 4 And $row[$xwidth + 3] = 6 And $row[$xwidth + 4] = 3 And $row[$xwidth + 5] = 6 And $row[$xwidth + 6] = 4  And $row[$xwidth + 7] = 9 And $row[$xwidth + 8] = 9 Then
            $result &= "M"
        EndIf
        
        
        If $row[$xwidth + 0] = 9 And $row[$xwidth + 1] = 9 And $row[$xwidth + 2] = 2 And $row[$xwidth + 3] = 2 And $row[$xwidth + 4] = 2 And $row[$xwidth + 5] = 6 And $row[$xwidth + 6] = 4 Then
            $result &= "P"
        EndIf
        
        
        If $row[$xwidth + 0] = 9 And $row[$xwidth + 1] = 9 And $row[$xwidth + 2] = 2 And $row[$xwidth + 3] = 2 And $row[$xwidth + 4] = 3 And $row[$xwidth + 5] = 8 And $row[$xwidth + 6] = 6  And $row[$xwidth + 7] = 1 Then
            $result &= "R"
        EndIf
        

        If $row[$xwidth + 0] = 5 And $row[$xwidth + 1] = 7 And $row[$xwidth + 2] = 3 And $row[$xwidth + 3] = 3 And $row[$xwidth + 4] = 6 And $row[$xwidth + 5] = 4 Then
            $result &= "e"
        EndIf
        

        If $row[$xwidth + 0] = 7 And $row[$xwidth + 1] = 9 And $row[$xwidth + 2] = 2 Then
            $result &= "t"
        EndIf
        

        If $row[$xwidth + 0] = 6 And $row[$xwidth + 1] = 7 And $row[$xwidth + 2] = 1 And $row[$xwidth + 3] = 1 And $row[$xwidth + 4] = 7 And $row[$xwidth + 5] = 7 Then
            $result &= "u"
        EndIf
        

        If $row[$xwidth + 0] = 9 And $row[$xwidth + 1] = 9 And $row[$xwidth + 2] = 2 And $row[$xwidth + 3] = 2 And $row[$xwidth + 4] = 7 And $row[$xwidth + 5] = 5 Then
            $result &= "b"
        EndIf
        

        If $row[$xwidth + 0] = 5 And $row[$xwidth + 1] = 8 And $row[$xwidth + 2] = 3 And $row[$xwidth + 3] = 5 And $row[$xwidth + 4] = 5 And $row[$xwidth + 5] = 2 Then
            $result &= "u"
        EndIf
        
        If $row[$xwidth + 0] = 2 And $row[$xwidth + 1] = 3 And $row[$xwidth + 2] = 1 And $row[$xwidth + 3] = 1 And $row[$xwidth + 4] = 9 And $row[$xwidth + 5] = 8 Then
            $result &= "J"
        EndIf
        
        If $row[$xwidth + 0] = 3 And $row[$xwidth + 1] = 5 And $row[$xwidth + 2] = 4 And $row[$xwidth + 3] = 3 And $row[$xwidth + 4] = 7 And $row[$xwidth + 5] = 6 Then
            $result &= "a"
        EndIf
        
        If $row[$xwidth + 0] = 5 And $row[$xwidth + 1] = 7 And $row[$xwidth + 2] = 2 And $row[$xwidth + 3] = 2 And $row[$xwidth + 4] = 9 And $row[$xwidth + 5] = 9 Then
            $result &= "d"
        EndIf
        
        $len = StringLen($result)
        If $result > 4 Then
            ExitLoop
            Return $result
            EndIf



    Next
    $len = StringLen($result)
    Return $result

EndFunc   ;==>_NCR



Func AutoSpam()
    While 1
    Sleep($SpamDelay)
    MouseClick("Left",87,703,1,0)
    Sleep(300)
    ControlSend("SRO_Client", "", "", $SpamMessage1)
    Sleep(1000)
    ControlSend("SRO_Client", "", "", "{ENTER}")
    WEnd
endFunc

dont worry i just removed some things that i replaced by x for the copyright

Link to comment
Share on other sites

well thats good.. i cant even test to see wtf the problem is.. i just get a bunch of errors cause you took shit out

lol wtf is your favorite expression (no offense) , the script is damn to big to be analyzed properly!!! test the normal one and post the error that you get, also there must be 2 separate scripts

THE server's one and the client's which are used in different pc's...

1) i can say better use TCP than UDP

2) search for other examples....

Link to comment
Share on other sites

can any one make for me the servers one or give me a tutoriel that explane how to make one all he have to is to have a place where he have account names and passwords that the user enter and the servers one verify

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...