Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

EO 2.0 - Stackable Items with Limit


Sicarii
 Share

Recommended Posts

**known issues:
1\. Small fix needed for Shops to work correctly…should be updated 03/24/12**

I don't know if there is a better way to do this but this does work.  It was a major learning process.  I've tried to debug as much as possible and I haven't been able to make anything screw up so figured I'd share it.

This will allow you to have all items stack to a limit that you set.

**FORM**
**Client - frmEditor_Item - (View Object)**
Add a label entitled "lblStackLimit" with a caption of "Stack Limit: 0"

Add a horizontal scroll bar entitled "scrlStackLimit" with a Min of 0 and a Max of 25 (This is where you set the maximum amount)

(Refer to attachment for form screenshot)

**CLIENT**
**Client - frmEditor_Item - Private Sub cmbType_Click**
Below this…
```
If EditorIndex = 0 Or EditorIndex > MAX_ITEMS Then Exit Sub

```
…add this:
```
If cmbType.ListIndex <> ITEM_TYPE_CURRENCY Then
    frmEditor_Item.lblStackLimit.Visible = True
    frmEditor_Item.scrlStackLimit.Visible = True
    lblStackLimit.Caption = "Stack Limit: " & scrlStackLimit.Value
End If

```
Below this…
```
If (cmbType.ListIndex = ITEM_TYPE_SPELL) Then
    fraSpell.Visible = True
Else
    fraSpell.Visible = False
End If

```
…add this:
```
If cmbType.ListIndex = ITEM_TYPE_CURRENCY Then
    frmEditor_Item.scrlStackLimit.Visible = False
    frmEditor_Item.lblStackLimit.Visible = False
End If

```
**Client - frmEditor_Item - Private Sub scrlStackLimit_Change**
```
Private Sub scrlStackLimit_Change()
    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    If EditorIndex = 0 Or EditorIndex > MAX_ITEMS Then Exit Sub
    lblStackLimit.Caption = "Stack Limit: " & scrlStackLimit.Value
    Item(EditorIndex).StackLimit = scrlStackLimit.Value

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "scrlStackLimit_Change", "frmEditor_Item", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub

```
**Client - frmEditor_Map - Private Sub scrlMapItem_Change**
Replace this…
```
If Item(scrlMapItem.Value).Type = ITEM_TYPE_CURRENCY Then
    scrlMapItemValue.Enabled = True
Else
    scrlMapItemValue.Value = 1
    scrlMapItemValue.Enabled = False
End If

```
…with this:
```
scrlMapItemValue.Enabled = True

```
**Client - frmMain - Private Sub lblCurrencyOK_Click**

If you have applied the 'Currency menu overflow' fix:
```
If Val(txtCurrency.text) > GetPlayerInvItemValue(MyIndex, tmpCurrencyItem) Then txtCurrency.text = GetPlayerInvItemValue(MyIndex, tmpCurrencyItem)

```
You'll need to take it out.  I just commented it out and planned on coming back to address the issue at a later date.

**Client - frmMain - Private Sub picBank_DblClick**
Replace this…
```
If Item(GetBankItemNum(bankNum)).Type = ITEM_TYPE_CURRENCY Then
    CurrencyMenu = 3 ' withdraw
    lblCurrency.Caption = "How many do you want to withdraw?"
    tmpCurrencyItem = bankNum
    txtCurrency.text = vbNullString
    picCurrency.Visible = True
    txtCurrency.SetFocus
    Exit Sub
End If

```
…with this:
```
CurrencyMenu = 3 ' withdraw
lblCurrency.Caption = "How many do you want to withdraw?"
tmpCurrencyItem = bankNum
txtCurrency.text = vbNullString
picCurrency.Visible = True
txtCurrency.SetFocus
Exit Sub

```
**Client - frmMain - Private Sub picInventory_DblClick**
Replace this…
```
If Item(GetPlayerInvItemNum(MyIndex, InvNum)).Type = ITEM_TYPE_CURRENCY Then
    CurrencyMenu = 2 ' deposit
    lblCurrency.Caption = "How many do you want to deposit?"
    tmpCurrencyItem = InvNum
    txtCurrency.text = vbNullString
    picCurrency.Visible = True
    txtCurrency.SetFocus
    Exit Sub
End If

```
…with this:
```
    CurrencyMenu = 2 ' deposit
    lblCurrency.Caption = "How many do you want to deposit?"
    tmpCurrencyItem = InvNum
    txtCurrency.text = vbNullString
    picCurrency.Visible = True
    txtCurrency.SetFocus
    Exit Sub

```
Replace this…
```
If Item(GetPlayerInvItemNum(MyIndex, TradeYourOffer(i).num)).Type = ITEM_TYPE_CURRENCY Then
    ' only exit out if we're offering all of it
    If TradeYourOffer(i).Value = GetPlayerInvItemValue(MyIndex, TradeYourOffer(i).num) Then
        Exit Sub
    End If
Else
    Exit Sub
End If

```
…with this:
```
If TradeYourOffer(i).Value = GetPlayerInvItemValue(MyIndex, TradeYourOffer(i).num) Then
    Exit Sub
End If

```
Replace this…
```
If Item(GetPlayerInvItemNum(MyIndex, InvNum)).Type = ITEM_TYPE_CURRENCY Then
    CurrencyMenu = 4 ' offer in trade
    lblCurrency.Caption = "How many do you want to trade?"
    tmpCurrencyItem = InvNum
    txtCurrency.text = vbNullString
    picCurrency.Visible = True
    txtCurrency.SetFocus
    Exit Sub
End If

```
…with this:
```
    CurrencyMenu = 4 ' offer in trade
    lblCurrency.Caption = "How many do you want to trade?"
    tmpCurrencyItem = InvNum
    txtCurrency.text = vbNullString
    picCurrency.Visible = True
    txtCurrency.SetFocus
    Exit Sub

```
**Client - frmMain - Private Sub picInventory_MouseDown**

