So i've been thinking about making a trading bot for daily use, and ive got it sorted with some functions, but the one function that doesnt seems to work is OfferItem. Ive found 2 different ones, 1 from the old gwApi and one from another bot.
Anyone of you know any working offeritem function out there? would be lovely to get a tradebot going to spend less time in kamada
Code:
Func OfferItem($aItemID, $aQuantity = 1)
If IsPtr($aItemID) <> 0 Then
Local $lItemID = MemoryRead($aItemID, 'long')
Local $lQuantity = MemoryRead($aItemID + 75, 'byte')
ElseIf IsDllStruct($aItemID) <> 0 Then
Local $lItemID = DllStructGetData($aItemID, 'ID')
Local $lQuantity = DllStructGetData($aItemID, 'Quantity')
Else
Local $lItemID = $aItemID
Local $lQuantity = MemoryRead(GetItemPtr($aItemID) + 75, 'byte')
EndIf
If $aQuantity > $lQuantity Then
Return SendPacket(0xC, $HEADER_TRADE_OFFER_ITEM, $lItemID, $lQuantity)
Else
Return SendPacket(0xC, $HEADER_TRADE_OFFER_ITEM, $lItemID, $aQuantity)
EndIf
EndFunc ;==>OfferItem
Func getitemptr($aitemid)
Local $loffset[5] = [0, 24, 64, 184, 4 * $aitemid]
Local $litemstructaddress = memoryreadptr($mbasepointer, $loffset, "ptr")
Return $litemstructaddress[1]
EndFunc ;==>getitemptr
Func OfferItem2($aItem, $aAmount = 0)
Local $lItemID, $lAmount
If IsDllStruct($aItem) = 0 Then
$lItemID = $aItem
If $aAmount > 0 Then
$lAmount = $aAmount
Else
$lAmount = DllStructGetData(GetItemByItemID($aItem), 'Quantity')
EndIf
Else
$lItemID = DllStructGetData($aItem, 'ID')
If $aAmount > 0 Then
$lAmount = $aAmount
Else
$lAmount = DllStructGetData($aItem, 'Quantity')
EndIf
EndIf
SendPacket(0xC, $HEADER_TRADE_OFFER_ITEM, $lItemID, $lAmount)
EndFunc ;==>OfferItem2