Store stackable items

03/21/2022 21:49 Backxtar#1
Hey, this storage function is working only for single items.. how can i store stackable items?

Code:
If FindEmptyStorageSlot($lStorageNumber, $lSlotNumber) Then
					Out("Storing item [" & $I & "," & $J & "]")
					MoveItem($lItem, $lStorageNumber, $lSlotNumber)
					Do
						RndSleep(GetPing() + 1000)
					Until DllStructGetData(GetItemBySlot($lStorageNumber, $lSlotNumber), "ID") <> 0
				EndIf
03/24/2022 23:49 afmart#2
just moving the item should do it, at least according to some old code

If FindEmptyStorageSlot($lStorageNumber, $lSlotNumber) Then
MoveItem($lItem, $lStorageNumber, $lSlotNumber)
EndIf

you can also check the amount and only move it if its full (250)
DllStructGetData($lItem, "quantity")
03/26/2022 08:53 Backxtar#3
Quote:
Originally Posted by afmart View Post
just moving the item should do it, at least according to some old code

If FindEmptyStorageSlot($lStorageNumber, $lSlotNumber) Then
MoveItem($lItem, $lStorageNumber, $lSlotNumber)
EndIf

you can also check the amount and only move it if its full (250)
DllStructGetData($lItem, "quantity")
Solved the problem with arrays :)
04/04/2022 20:12 afmart#4
ok,
please note there should be 3 different headers
$MoveItemHeader
$AcceptAllItemsHeader
$MoveItemSplitHeader

I dont have the current values for headers or patterns and dont have the time to look into it. Maybe i'll do it during the summer.

this a funcion that was available in bots shared back in 2018.
Code:
Func MoveItem(Const ByRef $aItem, $aBag, $aSlot, $aAmount = 0)
	Local $lItemPtr = GetItemPtr($aItem)
	Local $lItemStruct = GetItemByPtr($lItemPtr)
	Local $lQuantity = GetItemProperty($lItemStruct, 'Quantity')
	Local $lBagPtr = GetBagPtr($aBag)
	Local $lBagStruct = GetBag($lBagPtr)
	If $lItemStruct = 0 Or $lBagStruct = 0 Then Return False
	If $aAmount = 0 Or $aAmount > $lQuantity Then $aAmount = $lQuantity
	Local $lFromSlot = GetItemProperty($lItemStruct, 'Slot')
	Local $lFromBag = GetItemProperty($lItemStruct, 'Bag')
	If $aAmount >= $lQuantity Then
		SendPacket(0x10, $MoveItemHeader, GetItemProperty($lItemStruct, 'Id'), GetBagProperty($lBagStruct, 'Id'), $aSlot - 1)
	Else
		SendPacket(0x14, $MoveItemSplitHeader, GetItemProperty($lItemStruct, 'Id'), $aAmount, GetBagProperty($lBagStruct, 'Id'), $aSlot - 1)
	EndIf
	Local $lDeadlock = TimerInit()
	Do 
		Sleep(50)
		If GetItemProperty($lItemPtr, 'Quantity') <> $lQuantity Then Return True
		If GetItemProperty($lItemPtr, 'Bag') <> $lFromBag Then Return True
		If GetItemProperty($lItemPtr, 'Slot') <> $lFromSlot Then Return True
	Until TimerDiff($lDeadlock) > 5000
	Return False
EndFunc