Replace this…
```
If Item(GetPlayerInvItemNum(MyIndex, InvNum)).Type = ITEM_TYPE_CURRENCY Then
    If GetPlayerInvItemValue(MyIndex, InvNum) > 0 Then
        CurrencyMenu = 1 ' drop
        lblCurrency.Caption = "How many do you want to drop?"
        tmpCurrencyItem = InvNum
        txtCurrency.text = vbNullString
        picCurrency.Visible = True
        txtCurrency.SetFocus
    End If
Else
    Call SendDropItem(InvNum, 0)
End If

```
…with this:
```
If GetPlayerInvItemValue(MyIndex, InvNum) > 0 Then
    CurrencyMenu = 1 ' drop
    lblCurrency.Caption = "How many do you want to drop?"
    tmpCurrencyItem = InvNum
    txtCurrency.text = vbNullString
    picCurrency.Visible = True
    txtCurrency.SetFocus
End If

```
**Client - frmMain - Private Sub picInventory_MouseMove**

Replace this…
```
If Item(GetPlayerInvItemNum(MyIndex, TradeYourOffer(i).num)).Type = ITEM_TYPE_CURRENCY Then
    ' only exit out if we're offering all of it
    If TradeYourOffer(i).Value = GetPlayerInvItemValue(MyIndex, TradeYourOffer(i).num) Then
        Exit Sub
    End If
Else
    Exit Sub
End If

```
…with this:
```
If TradeYourOffer(i).Value = GetPlayerInvItemValue(MyIndex, TradeYourOffer(i).num) Then
    Exit Sub
End If

```
**Client - frmMain - Private Sub scrlAItem_Change**

Replace this…
```
If Item(scrlAItem.Value).Type = ITEM_TYPE_CURRENCY Then
    scrlAAmount.Enabled = True
    Exit Sub
End If

```
…with this:
```
scrlAAmount.Enabled = True
Exit Sub

```
**Client - modClientTCP - Public Sub SendDropItem**

Replace this…
```
If Item(GetPlayerInvItemNum(MyIndex, InvNum)).Type = ITEM_TYPE_CURRENCY Then
    If Amount < 1 Or Amount > PlayerInv(InvNum).Value Then Exit Sub
End If

```
…with this:
```
If Amount < 1 Or Amount > PlayerInv(InvNum).Value Then Exit Sub

```
**Client - modDirectDraw7 - Sub BltInventory**

Replace this…
```
If Not Item(tmpItem).Type = ITEM_TYPE_CURRENCY Then
    ' normal item, exit out
    GoTo NextLoop
Else
    ' if amount = all currency, remove from inventory
    If TradeYourOffer(x).Value = GetPlayerInvItemValue(MyIndex, i) Then
        GoTo NextLoop
    Else
        ' not all, change modifier to show change in currency count
        amountModifier = TradeYourOffer(x).Value
    End If
End If

```
…with this:
```
If TradeYourOffer(x).Value = GetPlayerInvItemValue(MyIndex, i) Then
    GoTo NextLoop
Else
    ' not all, change modifier to show change in currency count
    amountModifier = TradeYourOffer(x).Value
End If

```
**Client - modGameEditors - Public Sub ItemEditorInit**

Below this…
```
If (frmEditor_Item.cmbType.ListIndex = ITEM_TYPE_SPELL) Then
    frmEditor_Item.fraSpell.Visible = True
    frmEditor_Item.scrlSpell.Value = .Data1
Else
    frmEditor_Item.fraSpell.Visible = False
End If

```
…add this:
```
If (frmEditor_Item.cmbType.ListIndex <> ITEM_TYPE_CURRENCY) Then
    frmEditor_Item.lblStackLimit.Visible = True
    frmEditor_Item.scrlStackLimit.Visible = True
Else
    frmEditor_Item.scrlStackLimit.Visible = False
    frmEditor_Item.lblStackLimit.Visible = False
End If

```
Below this…
```
frmEditor_Item.scrlRarity.Value = .Rarity

```
…add this:
```
frmEditor_Item.scrlStackLimit.Value = .StackLimit

```
**Client - modTypes - Private Type ItemRec**
Below this…
```
instaCast as Byte

```
…add this
```
StackLimit As Long

```

**SERVER**

**Server - modGameLogic - Sub PlayerUnequipItem**

Replace this…
```
GiveInvItem Index, GetPlayerEquipment(Index, EqSlot), 0

```
…with this:
```
GiveInvItem Index, GetPlayerEquipment(Index, EqSlot), 1

```
**Server - modGameLogic - Sub SpawnMapItems**

Replace this…
```
If Item(Map(mapNum).Tile(x, y).Data1).Type = ITEM_TYPE_CURRENCY And Map(mapNum).Tile(x, y).Data2 <= 0 Then

```
…with this:
```
If Map(mapNum).Tile(x, y).Data2 <= 0 Then

```
**Server - modHandleData - Sub HandleMapDropItem**

