Rorka Posted September 21, 2009 Share Posted September 21, 2009 I seem to be having a problem... What am i doing wrong in this code? $orefile = FileRead("Orelist.xData") $orecontent = _StringBetween($orefile, "<XGathernode>", "</XGathernode>") $split1 = StringSplit($orecontent[0], " ") If IsArray($split1) Then If $split1[0] = 1 Then $Ore = $split1[1] EndIf EndIf If $name = $split1 Then _Log("Found : " & $name) _Move($handle, _getObjectX($handle, $curobject), _getObjectY($handle, $curobject), _getObjectZ($handle, $curobject)) EndIf I know its messy... It needs to check all the words in the Orelist.xData, every word is on a diffrent line and have <XGathernode> before then and </XGathernode> after them. Please help Link to comment Share on other sites More sharing options...
jvanegmond Posted September 21, 2009 Share Posted September 21, 2009 Your code is fine, apart from a lack of error checking. If there's anything wrong, then it's something you haven't posted. Write a reproduction script for us, so we can identify the issue and solve it. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Rorka Posted September 21, 2009 Author Share Posted September 21, 2009 Here is my full code: expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include <string.au3> #include <Includes/WoWConstants.au3> #include <Includes/BlackMagicAU3.au3> #include <Includes/DifferentWoWMemoryThings.au3> Global $versionnumber = "Alpha - Rev 1" Global $PIDbox, $getnickname, $pName Global $lineNumber = 3 _BMInitialize() $PID = WinGetProcess("World of Warcraft") $handle = _BMOpenProcess($PID) $ptr1 = _BMReadMemory($handle, $PlayerBase, "ptr") $ptr2 = _BMReadMemory($handle, $ptr1 + $PlayerBaseOffset1, "ptr") $pBase = _BMReadMemory($handle, $ptr2 + $PlayerBaseOffset2, "ptr") $ObjectManager = _BMReadUInt($handle, (_BMReadUInt($handle, $aClientConnection) + $ObjManagerOffset)) $FirstObject = _BMReadUInt($handle, ($ObjectManager + $ObjManagerFirstObject)) RefreshPID() $GUI = GUICreate("XGather", 571, 456) $Logwindow = GUICtrlCreateEdit("[Startup] Welcome to XGather.", 8, 64, 249, 353, BitOR($ES_AUTOVSCROLL,$ES_READONLY,$ES_WANTRETURN,$WS_VSCROLL)) $Group1 = GUICtrlCreateGroup("WoW Details", 8, 8, 249, 49) $PIDbox = GUICtrlCreateCombo("Select PID", 16, 24, 153, 25) $RefeshPID = GUICtrlCreateButton("Refresh", 176, 24, 75, 25, $WS_GROUP) GUICtrlCreateGroup("", -99, -99, 1, 1) $Tab1 = GUICtrlCreateTab(264, 16, 289, 193) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $Latest = GUICtrlCreateTabItem("News") $Newspanel = GUICtrlCreateEdit("", 272, 48, 273, 153, BitOR($ES_READONLY,$ES_WANTRETURN)) GUICtrlSetData(-1, "Alpha - Rev 1 Released") $License = GUICtrlCreateTabItem("License") $Label1 = GUICtrlCreateLabel("Without a working license key. This bot cannot function", 272, 48, 267, 17) $Label2 = GUICtrlCreateLabel("properly. Therefore the bot will only allow you to run for ", 272, 64, 263, 17) $Label3 = GUICtrlCreateLabel("10 Minutes at a time.", 272, 80, 102, 17) $Licenseinput = GUICtrlCreateInput(FileRead("License.Xdata"), 272, 104, 273, 21) $Save = GUICtrlCreateButton("SaveLicense", 272, 128, 275, 25, $WS_GROUP) $TabSheet1 = GUICtrlCreateTabItem("Ores") $Farmminescheckbox = GUICtrlCreateCheckbox("Farm ores", 272, 48, 97, 17) $Orelist = GUICtrlCreateEdit("", 272, 72, 273, 73, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN,$WS_VSCROLL)) GUICtrlSetData(-1, FileRead("Orelist.Xdata")) $Group3 = GUICtrlCreateGroup("Add an farming node:", 272, 152, 265, 49) $Addoreinput = GUICtrlCreateInput("Insert node name here", 280, 168, 145, 21) $Addorenode = GUICtrlCreateButton("Add Node", 432, 168, 99, 25, $WS_GROUP) GUICtrlCreateGroup("", -99, -99, 1, 1) $TabSheet2 = GUICtrlCreateTabItem("Herbs") $Farmherbscheckbox = GUICtrlCreateCheckbox("Farm herbs", 272, 48, 97, 17) $Herblist = GUICtrlCreateEdit("", 272, 72, 273, 73, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN,$WS_VSCROLL)) GUICtrlSetData(-1, FileRead("Herblist.Xdata")) $Group4 = GUICtrlCreateGroup("Add a farming node:", 272, 152, 273, 49) $Addherbinput = GUICtrlCreateInput("Insert node name here", 280, 168, 161, 21) $Addherbnode = GUICtrlCreateButton("Add node", 464, 168, 75, 25, $WS_GROUP) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateTabItem("") $Group2 = GUICtrlCreateGroup("Alpha stats:", 264, 216, 289, 225) $Label4 = GUICtrlCreateLabel("Here I will be showing some statistics about the Alpha!", 272, 232, 259, 17) $Label5 = GUICtrlCreateLabel("Bugs Fixed: 0", 272, 256, 81, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Label6 = GUICtrlCreateLabel("Estimated Alpha end date: Unknown", 272, 272, 210, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Label7 = GUICtrlCreateLabel("Planned future releases:", 272, 296, 142, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Label8 = GUICtrlCreateLabel("Automatic fighting", 272, 320, 88, 17) $Label9 = GUICtrlCreateLabel("Ground Mount Support", 272, 336, 112, 17) $Label10 = GUICtrlCreateLabel("Timed Session", 272, 352, 73, 17) $Label11 = GUICtrlCreateLabel("Death dection", 272, 368, 71, 17) $Label12 = GUICtrlCreateLabel("Automatic updater", 272, 384, 90, 17) $Label13 = GUICtrlCreateLabel("A nice GUI", 272, 400, 56, 17) $Label14 = GUICtrlCreateLabel("And Much-Much more!!!", 272, 416, 118, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Startbot = GUICtrlCreateButton("Start", 8, 424, 251, 25, $WS_GROUP) ;Startup message _Log("[Startup] Version: "&$versionnumber&".") _Log("[Startup] Waiting for user input") _Log(@CRLF & "[XGather Help] If there are no options in the PID dropbox make sure you is started and you are loged in then press refresh" & @CRLF) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Startbot _Log("[XGather Login System] Checking Auth...") If FileRead("License.Xdata") = "Insert License Key Here" Then _Log("[XGather Login System] Auth is valid") _Log("[XGather Login System] Allowing Xgather to start" & @CRLF) CheckOptions() Else _Log("[XGather Login System] Auth is invalid") _Log("[Alpha Information] During the Alpha testing you shouldnt change the License Key") EndIf ;Bot here Case $RefeshPID RefreshPID() Case $Save FileDelete("License.Xdata") FileWrite("License.Xdata", GUICtrlRead($Licenseinput)) Case $Addorenode If GUICtrlRead($Addoreinput) = "Insert node name here" Then _Log("[Error Information] You didnt type in an Node name") Else FileWriteLine("Orelist.Xdata", GUICtrlRead($Addoreinput)) _Log("[XGather] Added "&GUICtrlRead($Addoreinput)&".") GUICtrlSetData($Addoreinput, "Insert node name here") EndIf Case $Addherbnode If GUICtrlRead($Addherbinput) = "Insert node name here" Then _Log("[Error Information] You didnt type in an Node name") Else FileWriteLine("Herblist.Xdata", GUICtrlRead($Addherbinput)) _Log("[XGather] Added "&GUICtrlRead($Addoreinput)&".") GUICtrlSetData($Addherbinput, "Insert node name here") EndIf EndSwitch WEnd Func _Log($logmessage) $alreadylogged = GUICtrlRead($Logwindow) GUICtrlSetData($Logwindow, $alreadylogged & @CRLF & $logmessage) EndFunc Func RefreshPID() $handle1 = GUICtrlRead($PIDbox) GUICtrlSetData($PIDbox, $handle) EndFunc Func CheckOptions() _Log("[XGather] Checking Options") If GUICtrlRead($Farmminescheckbox) == 4 Then _Log("[Farming Ores] False") _Log("") ElseIf GUICtrlRead($Farmminescheckbox) == 1 Then _Log("[Farming Ores] True") _Log("[Loading Farming Details for]:" & @CRLF &FileRead("Orelist.Xdata")) _Log("") EndIf If GUICtrlRead($Farmherbscheckbox) == 4 Then _Log("[Farming Herbs] False") _Log("") ElseIf GUICtrlRead($Farmherbscheckbox) == 1 Then _Log("[Farming Herbs] True") _Log("[Loading Farming Details for]:" & @CRLF &FileRead("herblist.Xdata")) _Log("") EndIf If GUICtrlRead($Farmminescheckbox) == 4 And GUICtrlRead($Farmherbscheckbox) == 4 Then _Log("[XGather] You havent selected anything to farm.") _Log("[XGather] Please either select Ores or Herbs from the options.") _Log("[XGather] Stopped.") Else _Log("[XGather] Options are okay.") _Log("") Profilego() EndIf EndFunc Func Profilego() _BMWriteFloat($handle, $Clicktomovestart, 13.9626340866089);Enable CTM $X = _GetX($handle, $pBase) $Y = _GetY($handle, $pBase) $Z = _GetZ($handle, $pBase) _Log("[XGather] Current Location:" & @CRLF & "X: " & $X & @CRLF &"Y: " & $Y & @CRLF & "Z: " & $Z) _Log("") $Movement = True $curobject = $FirstObject $pName = FileOpenDialog("Please select a profile", @ScriptDir & "/Profiles", "XGather Profiles (*.xProfile)") $getnickname = FileReadLine($pName, 1) _Log("[XGather] Profile Loaded: " & $getnickname) While ($Movement == True) $profileFile = FileReadLine($pName, $lineNumber) $content = _StringBetween($profileFile, "<XGatherWP>", "</XGatherWP>") If Not @error Then $split = StringSplit($content[0], " ") If IsArray($split) Then If $split[0] = 3 Then $XCoord = $split[1] $YCoord = $split[2] $ZCoord = $split[3] $X = _GetX($handle, $pBase) $Y = _GetY($handle, $pBase) $Z = _GetZ($handle, $pBase) _Log("["&$getnickname&"] Moving to " & Round($XCoord) &" "& Round($YCoord) &" "& Round($ZCoord)) $lineNumber = $lineNumber + 1 If $X = _GetX($handle, $pBase) = Round($XCoord) and $Y = _GetY($handle, $pBase) = Round($YCoord) and $Z = _GetZ($handle, $pBase) Then Sleep(10) Else $ObjectManager = _BMReadUInt($handle, (_BMReadUInt($handle, $aClientConnection) + $ObjManagerOffset)) $FirstObject = _BMReadUInt($handle, ($ObjectManager + $ObjManagerFirstObject)) $curobject = _BMReadUInt($handle, ($curobject + $ObjectNextOffset)) $name = _BMReadASCIIString($handle, _BMReadUint($handle, (_BMReadUInt($handle, ($curobject + $GAMEOBJECT_NAMEOFFSET_1)) + $GAMEOBJECT_NAMEOFFSET_2)), 30) $curGUID = _BMReadMemory($handle, ($curobject + 0x30), 'uint64') $orefile = FileRead("Orelist.xData") $orecontent = _StringBetween($orefile, "<XGathernode>", "</XGathernode>") $split1 = StringSplit($orecontent[0], " ") If IsArray($split1) Then If $split1[0] = 1 Then $Ore = $split1[1] EndIf EndIf ;If $name = $split1 Then ;_Log("Found : " & $name) ;_Move($handle, _getObjectX($handle, $curobject), _getObjectY($handle, $curobject), _getObjectZ($handle, $curobject)) ;EndIf EndIf EndIf EndIf EndIf WEnd ; _Move($handle, $XCoord, $YCoord, $ZCoord) EndFunc Func _getObjectX($handle, $curobject) Return Floor(_BMReadMemory($handle, $curobject + 0xE8, "float")) EndFunc ;==>_getObjectX Func _getObjectY($handle, $curobject) Return Floor(_BMReadMemory($handle, $curobject + 0xEC, "float")) EndFunc ;==>_getObjectY Func _getObjectZ($handle, $curobject) Return Floor(_BMReadMemory($handle, $curobject + 0xF0, "float")) EndFunc ;==>_getObjectZ Func _Move($handle, $XCoord, $YCoord, $ZCoord) _BMWriteFloat($handle, 0x012818C4, $XCoord) _BMWriteFloat($handle, 0x012818C8, $YCoord) _BMWriteFloat($handle, 0x012818CC, $ZCoord) _BMWriteInt($handle, 0x01281854, "4") $X = Round(_GetX($handle, $pBase)) $Y = Round(_GetY($handle, $pBase)) $lastDist = 10000000 $dist = Sqrt(($X - $XCoord) ^ 2 + ($Y - $YCoord) ^ 2) ;MsgBox(0, "Wrote that Shit", "") $distance = False While ($distance == False) $distancewp = Round(Sqrt(($XCoord - _GetX($handle, $pBase)) ^ 2 + ($YCoord - _GetY($handle, $pBase)) ^ 2)) If $distancewp < 5 Then $distance = True EndIf If $distancewp > 6 Then Sleep(100) EndIf WEnd EndFunc ;==>_Move Link to comment Share on other sites More sharing options...
jvanegmond Posted September 21, 2009 Share Posted September 21, 2009 (edited) No, I asked to write a reproduction script. Not just dump all your stuff here.Characteristics of a reproduction script are: - It has a problem or special feature. - It's as short as possible, while maintaining readability. - It's commented where necessary. - There are as little as possible requirements. (It doesn't require you to own World of Warcraft to be able to debug it.)Edit: Beside that, am I supposed to guess the format of your XML file or something? Edited September 21, 2009 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
99ojo Posted September 21, 2009 Share Posted September 21, 2009 (edited) No, I asked to write a reproduction script. Not just dump all your stuff here. Characteristics of a reproduction script are: - It has a problem or special feature. - It's as short as possible, while maintaining readability. - It's commented where necessary. - There are as little as possible requirements. (It doesn't require you to own World of Warcraft to be able to debug it.) Edit: Beside that, am I supposed to guess the format of your XML file or something? Hi, It needs to check all the words in the Orelist.xData, every word is on a diffrent line and have <XGathernode> before then and </XGathernode> after them i think you should try this: #include <array.au3> #include <string.au3> $orefile = FileRead("Orelist.xData"); the file must be in Script folder, otherwise you get error like your next post $orecontent = _StringBetween($orefile, "<XGathernode>", "</XGathernode>") _arraydisplay ($orecontent) For $i = 0 To UBound ($orecontent) - 1 $split1 = StringSplit($orecontent[$i], " ") If $split1[0] = 1 Then $Ore = $split1[1] EndIf ;outcommented for test ;If $name = $split1 Then ;_Log("Found : " & $name) ;_Move($handle, _getObjectX($handle, $curobject), _getObjectY($handle, $curobject), _getObjectZ($handle, $curobject)) ;EndIf Next ;-)) Stefan [Edit] After following post post from Rorka. The updated code works fine with your Orelist.xdate file, if it is in scriptdir. Couldn't test the outcommented lines..... Edited September 21, 2009 by 99ojo Link to comment Share on other sites More sharing options...
Rorka Posted September 21, 2009 Author Share Posted September 21, 2009 Here is there log from Scite >"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\Ashley\Desktop\MY BOT\GUI.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams +>13:11:39 Starting AutoIt3Wrapper v.2.0.0.1 Environment(Language:0409 Keyboard:00000809 OS:WIN_VISTA/Service Pack 2 CPU:X64 OS:X86) >Running AU3Check (1.54.14.0) from:C:\Program Files\AutoIt3 +>13:11:39 AU3Check ended.rc:0 >Running:(3.3.0.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Users\Ashley\Desktop\MY BOT\GUI.au3" C:\Users\Ashley\Desktop\MY BOT\GUI.au3 (213) : ==> Subscript used with non-Array variable.: $split1 = StringSplit($orecontent[0], " ") $split1 = StringSplit($orecontent^ ERROR ->13:11:46 AutoIT3.exe ended.rc:1 +>13:11:47 AutoIt3Wrapper Finished >Exit code: 1 Time: 8.722 Here is my Orelist.xDate file <XGathernode>Black Blood of Yogg-Saron</XGathernode> <XGathernode>Copper Vein</XGathernode> <XGathernode>Tin Vein</XGathernode> <XGathernode>Ooze Covered Silver Vein</XGathernode> <XGathernode>Silver Vein</XGathernode> <XGathernode>Iron Deposit</XGathernode> <XGathernode>Gold Vein</XGathernode> <XGathernode>Ooze Covered Gold Vein</XGathernode> <XGathernode>Mithril Deposit</XGathernode> <XGathernode>Ooze Covered Mithril Deposit</XGathernode> <XGathernode>Dark Iron Deposit</XGathernode> <XGathernode>Ooze Covered Truesilver Deposit</XGathernode> <XGathernode>Truesilver Deposit</XGathernode> <XGathernode>Ooze Covered Thorium Vein</XGathernode> <XGathernode>Small Thorium Vein</XGathernode> <XGathernode>Hakkari Thorium Vein</XGathernode> <XGathernode>Ooze Covered Rich Thorium Vein</XGathernode> <XGathernode>Rich Thorium Vein</XGathernode> <XGathernode>Fel Iron Deposit</XGathernode> <XGathernode>Nethercite Deposit</XGathernode> <XGathernode>Large Obsidian Chunk</XGathernode> <XGathernode>Small Obsidian Chunk</XGathernode> <XGathernode>Adamantite Deposit</XGathernode> <XGathernode>Cobalt Deposit</XGathernode> <XGathernode>Rich Adamantite Deposit</XGathernode> <XGathernode>Ancient Gem Vein</XGathernode> <XGathernode>Khorium Vein</XGathernode> <XGathernode>Rich Cobalt Deposit</XGathernode> <XGathernode>Saronite Deposit</XGathernode> <XGathernode>Rich Saronite Deposit</XGathernode> <XGathernode>Pure Saronite Deposit</XGathernode> <XGathernode>Titanium Vein</XGathernode> I dont see how i can make it work out of World of Warcraft, when it needs to see if there is a object close thats in that xdata file? Link to comment Share on other sites More sharing options...
jvanegmond Posted September 21, 2009 Share Posted September 21, 2009 The part you're having problems with is parsing of the "XML" file. I don't see why you need World of Warcraft to parse a XML file. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Rorka Posted September 21, 2009 Author Share Posted September 21, 2009 Hi, i think you should try this: #include <array.au3> #include <string.au3> $orefile = FileRead("Orelist.xData"); the file must be in Script folder, otherwise you get error like your next post $orecontent = _StringBetween($orefile, "<XGathernode>", "</XGathernode>") _arraydisplay ($orecontent) For $i = 0 To UBound ($orecontent) - 1 $split1 = StringSplit($orecontent[$i], " ") If $split1[0] = 1 Then $Ore = $split1[1] EndIf ;outcommented for test ;If $name = $split1 Then ;_Log("Found : " & $name) ;_Move($handle, _getObjectX($handle, $curobject), _getObjectY($handle, $curobject), _getObjectZ($handle, $curobject)) ;EndIf Next ;-)) Stefan [Edit] After following post post from Rorka. The updated code works fine with your Orelist.xdate file, if it is in scriptdir. Couldn't test the outcommented lines..... Well it doesnt error so thats a start... Ill try and figure out the moving to it and collecting now... Thanks guys Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now