Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Guild Wars > GW Bots
You last visited: Today at 12:22

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Am I using "TraderRequest()" and "TraderBuy()" wrong?

Discussion on Am I using "TraderRequest()" and "TraderBuy()" wrong? within the GW Bots forum part of the Guild Wars category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Dec 2022
Posts: 3
Received Thanks: 0
Exclamation Am I using "TraderRequest()" and "TraderBuy()" wrong?

Hello,

I started a bot from scratch. Once done, I would like to share it.
I would like to have a function to buy ectos until the player has less than 10k.
I'm unsure whether the functions are broken or I am using them wrong.

My function:
Code:
Func BuyEcto()
  Local Const $Ecto = 930
  Local Const $mapid_<MaterialMap> = <ID>
  Local Const $mapid_<FarmingOutpost> = <ID>
  If GetMapID() <> $mapid_<MaterialMap> Then
    TravelTo($mapid_<MaterialMap>)
    WaitMapLoading($mapid_<MaterialMap>, 5000)
  EndIf
  Local $Trader = GetNearestNPCToCoords(X, Y)
  GoToNPC($Trader)
  Sleep(GetPing()+1000)
  While GetGoldCharacter() > 10000
    TraderRequest($Ecto)
    Sleep(GetPing()+250)
    TraderBuy()
  WEnd
  TravelTo($mapid_<FarmingOutpost>)
  WaitMapLoading($mapid_<FarmingOutpost>, 5000)
EndFunc
I added some console logs to track down potential errors:
Code:
Func BuyEcto()
  Out("Declare Ecto with its ID.")
  Local Const $Ecto = 930
  Out("Declared and set.")
  Out("Declare material map with its ID.")
  Local Const $mapid_<MaterialMap> = <ID>
  Out("Map declared1.")
  Out("Declare farming outpost with its ID.")
  Local Const $mapid_<FarmingOutpost> = <ID>
  Out("Map declared2.")
  If GetMapID() <> $mapid_<MaterialMap> Then
    Out("Going to MaterialMap.")
    TravelTo($mapid_<MaterialMap>)
    Out("At MaterialMap.")
    WaitMapLoading($mapid_<MaterialMap>, 5000)
    Out("MaterialMap loaded.")
  EndIf
  Out("Storing Rare Material Trader in $Trader.")
  Local $Trader = GetNearestNPCToCoords(X, Y)
  Out("Trader stored.")
  Out("Going to Trader.")
  GoToNPC($Trader)
  Out("At trader.")
  Sleep(GetPing()+1000)
  While GetGoldCharacter() > 10000
    Out("Gold over 10k.")
    Out("Requesting Ecto.")
    TraderRequest($Ecto)
    Out("Ecto requested.")
    Sleep(GetPing()+250)
    Out("Buying Ecto x1.")
    TraderBuy()
    Out("Ecto bought.")
  WEnd
  Out("Going to FarmingOutpost.")
  TravelTo($mapid_<FarmingOutpost>)
  Out("At FarmingOutpost.")
  WaitMapLoading($mapid_<FarmingOutpost>, 5000)
  Out("FarmingOutpost Loaded.")
EndFunc
Which logs the following lines:
Code:
Declare Ecto with its ID.
Declared and set.
Declare material map with its ID.
Map declared1.
Declare farming outpost with its ID.
Map declared2.
Going to MaterialMap.       //Player is teleported as intended.
At MaterialMap.
MaterialMap loaded.
Storing Rare Material Trader in $Trader.
Trader stored.
Going to Trader.            //Player goes to trader as intended.
At trader.                  //Trader window opens.
Gold over 10k.
Requesting Ecto.            //Nothing happens, not sure if there should be anything.
Buying Ecto x1.             //Nothing happens.
Ecto bought.                //No ecto bought. Gold didn't decrease.
Gold over 10k.              //The loop starts again. Trader window still open. Nothing happens.
Requesting Ecto.
Buying Ecto x1.
Ecto bought.
Gold over 10k.              //The loop goes on forever.
...etc...
Looked for both trading functions in "GWA2.au3". Are they outdated or am I used them wrong?
Here are the functions:
Code:
;~ Description: Request a quote to buy an item from a trader. Returns true if successful.
Func TraderRequest($aModelID, $aExtraID = -1)
  Local $lItemStruct = DllStructCreate('long Id;long AgentId;byte Unknown1[4];ptr Bag;ptr ModStruct;long ModStructSize;ptr Customized;byte unknown2[4];byte Type;byte unknown4;short ExtraId;short Value;byte unknown4[2];short Interaction;long ModelId;ptr ModString;byte unknown5[4];ptr NameString;ptr SingleItemName;byte Unknown4[10];byte IsSalvageable;byte Unknown6;byte Quantity;byte Equiped;byte Profession;byte Type2;byte Slot')

  Local $lOffset[4] = [0, 0x18, 0x40, 0xC0]
  Local $lItemArraySize = MemoryReadPtr($mBasePointer, $lOffset)
  Local $lOffset[5] = [0, 0x18, 0x40, 0xB8, 0]
  Local $lItemPtr, $lItemID
  Local $lFound = False
  Local $lQuoteID = MemoryRead($mTraderQuoteID)

  For $lItemID = 1 To $lItemArraySize[1]
    $lOffset[4] = 0x4 * $lItemID
    $lItemPtr = MemoryReadPtr($mBasePointer, $lOffset)
    If $lItemPtr[1] = 0 Then ContinueLoop
    DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandle, 'int', $lItemPtr[1], 'ptr', DllStructGetPtr($lItemStruct), 'int', DllStructGetSize($lItemStruct), 'int', '')
    If DllStructGetData($lItemStruct, 'ModelID') = $aModelID And DllStructGetData($lItemStruct, 'bag') = 0 And DllStructGetData($lItemStruct, 'AgentID') == 0 Then
      If $aExtraID = -1 Or DllStructGetData($lItemStruct, 'ExtraID') = $aExtraID Then
        $lFound = True
        ExitLoop
      EndIf
    EndIf
  Next
  If Not $lFound Then Return False

  DllStructSetData($mRequestQuote, 2, DllStructGetData($lItemStruct, 'ID'))
  Enqueue($mRequestQuotePtr, 8)

  Local $lDeadlock = TimerInit()
  $lFound = False
  Do
    Sleep(20)
    $lFound = MemoryRead($mTraderQuoteID) <> $lQuoteID
  Until $lFound Or TimerDiff($lDeadlock) > GetPing() + 5000
  Return $lFound
EndFunc   ;==>TraderRequest

;~ Description: Buy the requested item.
Func TraderBuy()
  If Not GetTraderCostID() Or Not GetTraderCostValue() Then Return False
  Enqueue($mTraderBuyPtr, 4)
  Return True
EndFunc   ;==>TraderBuy
Thank you in advance for any reply.
Have a great day,
James.
James3549 is offline  
Reply

Tags
ecto, issue., material, traderbuy(), traderrequest()


Similar Threads Similar Threads
Func TraderRequest + TraderBuy
05/07/2024 - GW Bots - 9 Replies
Hello everybody, I have been trying to get the Function TraderRequest work. But it doesn't work. While GetGoldCharacter() > 20*1000 TraderRequest(930) TraderBuy() Sleep(500 + 3 * GetPing()) WEnd
WEAPONSCRIPT!!!!!!!!!!!!!!!!!!!!!!!!!HOT"""""""""" """""""""""""""""""""
08/06/2011 - WarRock Hacks, Bots, Cheats & Exploits - 7 Replies
detetected



All times are GMT +2. The time now is 12:22.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.