Replace this…
```
If Item(GetPlayerInvItemNum(index, invNum)).Type = ITEM_TYPE_CURRENCY Then
    If amount < 1 Or amount > GetPlayerInvItemValue(index, invNum) Then Exit Sub
End If

```
…with this:
```
If amount < 1 Or amount > GetPlayerInvItemValue(Index, invNum) Then Exit Sub

```
**Server - modHandleData - Sub HandleTradeItem**

Replace this…
```
If Item(itemnum).Type = ITEM_TYPE_CURRENCY Then
    ' check if already offering same currency item
    For i = 1 To MAX_INV
        If TempPlayer(index).TradeOffer(i).Num = invSlot Then
            ' add amount
            TempPlayer(index).TradeOffer(i).Value = TempPlayer(index).TradeOffer(i).Value + amount
            ' clamp to limits
            If TempPlayer(index).TradeOffer(i).Value > GetPlayerInvItemValue(index, invSlot) Then
                TempPlayer(index).TradeOffer(i).Value = GetPlayerInvItemValue(index, invSlot)
            End If
            ' cancel any trade agreement
            TempPlayer(index).AcceptTrade = False
            TempPlayer(TempPlayer(index).InTrade).AcceptTrade = False

            SendTradeStatus index, 0
            SendTradeStatus TempPlayer(index).InTrade, 0

            SendTradeUpdate index, 0
            SendTradeUpdate TempPlayer(index).InTrade, 1
            ' exit early
            Exit Sub
        End If
    Next
Else
    ' make sure they're not already offering it
    For i = 1 To MAX_INV
        If TempPlayer(index).TradeOffer(i).Num = invSlot Then
            PlayerMsg index, "You've already offered this item.", BrightRed
            Exit Sub
        End If
    Next
End If

```
…with this:
```
For i = 1 To MAX_INV
    If TempPlayer(Index).TradeOffer(i).Num = invSlot Then
        ' add amount
        TempPlayer(Index).TradeOffer(i).Value = TempPlayer(Index).TradeOffer(i).Value + amount
        ' clamp to limits
        If TempPlayer(Index).TradeOffer(i).Value > GetPlayerInvItemValue(Index, invSlot) Then
                TempPlayer(Index).TradeOffer(i).Value = GetPlayerInvItemValue(Index, invSlot)
        End If
        ' cancel any trade agreement
        TempPlayer(Index).AcceptTrade = False
        TempPlayer(TempPlayer(Index).InTrade).AcceptTrade = False

        SendTradeStatus Index, 0
        SendTradeStatus TempPlayer(Index).InTrade, 0

        SendTradeUpdate Index, 0
        SendTradeUpdate TempPlayer(Index).InTrade, 1
        ' exit early
        Exit Sub
    End If
Next

```
**Server - modPlayer - Function FindOpenBankSlot**

Replace this…
```
For i = 1 To MAX_BANK
    If GetPlayerBankItemNum(index, i) = itemnum Then
        FindOpenBankSlot = i
        Exit Function
    End If
Next i

```
…with this:
```
If Item(ItemNum).Type = ITEM_TYPE_CURRENCY Then
    For i = 1 To MAX_BANK
        If GetPlayerBankItemNum(Index, i) = ItemNum Then
            FindOpenBankSlot = i
            Exit Function
        End If
    Next
End If
For i = 1 To MAX_BANK
If Item(ItemNum).Type <> ITEM_TYPE_CURRENCY Then
    If GetPlayerBankItemValue(Index, i) > 0 And GetPlayerBankItemNum(Index, i) = ItemNum Then
        If GetPlayerBankItemValue(Index, i) < Item(GetPlayerBankItemNum(Index, i)).StackLimit Then
            FindOpenBankSlot = i
            Exit Function
        End If
    End If
End If
Next

```
**Server - modPlayer - Function FindOpenInvSlot**

After this…
```
If Item(itemnum).Type = ITEM_TYPE_CURRENCY Then

    ' If currency then check to see if they already have an instance of the item and add it to that
    For i = 1 To MAX_INV

        If GetPlayerInvItemNum(index, i) = itemnum Then
            FindOpenInvSlot = i
            Exit Function
        End If

    Next

End If

```
…insert this:
```
For i = 1 To MAX_INV
    If Item(ItemNum).Type <> ITEM_TYPE_CURRENCY Then
        If GetPlayerInvItemValue(Index, i) > 0 And GetPlayerInvItemNum(Index, i) = ItemNum Then
            If GetPlayerInvItemValue(Index, i) < Item(GetPlayerInvItemNum(Index, i)).StackLimit Then
                FindOpenInvSlot = i
                Exit Function
            End If
        End If
    End If
Next

```
**Server - modPlayer - Sub GiveBankItem**

