Yea i understand that, maybe i'll try to figure out myself what's wrong with that :D
Hmm i commented all OpenStorageWindow() calls out and it still doesn't work, it crashes right after the StoreItems function is called.
I think it has to do with one of these functions:
Func UpdateEmptyStorageSlot(ByRef $aBagNr, ByRef $aSlot)
If $aBagNr = 0 Then
$lBagNr = 8
Else
$lBagNr = $aBagNr
EndIf
If $aSlot = 0 Then
$lSlot = 1
Else
$lSlot = $aSlot
EndIf
$aBagNr = 0
$aSlot = 0
For $bag = $lBagNr To 16
$lBagPtr = GetBagPtr($bag)
If $lBagPtr = 0 Then Return 0 ; no bag
For $slot = $lSlot To 20
$lSlotPtr = GetItemPtrBySlot($lBagPtr, $slot)
If $lSlotPtr = 0 Then
$aBagNr = $bag
$aSlot = $slot
Return True
EndIf
Next
$lSlot = 1
Next
EndFunc ;==>UpdateEmptyStorageSlot
Func MoveItem($aItem, $aBag, $aSlot)
If IsPtr($aItem) <> 0 Then
Local $lItemID = MemoryRead($aItem, 'long')
ElseIf IsDllStruct($aItem) <> 0 Then
Local $lItemID = DllStructGetData($aItem, 'ID')
Else
Local $lItemID = $aItem
EndIf
If IsPtr($aBag) <> 0 Then
Local $lBagID = MemoryRead($aBag + 8, 'long')
ElseIf IsDllStruct($aBag) <> 0 Then
Local $lBagID = DllStructGetData($aBag, 'ID')
Else
Local $lBagID = MemoryRead(GetBagPtr($aBag) + 8, 'long')
EndIf
Return SendPacket(0x10, $HEADER_ITEM_MOVE, $lItemID, $lBagID, $aSlot - 1)
EndFunc ;==>MoveItem
and the StoreItems function:
Func StoreItems()
$mStoreMaterials = true
UpdateEmptyStorageSlot($mEmptyBag, $mEmptySlot)
Update("Empty Spot: " & $mEmptyBag & ", " & $mEmptySlot)
If $mEmptySlot = 0 Then Return ; no more empty slots found
;~ OpenStorageWindow()
For $bag = 1 To 4 ; inventory only
$lBagPtr = GetBagPtr($bag)
If $lBagPtr = 0 Then ContinueLoop ; empty bag slot
$lItemArrayPtr = MemoryRead($lBagPtr + 24, 'ptr')
For $slot = 0 To MemoryRead($lBagPtr + 32, 'long') - 1
$lItemPtr = MemoryRead($lItemArrayPtr + 4 * ($slot), 'ptr')
If $lItemPtr = 0 Then ContinueLoop ; empty slot
$lItemID = MemoryRead($lItemPtr, 'long')
$lItemType = MemoryRead($lItemPtr + 32, 'byte')
$lItemQuantity = MemoryRead($lItemPtr + 75, 'byte')
$lItemMID = MemoryRead($lItemPtr + 44, 'long')
If $lItemType = 11 And $lItemQuantity = 250 And $mStoreMaterials Then ; materials
If $lItemMID = 948 or $lItemMID = 929 or $lItemMID = 933 or $lItemMID = 934 or $lItemMID = 921 Then
Update("Store Materials: " & $bag & ", " & $slot & " -> " & $mEmptyBag & ", " & $mEmptySlot)
MoveItem($lItemID, $mEmptyBag, $mEmptySlot)
Do
Sleep(250)
Until MemoryRead($lItemArrayPtr + 4 * ($slot), 'ptr') = 0
UpdateEmptyStorageSlot($mEmptyBag, $mEmptySlot)
If $mEmptySlot = 0 Then Return
ContinueLoop
EndIf
EndIf
If StackableItems($lItemMID) And $lItemQuantity = 250 Then ; only full stacks
Update("Store Stack: " & $bag & ", " & $slot & " -> " & $mEmptyBag & ", " & $mEmptySlot)
MoveItem($lItemID, $mEmptyBag, $mEmptySlot)
Do
Sleep(250)
Until MemoryRead($lItemArrayPtr + 4 * ($slot), 'ptr') = 0
UpdateEmptyStorageSlot($mEmptyBag, $mEmptySlot)
If $mEmptySlot = 0 Then Return
ContinueLoop
EndIf
If Keepers($lItemMID) Then
Update("Store Keepers: " & $bag & ", " & $slot & " -> " & $mEmptyBag & ", " & $mEmptySlot)
MoveItem($lItemID, $mEmptyBag, $mEmptySlot)
Do
Sleep(250)
Until MemoryRead($lItemArrayPtr + 4 * ($slot), 'ptr') = 0
UpdateEmptyStorageSlot($mEmptyBag, $mEmptySlot)
If $mEmptySlot = 0 Then Return ; no more empty slots
ContinueLoop
EndIf
If $mStoreGold And GetRarity($lItemPtr) = 2624 Then ; store unident golds if possible
Update("Store Golds: " & $bag & ", " & $slot & " -> " & $mEmptyBag & ", " & $mEmptySlot)
MoveItem($lItemID, $mEmptyBag, $mEmptySlot)
Do
Sleep(250)
Until MemoryRead($lItemArrayPtr + 4 * ($slot), 'ptr') = 0
UpdateEmptyStorageSlot($mEmptyBag, $mEmptySlot)
If $mEmptySlot = 0 Then Return ; no more empty slots
ContinueLoop
EndIf
Next
Next
EndFunc ;==>StoreItems