Replace this…
```
BankSlot = FindOpenBankSlot(index, GetPlayerInvItemNum(index, invSlot))

If BankSlot > 0 Then
    If Item(GetPlayerInvItemNum(index, invSlot)).Type = ITEM_TYPE_CURRENCY Then
        If GetPlayerBankItemNum(index, BankSlot) = GetPlayerInvItemNum(index, invSlot) Then
            Call SetPlayerBankItemValue(index, BankSlot, GetPlayerBankItemValue(index, BankSlot) + amount)
            Call TakeInvItem(index, GetPlayerInvItemNum(index, invSlot), amount)
        Else
            Call SetPlayerBankItemNum(index, BankSlot, GetPlayerInvItemNum(index, invSlot))
            Call SetPlayerBankItemValue(index, BankSlot, amount)
            Call TakeInvItem(index, GetPlayerInvItemNum(index, invSlot), amount)
        End If
    Else
        If GetPlayerBankItemNum(index, BankSlot) = GetPlayerInvItemNum(index, invSlot) Then
            Call SetPlayerBankItemValue(index, BankSlot, GetPlayerBankItemValue(index, BankSlot) + 1)
            Call TakeInvItem(index, GetPlayerInvItemNum(index, invSlot), 0)
        Else
            Call SetPlayerBankItemNum(index, BankSlot, GetPlayerInvItemNum(index, invSlot))
            Call SetPlayerBankItemValue(index, BankSlot, 1)
            Call TakeInvItem(index, GetPlayerInvItemNum(index, invSlot), 0)
        End If
    End If
End If

```
…with this:
```
FindAnotherGiveBankItemSlot:

    BankSlot = FindOpenBankSlot(Index, GetPlayerInvItemNum(Index, invSlot))

    If BankSlot > 0 Then
        If Item(GetPlayerInvItemNum(Index, invSlot)).Type = ITEM_TYPE_CURRENCY Then
            If GetPlayerBankItemNum(Index, BankSlot) = GetPlayerInvItemNum(Index, invSlot) Then
                Call SetPlayerBankItemValue(Index, BankSlot, GetPlayerBankItemValue(Index, BankSlot) + amount)
                Call TakeInvItem(Index, GetPlayerInvItemNum(Index, invSlot), amount)
            Else
                Call SetPlayerBankItemNum(Index, BankSlot, GetPlayerInvItemNum(Index, invSlot))
                Call SetPlayerBankItemValue(Index, BankSlot, amount)
                Call TakeInvItem(Index, GetPlayerInvItemNum(Index, invSlot), amount)
            End If
        Else
            If Item(GetPlayerInvItemNum(Index, invSlot)).Type <> ITEM_TYPE_CURRENCY Then
                If GetPlayerBankItemValue(Index, BankSlot) >= 1 Then
                    If amount + GetPlayerBankItemValue(Index, BankSlot) <= Item(GetPlayerInvItemNum(Index, invSlot)).StackLimit Then
                        Call SetPlayerBankItemValue(Index, BankSlot, GetPlayerBankItemValue(Index, BankSlot) + amount)
                            If GetPlayerInvItemValue(Index, invSlot) - amount = 0 Then
                                Call SetPlayerInvItemNum(Index, invSlot, 0)
                                Call SetPlayerInvItemValue(Index, invSlot, 0)
                                Call SendInventoryUpdate(Index, invSlot)
                            Else
                                Call SetPlayerInvItemValue(Index, invSlot, GetPlayerInvItemValue(Index, invSlot) - amount)
                                Call SendInventoryUpdate(Index, invSlot)
                            End If
                    Else
                        If amount + GetPlayerBankItemValue(Index, BankSlot) > Item(GetPlayerInvItemNum(Index, invSlot)).StackLimit Then
                            amount = amount - (Item(GetPlayerInvItemNum(Index, invSlot)).StackLimit - GetPlayerBankItemValue(Index, BankSlot))
                            Call SetPlayerInvItemValue(Index, invSlot, GetPlayerInvItemValue(Index, invSlot) - (Item(GetPlayerInvItemNum(Index, invSlot)).StackLimit - GetPlayerBankItemValue(Index, BankSlot)))
                            Call SendInventoryUpdate(Index, invSlot)
                            Call SetPlayerBankItemValue(Index, BankSlot, Item(GetPlayerInvItemNum(Index, invSlot)).StackLimit)
                            GoTo FindAnotherGiveBankItemSlot
                        End If
                    End If
                Else
                    If GetPlayerBankItemValue(Index, BankSlot) = 0 Then
                        If amount <= Item(GetPlayerInvItemNum(Index, invSlot)).StackLimit Then
                            Call SetPlayerBankItemNum(Index, BankSlot, GetPlayerInvItemNum(Index, invSlot))
                            Call SetPlayerBankItemValue(Index, BankSlot, GetPlayerBankItemValue(Index, BankSlot) + amount)
                                If GetPlayerInvItemValue(Index, invSlot) - amount = 0 Then
                                    Call SetPlayerInvItemNum(Index, invSlot, 0)
                                    Call SetPlayerInvItemValue(Index, invSlot, 0)
                                    Call SendInventoryUpdate(Index, invSlot)
                                Else
                                    Call SetPlayerInvItemValue(Index, invSlot, GetPlayerInvItemValue(Index, invSlot) - amount)
                                    Call SendInventoryUpdate(Index, invSlot)
                                End If
                        End If
                    End If
                End If
            End If
        End If
    End If

```
**Server - modPlayer - Function GiveInvItem**

Replace this…
```
i = FindOpenInvSlot(index, itemnum)

' Check to see if inventory is full
If i <> 0 Then
    Call SetPlayerInvItemNum(index, i, itemnum)
    Call SetPlayerInvItemValue(index, i, GetPlayerInvItemValue(index, i) + ItemVal)
    If sendUpdate Then Call SendInventoryUpdate(index, i)
    GiveInvItem = True
Else
    Call PlayerMsg(index, "Your inventory is full.", BrightRed)
    GiveInvItem = False
End If

```
…with this:
```
FindAnotherGiveInvItemSlot:

    i = FindOpenInvSlot(Index, ItemNum)

    ' Check to see if inventory is full
    If i <> 0 Then
        If Item(ItemNum).Type = ITEM_TYPE_CURRENCY Then
            Call SetPlayerInvItemNum(Index, i, ItemNum)
            Call SetPlayerInvItemValue(Index, i, GetPlayerInvItemValue(Index, i) + ItemVal)
            If sendUpdate Then Call SendInventoryUpdate(Index, i)
            GiveInvItem = True
            Exit Function
        End If
        If GetPlayerInvItemValue(Index, i) = 0 Then
            If ItemVal >= 1 Then
                ItemVal = ItemVal - 1
                Call SetPlayerInvItemNum(Index, i, ItemNum)
                Call SetPlayerInvItemValue(Index, i, GetPlayerInvItemValue(Index, i) + 1)
                If sendUpdate Then Call SendInventoryUpdate(Index, i)
                GiveInvItem = True
                GoTo FindAnotherGiveInvItemSlot
            Else
                Call SetPlayerInvItemNum(Index, i, ItemNum)
                Call SetPlayerInvItemValue(Index, i, GetPlayerInvItemValue(Index, i) + ItemVal)
                If sendUpdate Then Call SendInventoryUpdate(Index, i)
                GiveInvItem = True
            End If
        Else
            If GetPlayerInvItemValue(Index, i) > 0 Then
                If GetPlayerInvItemValue(Index, i) + ItemVal <= Item(GetPlayerInvItemNum(Index, i)).StackLimit Then
                    Call SetPlayerInvItemNum(Index, i, ItemNum)
                    Call SetPlayerInvItemValue(Index, i, GetPlayerInvItemValue(Index, i) + ItemVal)
                    If sendUpdate Then Call SendInventoryUpdate(Index, i)
                    GiveInvItem = True
                Else
                    If GetPlayerInvItemValue(Index, i) + ItemVal > Item(GetPlayerInvItemNum(Index, i)).StackLimit Then
                        ItemVal = ItemVal - (Item(GetPlayerInvItemNum(Index, i)).StackLimit - GetPlayerInvItemValue(Index, i))
                        Call SetPlayerInvItemNum(Index, i, ItemNum)
                        Call SetPlayerInvItemValue(Index, i, Item(GetPlayerInvItemNum(Index, i)).StackLimit)
                        If sendUpdate Then Call SendInventoryUpdate(Index, i)
                        GiveInvItem = True
                        GoTo FindAnotherGiveInvItemSlot
                    End If
                End If
            End If
        End If
    Else
        Call PlayerMsg(Index, "Your inventory is full.", BrightRed)
        GiveInvItem = False
    End If

```
**Server - modPlayer - Function HasItem**

Replace this…
```
If Item(itemnum).Type = ITEM_TYPE_CURRENCY Then
    HasItem = GetPlayerInvItemValue(index, i)
Else
    HasItem = 1
End If

```
…with this:
```
HasItem = GetPlayerInvItemValue(Index, i)

```
**Server - modPlayer - Sub PlayerMapDropItem**

Replace this…
```
If Item(GetPlayerInvItemNum(index, invNum)).Type = ITEM_TYPE_CURRENCY Then

    ' Check if its more then they have and if so drop it all
    If amount >= GetPlayerInvItemValue(index, invNum) Then
        MapItem(GetPlayerMap(index), i).Value = GetPlayerInvItemValue(index, invNum)
        Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & " drops " & GetPlayerInvItemValue(index, invNum) & " " & Trim$(Item(GetPlayerInvItemNum(index, invNum)).Name) & ".", Yellow)
        Call SetPlayerInvItemNum(index, invNum, 0)
        Call SetPlayerInvItemValue(index, invNum, 0)
    Else
        MapItem(GetPlayerMap(index), i).Value = amount
        Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & " drops " & amount & " " & Trim$(Item(GetPlayerInvItemNum(index, invNum)).Name) & ".", Yellow)
        Call SetPlayerInvItemValue(index, invNum, GetPlayerInvItemValue(index, invNum) - amount)
    End If

Else
    ' Its not a currency object so this is easy
    MapItem(GetPlayerMap(index), i).Value = 0
    ' send message
    Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & " drops " & CheckGrammar(Trim$(Item(GetPlayerInvItemNum(index, invNum)).Name)) & ".", Yellow)
    Call SetPlayerInvItemNum(index, invNum, 0)
    Call SetPlayerInvItemValue(index, invNum, 0)
End If

```
…with this:
```
If amount >= GetPlayerInvItemValue(Index, invNum) Then
    MapItem(GetPlayerMap(Index), i).Value = GetPlayerInvItemValue(Index, invNum)
    Call MapMsg(GetPlayerMap(Index), GetPlayerName(Index) & " drops " & GetPlayerInvItemValue(Index, invNum) & " " & Trim$(Item(GetPlayerInvItemNum(Index, invNum)).Name) & ".", Yellow)
    Call SetPlayerInvItemNum(Index, invNum, 0)
    Call SetPlayerInvItemValue(Index, invNum, 0)
Else
    MapItem(GetPlayerMap(Index), i).Value = amount
    Call MapMsg(GetPlayerMap(Index), GetPlayerName(Index) & " drops " & amount & " " & Trim$(Item(GetPlayerInvItemNum(Index, invNum)).Name) & ".", Yellow)
    Call SetPlayerInvItemValue(Index, invNum, GetPlayerInvItemValue(Index, invNum) - amount)
End If

```
**Server - modPlayer - Sub PlayerMapGetItem**

Below this…
```
If (MapItem(mapNum, i).y = GetPlayerY(index)) Then

```
…add this:
```
FindAnotherPlayerMapGetItemSlot:

```
Replace this…
```
If Item(GetPlayerInvItemNum(index, n)).Type = ITEM_TYPE_CURRENCY Then
    Call SetPlayerInvItemValue(index, n, GetPlayerInvItemValue(index, n) + MapItem(mapNum, i).Value)
    Msg = MapItem(mapNum, i).Value & " " & Trim$(Item(GetPlayerInvItemNum(index, n)).Name)
Else
    Call SetPlayerInvItemValue(index, n, 0)
    Msg = Trim$(Item(GetPlayerInvItemNum(index, n)).Name)
End If

```
…with this:
```
If Item(GetPlayerInvItemNum(Index, n)).Type = ITEM_TYPE_CURRENCY Then
    Call SetPlayerInvItemValue(Index, n, GetPlayerInvItemValue(Index, n) + MapItem(mapNum, i).Value)
    Msg = MapItem(mapNum, i).Value & " " & Trim$(Item(GetPlayerInvItemNum(Index, n)).Name)
End If
If Item(GetPlayerInvItemNum(Index, n)).Type <> ITEM_TYPE_CURRENCY Then
    If GetPlayerInvItemValue(Index, n) + MapItem(mapNum, i).Value <= Item(GetPlayerInvItemNum(Index, n)).StackLimit Then
        Call SetPlayerInvItemValue(Index, n, GetPlayerInvItemValue(Index, n) + MapItem(mapNum, i).Value)
        Msg = MapItem(mapNum, i).Value & " " & Trim$(Item(GetPlayerInvItemNum(Index, n)).Name)
    Else
        If GetPlayerInvItemValue(Index, n) + MapItem(mapNum, i).Value > Item(GetPlayerInvItemNum(Index, n)).StackLimit Then
            MapItem(mapNum, i).Value = MapItem(mapNum, i).Value - (Item(GetPlayerInvItemNum(Index, n)).StackLimit - GetPlayerInvItemValue(Index, n))
            Call SetPlayerInvItemValue(Index, n, GetPlayerInvItemValue(Index, n) + (Item(GetPlayerInvItemNum(Index, n)).StackLimit - GetPlayerInvItemValue(Index, n)))
            Call SendInventoryUpdate(Index, n)
            GoTo FindAnotherPlayerMapGetItemSlot
        End If
    End If
End If

```
**Server - modPlayer - Sub TakeBankItem**

Replace this…
```
    invSlot = FindOpenInvSlot(index, GetPlayerBankItemNum(index, BankSlot))

    If invSlot > 0 Then
        If Item(GetPlayerBankItemNum(index, BankSlot)).Type = ITEM_TYPE_CURRENCY Then
            Call GiveInvItem(index, GetPlayerBankItemNum(index, BankSlot), amount)
            Call SetPlayerBankItemValue(index, BankSlot, GetPlayerBankItemValue(index, BankSlot) - amount)
            If GetPlayerBankItemValue(index, BankSlot) <= 0 Then
                Call SetPlayerBankItemNum(index, BankSlot, 0)
                Call SetPlayerBankItemValue(index, BankSlot, 0)
            End If
        Else
            If GetPlayerBankItemValue(index, BankSlot) > 1 Then
                Call GiveInvItem(index, GetPlayerBankItemNum(index, BankSlot), 0)
                Call SetPlayerBankItemValue(index, BankSlot, GetPlayerBankItemValue(index, BankSlot) - 1)
            Else
                Call GiveInvItem(index, GetPlayerBankItemNum(index, BankSlot), 0)
                Call SetPlayerBankItemNum(index, BankSlot, 0)
                Call SetPlayerBankItemValue(index, BankSlot, 0)
            End If
        End If
    End If

```
…with this:
```
FindAnotherTakeBankItemSlot:
    invSlot = FindOpenInvSlot(Index, GetPlayerBankItemNum(Index, BankSlot))

    If invSlot > 0 Then
        If Item(GetPlayerBankItemNum(Index, BankSlot)).Type = ITEM_TYPE_CURRENCY Then
            Call GiveInvItem(Index, GetPlayerBankItemNum(Index, BankSlot), amount)
            Call SetPlayerBankItemValue(Index, BankSlot, GetPlayerBankItemValue(Index, BankSlot) - amount)
            If GetPlayerBankItemValue(Index, BankSlot) <= 0 Then
                Call SetPlayerBankItemNum(Index, BankSlot, 0)
                Call SetPlayerBankItemValue(Index, BankSlot, 0)
            End If
        Else
            If Item(GetPlayerBankItemNum(Index, BankSlot)).Type <> ITEM_TYPE_CURRENCY Then
                If GetPlayerInvItemValue(Index, invSlot) >= 1 Then
                    If amount + GetPlayerInvItemValue(Index, invSlot) <= Item(GetPlayerInvItemNum(Index, invSlot)).StackLimit Then
                        Call GiveInvItem(Index, GetPlayerBankItemNum(Index, BankSlot), amount)
                        Call SetPlayerBankItemValue(Index, BankSlot, GetPlayerBankItemValue(Index, BankSlot) - amount)
                            If GetPlayerBankItemValue(Index, BankSlot) <= 0 Then
                                Call SetPlayerBankItemNum(Index, BankSlot, 0)
                                Call SetPlayerBankItemValue(Index, BankSlot, 0)
                            End If
                    Else
                        If amount + GetPlayerInvItemValue(Index, invSlot) > Item(GetPlayerInvItemNum(Index, invSlot)).StackLimit Then
                            amount = amount - (Item(GetPlayerInvItemNum(Index, invSlot)).StackLimit - GetPlayerInvItemValue(Index, invSlot))
                            Call GiveInvItem(Index, GetPlayerBankItemNum(Index, BankSlot), Item(GetPlayerBankItemNum(Index, BankSlot)).StackLimit - GetPlayerInvItemValue(Index, invSlot))
                            Call SetPlayerBankItemValue(Index, BankSlot, amount)
                            GoTo FindAnotherTakeBankItemSlot
                        End If
                    End If
                Else
                    If GetPlayerInvItemValue(Index, invSlot) = 0 Then
                        If amount <= Item(GetPlayerBankItemNum(Index, BankSlot)).StackLimit Then
                            Call GiveInvItem(Index, GetPlayerBankItemNum(Index, BankSlot), amount)
                            Call SetPlayerBankItemValue(Index, BankSlot, GetPlayerBankItemValue(Index, BankSlot) - amount)
                                If GetPlayerBankItemValue(Index, BankSlot) <= 0 Then
                                    Call SetPlayerBankItemNum(Index, BankSlot, 0)
                                    Call SetPlayerBankItemValue(Index, BankSlot, 0)
                                End If
                        Else
                            If amount > Item(GetPlayerBankItemNum(Index, BankSlot)).StackLimit Then
                                Call GiveInvItem(Index, GetPlayerBankItemNum(Index, BankSlot), Item(GetPlayerBankItemNum(Index, BankSlot)).StackLimit)
                                Call SetPlayerBankItemValue(Index, BankSlot, GetPlayerBankItemValue(Index, BankSlot) - Item(GetPlayerBankItemNum(Index, BankSlot)).StackLimit)
                                amount = amount - Item(GetPlayerBankItemNum(Index, BankSlot)).StackLimit
                                GoTo FindAnotherTakeBankItemSlot
                            End If
                        End If
                    End If
                End If
            End If
        End If
    End If

```
**Server - modPlayer - Function TakeInvItem**

Replace entire function with:
```
Function TakeInvItem(ByVal Index As Long, ByVal invSlot As Long, ByVal ItemVal As Long) As Boolean
    Dim i As Long
    Dim n As Long

    TakeInvItem = False

    If invSlot < 0 Or invSlot > MAX_INV Then
        Exit Function
    End If

    If ItemVal < 0 Or ItemVal > GetPlayerInvItemValue(Index, invSlot) Then
        Exit Function
    End If

        ' Check to see if the player has the item
        If invSlot > 0 Then
            If ItemVal >= GetPlayerInvItemValue(Index, invSlot) Then
                TakeInvItem = True
            Else
                Call SetPlayerInvItemValue(Index, invSlot, GetPlayerInvItemValue(Index, invSlot) - ItemVal)
                Call SendInventoryUpdate(Index, invSlot)
            End If
            If TakeInvItem Then
                Call SetPlayerInvItemNum(Index, invSlot, 0)
                Call SetPlayerInvItemValue(Index, invSlot, 0)
                ' Send the inventory update
                Call SendInventoryUpdate(Index, invSlot)
                Exit Function
            End If
        End If
End Function

```
**Server - modPlayer - TakeInvSlot**

Replace this…
```
If Item(itemnum).Type = ITEM_TYPE_CURRENCY Then

    ' Is what we are trying to take away more then what they have?  If so just set it to zero
    If ItemVal >= GetPlayerInvItemValue(index, invSlot) Then
        TakeInvSlot = True
    Else
        Call SetPlayerInvItemValue(index, invSlot, GetPlayerInvItemValue(index, invSlot) - ItemVal)
    End If
Else
    TakeInvSlot = True
End If

```
…with this:
```
If ItemVal >= GetPlayerInvItemValue(Index, invSlot) Then
    TakeInvSlot = True
Else
    Call SetPlayerInvItemValue(Index, invSlot, GetPlayerInvItemValue(Index, invSlot) - ItemVal)
End If

```
**Server - modPlayer - Public Sub UseItem**

Replace this…
```
Call TakeInvItem(index, Player(index).Inv(invNum).Num, 0)

```
…with this:
```
Call TakeInvItem(Index, invNum, 1)

```
For each case of equipment type (Armor, Weapon, Helmet, Shield)

Replace this…
```
TakeInvItem Index, ItemNum, 0

If tempItem > 0 Then
    GiveInvItem Index, tempItem, 0 ' give back the stored item
    tempItem = 0
End If

```
…with this:
```
TakeInvItem Index, invNum, 1

If tempItem > 0 Then
    GiveInvItem Index, tempItem, 1 ' give back the stored item
    tempItem = 0
End If

```
**Server - modServerTCP - Sub SendTradeUpdate**

Replace this…
```
If Item(TempPlayer(index).TradeOffer(i).Num).Type = ITEM_TYPE_CURRENCY Then
    totalWorth = totalWorth + (Item(GetPlayerInvItemNum(index, TempPlayer(index).TradeOffer(i).Num)).price * TempPlayer(index).TradeOffer(i).Value)
Else
    totalWorth = totalWorth + Item(GetPlayerInvItemNum(index, TempPlayer(index).TradeOffer(i).Num)).price
End If

```
…with this:
```
totalWorth = totalWorth + (Item(GetPlayerInvItemNum(Index, TempPlayer(Index).TradeOffer(i).Num)).price * TempPlayer(Index).TradeOffer(i).Value)

```
**Server - modTypes - Private Type ItemRec**

Below this…
```
instaCast As Byte

```
…add this:
```
StackLimit As Long

```
Link to comment
Share on other sites

@Justn: no not as it is right now because I was stupid making this.  I was so focused on trying to figure it out that I failed to do it with multiple item types.  I believe it's just going to take an edit of the Find Next Inventory sections.

@Ryoku: you may be right; I'm no expert in vb, I'm just starting out learning.  It **is** more than just stackable items however, it has a limit.  So you can't treat items just like currency…which would take a lot less code.  This has to be able to handle an item stack of say 5 and you have 3 in your inventory and a player trade gives you 7 more for example.
Link to comment
Share on other sites

You might want to include a buglist in your first post.. That way people don't spend 20 minutes coding all of this in simply to have to revert to a backup because of the bugs.. I look forward to seeing this completed. Consumables should always stack, imo.
Link to comment
Share on other sites

**updated original post**
Server - modGameLogic - Sub PlayerUnequipItem
find:
```
GiveInvItem Index, GetPlayerEquipment(Index, EqSlot), 0

```
replace that 0 with a 1

Server - modPlayer - Function FindOpenBankSlot

replace this
```
If GetPlayerBankItemValue(Index, i) > 0 Then

```
with
```
If GetPlayerBankItemValue(Index, i) > 0 and GetPlayerBankItemNum(Index, i) = ItemNum Then

```
do the same thing (essentially) to FindOpenInvSlot

Server - modPlayer - Sub UseItem

under each case of equipment type (armor, weapon, helmet, shield) there are two lines where you need to replace a 0 with a 1…they are:

```
TakeInvItem Index, ItemNum, 0

```and
```
GiveInvItem Index, tempItem, 0 ' give back the stored item

```
Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...
  • 2 months later...
I have a problem with the drop items
if there is only one item i can drop it but then i cant drop another.
and if i get 1 item to inventory, in inventory appears full of this items

how can i do that "how many do you want to drop" is non visible when item value is 1 ?

problem with drop items and full inventory is only when stack limit is 0
Link to comment
Share on other sites

I don't think so also this seems like a ton of code for this :/ if people don't get mad I would like to rip a similar system from that stolen mirage creations code not sure who's feature it is though but it has this system and its bug free and less code
Link to comment
Share on other sites

  • 8 months later...
I tested this out and the method he uses here is pretty much exactly the way in-which I would of gone about adding this kind of functionality. Although I have yet to thoroughly test it through it seems to do the job. Anyone off put with changing this amount of code in their project shouldn't probably be doing it in the first place.
Link to comment
Share on other sites

Honestly, there isn't that much code there. The page is simply taken up by what he's telling you to replace. Half the code he's replacing has more lines of code than what it's being replaced with.

Sicarii, It could definitely be done better than that. Part of your learning process should include revising this to be more efficient. Even though it works, make it work better.

Also, declare a variable to hold the values for

* GetPlayerBankItemNum(Index, BankSlot)
* GetPlayerInvItemValue(Index, i)
* And anything similar.

You use them so damn much. You'd be surprised how much shorter your code would be without so many unnecessary retrievals like that..

Look at it this way, your friend is a pothead. You're telling him his name over and over again and he simply doesn't remember.

Take a sticky note with his name on it and attach it to his forehead. Now anytime he needs it, it's right there. No need for you to keep telling him.

Granted, I don't always do things the most efficient way possible when I'm working on my own projects, and that's okay, but when it comes to something you're presenting to someone else, you need to strive to make it the best you can. Always. I have faith in you. ![;)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/wink.png)

You did a very good job for a novice. With some more practice and experience, you'll be working with the big boys in no time.
Link to comment
Share on other sites

  • 1 month later...
yes, i wholeheartedly agree it could be done better…back then I was working with limited resources (my only inet connection was a cellphone) and then life happened and wound up in jail for a while and then life happened some more, etc...just recently thought about eclipse. Think this is the first time logging in for quite a while...might dabble a bit again
Link to comment
Share on other sites

> yes, i wholeheartedly agree it could be done better…back then I was working with limited resources (my only inet connection was a cellphone) and then life happened and wound up in jail for a while and then life happened some more, etc...just recently thought about eclipse. Think this is the first time logging in for quite a while...might dabble a bit again

My curiosity got the best of me. Could you tell why you were put in jail?
Link to comment
Share on other sites

  • 1 month later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...