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

[EO + 3.0] [Updated 1.1] Shop improvements - multiple item cost value


zerohero
 Share

Recommended Posts

Heya guys,

I just got Eclipse last night and noticed that the shop system lacks the ability to trade items for a number of items, instead its always a straight swap just with a varying amount. I've never coded visual basic before so please go easy on me but I intend to implement this system into a crafting system, where a number of items can be used or 'combined' to create a single item.

If you follow this tutorial what you should have by the end of it is a trading system that allows of the use of multiple items as currency for an object -

>! ![](http://i1012.photobucket.com/albums/af244/zeroohero/tutorial-pic-in-action.png)

Here is an example of it in action!

>! ![](http://i1012.photobucket.com/albums/af244/zeroohero/tutorial-pic-can-buy.png)

Lets begin!

**Server modifications -**

**Find -**

```
Private Type TradeItemRec
```
**Add**

```
CostValue1 As Long
CostValue2 As Long
CostValue3 As Long
CostValue4 As Long

CostItem1 As Long
CostItem2 As Long
CostItem3 As Long
CostItem4 As Long
```
**Add** in **ModPlayer**, anywhere should be fine

```
Function HasItemamount(ByVal index As Long, ByVal itemnum As Long) As Long
    Dim i As Long

    ' Check for subscript out of range
    If IsPlaying(index) = False Or itemnum <= 0 Or itemnum > MAX_ITEMS Then
        Exit Function
    End If

    For i = 1 To MAX_INV

        If GetPlayerInvItemNum(index, i) = itemnum Then
            If Item(itemnum).Type = ITEM_TYPE_CURRENCY Then
                HasItemamount = GetPlayerInvItemValue(index, i)
            Else
                HasItemamount = HasItemamount + 1
            End If

        End If

    Next

End Function
```
Bellow this function add

```
Sub HandleTakeItem(ByVal index As Long, ByVal itemname As Long, ByVal Amount As Long)
Dim i As Long
    If Item(itemname).Type = ITEM_TYPE_CURRENCY Then
            TakeInvItem index, itemname, Amount
            Else
                For i = 1 To Amount
                  TakeInvItem index, itemname, 1
              Next
      End If
End Sub
```

**Find**

```
Sub HandleBuyItem(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
```
**In the function bellow**

```
Dim itemamount As Long
```
**Add**

```
Dim itemamount1 As Long
Dim itemamount2 As Long
Dim itemamount3 As Long
Dim itemamount4 As Long
```
**Find**

```
' check has the cost item
itemamount = HasItem(index, .costitem)
```

**Replace with**

```
' check has the cost item
        itemamount = HasItemamount(index, .CostItem)
        itemamount1 = HasItemamount(index, .CostItem1)
        itemamount2 = HasItemamount(index, .CostItem2)
        itemamount3 = HasItemamount(index, .CostItem3)
        itemamount4 = HasItemamount(index, .CostItem4)

```
**Find**

```
' check has the cost item
        If itemamount = 0 Or itemamount < .costvalue Then
            PlayerMsg index, "You do not have enough to buy this item.", BrightRed
            ResetShopAction index
            Exit Sub
        End If
```

**Replace with**

```
    If .CostValue1 = 0 Then
            If itemamount = 0 Or itemamount < .CostValue Then
                PlayerMsg index, "You do not have enough to buy this item.", BrightRed
                ResetShopAction index
                Exit Sub
            End If
        Else
        If .CostValue2 = 0 Then
            If itemamount = 0 Or itemamount < .CostValue Or itemamount1 = 0 Or itemamount1 < .CostValue1 Then
                PlayerMsg index, "You do not have enough to buy this item.", BrightRed
                ResetShopAction index
                Exit Sub
            End If
        Else
        If .CostValue3 = 0 Then
            If itemamount = 0 Or itemamount < .CostValue Or itemamount1 = 0 Or itemamount1 < .CostValue1 Or itemamount2 = 0 Or itemamount2 < .CostValue2 Then
                PlayerMsg index, "You do not have enough to buy this item.", BrightRed
                ResetShopAction index
                Exit Sub
            End If
        Else
        If .CostValue4 = 0 Then
            If itemamount = 0 Or itemamount < .CostValue Or itemamount1 = 0 Or itemamount1 < .CostValue1 Or itemamount2 = 0 Or itemamount2 < .CostValue2 Or itemamount3 = 0 Or itemamount3 < .CostValue3 Then
                PlayerMsg index, "You do not have enough to buy this item.", BrightRed
                ResetShopAction index
                Exit Sub
            End If
        Else
            If itemamount = 0 Or itemamount < .CostValue Or itemamount1 = 0 Or itemamount1 < .CostValue1 Or itemamount2 = 0 Or itemamount2 < .CostValue2 Or itemamount3 = 0 Or itemamount3 < .CostValue3 Or itemamount4 = 0 Or itemamount4 < .CostValue4 Then
                PlayerMsg index, "You do not have enough to buy this item.", BrightRed
                ResetShopAction index
                Exit Sub
                End If
                End If
            End If
        End If
    End If

```

**Find**

```
it's fine, let's go ahead
        TakeInvItem index, .costitem, .costvalue
    End With
```

**Replace with**

```
              If .CostValue1 = 0 Then
        HandleTakeItem index, .CostItem, .CostValue
        ElseIf .CostValue2 = 0 Then
        HandleTakeItem index, .CostItem, .CostValue
        HandleTakeItem index, .CostItem1, .CostValue1
        ElseIf .CostValue3 = 0 Then
        HandleTakeItem index, .CostItem, .CostValue
        HandleTakeItem index, .CostItem1, .CostValue1
        HandleTakeItem index, .CostItem2, .CostValue2
        ElseIf .CostValue4 = 0 Then
        HandleTakeItem index, .CostItem, .CostValue
        HandleTakeItem index, .CostItem1, .CostValue1
        HandleTakeItem index, .CostItem2, .CostValue2
        HandleTakeItem index, .CostItem3, .CostValue3
        ElseIf .CostValue4 <> 0 Then
        HandleTakeItem index, .CostItem, .CostValue
        HandleTakeItem index, .CostItem1, .CostValue1
        HandleTakeItem index, .CostItem2, .CostValue2
        HandleTakeItem index, .CostItem3, .CostValue3
        HandleTakeItem index, .CostItem4, .CostValue4
        End If

```

**Thats it for the server!**

**Now for the client -**

**Find**

```
Private Type TradeItemRec
```
**Replace entire function with**

```
Private Type TradeItemRec
    Item As Long
    ItemValue As Long
    CostItem As Long
    CostItem1 As Long
    CostItem2 As Long
    CostItem3 As Long
    CostItem4 As Long

    CostValue As Long
    CostValue1 As Long
    CostValue2 As Long
    CostValue3 As Long
    CostValue4 As Long
End Type
```

**Find**

```
Private Sub cmdUpdate_Click()
```

**Replace the ENTIRE function with**
```

Private Sub cmdUpdate_Click()
Dim Index As Long
Dim tmpPos As Long
Dim i As Long

    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    tmpPos = lstTradeItem.ListIndex
    Index = lstTradeItem.ListIndex + 1
    If Index = 0 Then Exit Sub
    With Shop(EditorIndex).TradeItem(Index)
        .Item = cmbItem.ListIndex
        .ItemValue = Val(txtItemValue.text)

        .CostItem = cmbCostItem(0).ListIndex
        .CostItem1 = cmbCostItem(1).ListIndex
        .CostItem2 = cmbCostItem(2).ListIndex
        .CostItem3 = cmbCostItem(3).ListIndex
        .CostItem4 = cmbCostItem(4).ListIndex

        .CostValue = Val(txtCostValue(0).text)
        .CostValue1 = Val(txtCostValue(1).text)
        .CostValue2 = Val(txtCostValue(2).text)
        .CostValue3 = Val(txtCostValue(3).text)
        .CostValue4 = Val(txtCostValue(4).text)

    End With
    UpdateShopTrade tmpPos

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "cmdUpdate_Click", "frmEditor_Shop", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub
```

**Find**

```
With Shop(EditorIndex).TradeItem(Index)
        .Item = 0
        .ItemValue = 0
        .CostItem = 0
        .CostValue = 0
    End With
```

**Replace with**
```
With Shop(EditorIndex).TradeItem(Index)
        .Item = 0
        .ItemValue = 0
        .CostItem = 0
        .CostValue = 0
        .CostItem1 = 0
        .CostItem2 = 0
        .CostItem3 = 0
        .CostItem4 = 0
        .CostValue1 = 0
        .CostValue2 = 0
        .CostValue3 = 0
        .CostValue4 = 0
    End With
```

**Find**

```
Public Sub ShopEditorInit()
```

**Replace the ENTIRE function with**

```
Public Sub ShopEditorInit()
Dim i As Long
Dim x As Long

    ' If debug mode, handle error then exit out
    ' My edit
    If Options.Debug = 1 Then On Error GoTo errorhandler

    If frmEditor_Shop.Visible = False Then Exit Sub
    EditorIndex = frmEditor_Shop.lstIndex.ListIndex + 1

    frmEditor_Shop.txtName.text = Trim$(Shop(EditorIndex).Name)
    If Shop(EditorIndex).BuyRate > 0 Then
        frmEditor_Shop.scrlBuy.Value = Shop(EditorIndex).BuyRate
    Else
        frmEditor_Shop.scrlBuy.Value = 100
    End If

    frmEditor_Shop.cmbItem.Clear
    frmEditor_Shop.cmbItem.AddItem "None"

    For x = 0 To 4
    frmEditor_Shop.cmbCostItem(x).Clear
    frmEditor_Shop.cmbCostItem(x).AddItem "None"
    frmEditor_Shop.txtCostValue(x).text = "0"
    Next

    x = 0

    For i = 1 To MAX_ITEMS
        frmEditor_Shop.cmbItem.AddItem i & ": " & Trim$(Item(i).Name)
        For x = 0 To 4
        frmEditor_Shop.cmbCostItem(x).AddItem i & ": " & Trim$(Item(i).Name)
        Next
    Next

    frmEditor_Shop.cmbItem.ListIndex = 0

    For x = 0 To 4
    frmEditor_Shop.cmbCostItem(x).ListIndex = 0
    Next

    UpdateShopTrade

    Shop_Changed(EditorIndex) = True

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "ShopEditorInit", "modGameEditors", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub
```

**Replace ENTIRE Function**

```
Public Sub UpdateShopTrade(Optional ByVal tmpPos As Long = 0)
```

**With**

```
Public Sub UpdateShopTrade(Optional ByVal tmpPos As Long = 0)
Dim i As Long

    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    frmEditor_Shop.lstTradeItem.Clear

    For i = 1 To MAX_TRADES
        With Shop(EditorIndex).TradeItem(i)
            ' if none, show as none
            If .Item = 0 And .CostItem = 0 Then
            frmEditor_Shop.lstTradeItem.AddItem "Empty Trade Slot"
            Else
            If .CostValue1 = 0 Then
            frmEditor_Shop.lstTradeItem.AddItem i & ": " & .ItemValue & "x " & Trim$(Item(.Item).Name) & " for " & .CostValue & "x " & Trim$(Item(.CostItem).Name)
            ElseIf .CostValue2 = 0 Then
            frmEditor_Shop.lstTradeItem.AddItem i & ": " & .ItemValue & "x " & Trim$(Item(.Item).Name) & " for " & .CostValue & "x  " & Trim$(Item(.CostItem).Name) & " " & .CostValue1 & "x " & Trim$(Item(.CostItem1).Name)
            ElseIf .CostValue3 = 0 Then
            frmEditor_Shop.lstTradeItem.AddItem i & ": " & .ItemValue & "x " & Trim$(Item(.Item).Name) & " for " & .CostValue & "x  " & Trim$(Item(.CostItem).Name) & " " & .CostValue1 & "x " & Trim$(Item(.CostItem1).Name) & " " & .CostValue2 & "x " & Trim$(Item(.CostItem2).Name)
            ElseIf .CostValue4 = 0 Then
            frmEditor_Shop.lstTradeItem.AddItem i & ": " & .ItemValue & "x " & Trim$(Item(.Item).Name) & " for " & .CostValue & "x  " & Trim$(Item(.CostItem).Name) & " " & .CostValue1 & "x " & Trim$(Item(.CostItem1).Name) & " " & .CostValue2 & "x " & Trim$(Item(.CostItem2).Name) & " " & .CostValue3 & "x " & Trim$(Item(.CostItem3).Name)
            Else
            frmEditor_Shop.lstTradeItem.AddItem i & ": " & .ItemValue & "x " & Trim$(Item(.Item).Name) & " for " & .CostValue & "x  " & Trim$(Item(.CostItem).Name) & " " & .CostValue1 & "x " & Trim$(Item(.CostItem1).Name) & " " & .CostValue2 & "x " & Trim$(Item(.CostItem2).Name) & " " & .CostValue3 & "x " & Trim$(Item(.CostItem3).Name) & " " & .CostValue4 & "x " & Trim$(Item(.CostItem4).Name)
            End If
            End If
        End With
    Next

    frmEditor_Shop.lstTradeItem.ListIndex = tmpPos

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

```

**Replace Entire function**

```
Private Sub picShopItems_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)

```
**with**

```
Private Sub picShopItems_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim shopItem As Long

    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    shopItem = IsShopItem(x, y)

    If shopItem > 0 Then
        Select Case ShopAction
            Case 0 ' no action, give cost
                With Shop(InShop).TradeItem(shopItem)

                    If .CostValue1 = 0 Then
                    AddText "You can buy this item for " & .CostValue & " " & Trim$(Item(.CostItem).Name) & ".", White
                    ElseIf .CostValue2 = 0 Then
                    AddText "You can buy this item for " & .CostValue & " " & Trim$(Item(.CostItem).Name) & "  +  " & .CostValue1 & " " & Trim$(Item(.CostItem1).Name) & ".", White
                    ElseIf .CostValue3 = 0 Then
                    AddText "You can buy this item for " & .CostValue & " " & Trim$(Item(.CostItem).Name) & "  +  " & .CostValue1 & " " & Trim$(Item(.CostItem1).Name) & "  +  " & .CostValue2 & " " & Trim$(Item(.CostItem2).Name) & ".", White
                    ElseIf .CostValue4 = 0 Then
                    AddText "You can buy this item for " & .CostValue & " " & Trim$(Item(.CostItem).Name) & "  +  " & .CostValue1 & " " & Trim$(Item(.CostItem1).Name) & "  +  " & .CostValue2 & " " & Trim$(Item(.CostItem2).Name) & "  +  " & .CostValue3 & " " & Trim$(Item(.CostItem3).Name) & ".", White
                    Else
                    AddText "You can buy this item for " & .CostValue & " " & Trim$(Item(.CostItem).Name) & "  +  " & .CostValue1 & " " & Trim$(Item(.CostItem1).Name) & "  +  " & .CostValue2 & " " & Trim$(Item(.CostItem2).Name) & "  +  " & .CostValue3 & " " & Trim$(Item(.CostItem3).Name) & "  +  " & .CostValue4 & " " & Trim$(Item(.CostItem4).Name) & ".", White
                    End If

                End With
            Case 1 ' buy item
                ' buy item code
                BuyItem shopItem
        End Select
    End If

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

```

And that's it for the code! Now all that is left is to modify the shop form. You can either download the one attached to the post or simple duplicate the elements shown in the image bellow and you are all set!

![](http://i1012.photobucket.com/albums/af244/zeroohero/tutorial-pic-design.png)

Hopefully at least some of you find it useful. I find visual basics standards to be quote strange to what I already know so please excuse and help me improve on what I have made. Thank-you
Link to comment
Share on other sites

  • Replies 50
  • Created
  • Last Reply

Top Posters In This Topic

Thanks for the kind words guys. If you find some time to test it please let me know if you any any errors or I missed something out. I'm working on implementing this with a crafting system, much like the shop system currently in place but with variables such as the type of item you wish to craft affects the layout of the crafting screen (Shop). Once I have it working if anyone is interested I can post that too.
Link to comment
Share on other sites

@Fernz:

> Sorry did I make some kind of mistake? I don't really use visual basic 6\. Did he only edit the forms or something?

Those who have basic knowledge of VB6 and EO would understand where all this should be placed. However, he still should put which module/sub is being modified/added to help guide those inexperienced with VB6\.
I suggest you get VB6 and learn. Its fun making additions on your own to your game, and you would learn something. :)
Link to comment
Share on other sites

good stuff.. ive been wanting to do this for awhile since seeing it in "endless online".. all of the good equipment in game are made by collecting several items from different parts of the world and trading them in.. its a nice addition to simple reward quests.
Link to comment
Share on other sites

```
If .CostValue1 = 0 Then
            If itemamount = 0 Or itemamount < .CostValue Then
                PlayerMsg index, "You do not have enough to buy this item.", BrightRed
                ResetShopAction index
                Exit Sub
            End If
        Else
        If .CostValue2 = 0 Then
            If itemamount = 0 Or itemamount < .CostValue Or itemamount1 = 0 Or itemamount1 < .CostValue1 Then
                PlayerMsg index, "You do not have enough to buy this item.", BrightRed
                ResetShopAction index
                Exit Sub
            End If
        Else
        If .CostValue3 = 0 Then
            If itemamount = 0 Or itemamount < .CostValue Or itemamount1 = 0 Or itemamount1 < .CostValue1 Or itemamount2 = 0 Or itemamount2 < .CostValue2 Then
                PlayerMsg index, "You do not have enough to buy this item.", BrightRed
                ResetShopAction index
                Exit Sub
            End If
        Else
        If .CostValue4 = 0 Then
            If itemamount = 0 Or itemamount < .CostValue Or itemamount1 = 0 Or itemamount1 < .CostValue1 Or itemamount2 = 0 Or itemamount2 < .CostValue2 Or itemamount3 = 0 Or itemamount3 < .CostValue3 Then
                PlayerMsg index, "You do not have enough to buy this item.", BrightRed
                ResetShopAction index
                Exit Sub
            End If
        Else
            If itemamount = 0 Or itemamount < .CostValue Or itemamount1 = 0 Or itemamount1 < .CostValue1 Or itemamount2 = 0 Or itemamount2 < .CostValue2 Or itemamount3 = 0 Or itemamount3 < .CostValue3 Or itemamount4 = 0 Or itemamount4 < .CostValue4 Then
                PlayerMsg index, "You do not have enough to buy this item.", BrightRed
                ResetShopAction index
                Exit Sub
                End If
                End If
            End If
        End If
    End If

```You can change to this.
```
        If .CostValue1 = 0 Then
            If itemamount = 0 Or itemamount < .costvalue Then
                PlayerMsg Index, "You do not have enough to buy this item.", BrightRed
                ResetShopAction Index
                Exit Sub
            End If
        ElseIf .CostValue2 = 0 Then
            If itemamount = 0 Or itemamount < .costvalue Or itemamount1 = 0 Or itemamount1 < .CostValue1 Then
                PlayerMsg Index, "You do not have enough to buy this item.", BrightRed
                ResetShopAction Index
                Exit Sub
            End If
        ElseIf .CostValue3 = 0 Then
            If itemamount = 0 Or itemamount < .costvalue Or itemamount1 = 0 Or itemamount1 < .CostValue1 Or itemamount2 = 0 Or itemamount2 < .CostValue2 Then
                PlayerMsg Index, "You do not have enough to buy this item.", BrightRed
                ResetShopAction Index
                Exit Sub
            End If
        ElseIf .CostValue4 = 0 Then
            If itemamount = 0 Or itemamount < .costvalue Or itemamount1 = 0 Or itemamount1 < .CostValue1 Or itemamount2 = 0 Or itemamount2 < .CostValue2 Or itemamount3 = 0 Or itemamount3 < .CostValue3 Then
                PlayerMsg Index, "You do not have enough to buy this item.", BrightRed
                ResetShopAction Index
                Exit Sub
            End If
        ElseIf itemamount = 0 Or itemamount < .costvalue Or itemamount1 = 0 Or itemamount1 < .CostValue1 Or itemamount2 = 0 Or itemamount2 < .CostValue2 Or itemamount3 = 0 Or itemamount3 < .CostValue3 Or itemamount4 = 0 Or itemamount4 < .CostValue4 Then
                PlayerMsg Index, "You do not have enough to buy this item.", BrightRed
                ResetShopAction Index
                Exit Sub
                End If
```
Link to comment
Share on other sites

Thanks to sotvotkong fixed an issue where it would not take items correctly. Issue was that I accidently was checking the item number instead of the item amount, so item 0 whenever present would allow anything to be bought for a single price.

Original post has been updated with the fix.

Changed

```
' it's fine, let's go ahead and steal all your stuff
        If .CostItem1 = 0 Then
        TakeInvItem index, .CostItem, .CostValue
        ElseIf .CostItem2 = 0 Then
        TakeInvItem index, .CostItem, .CostValue
        TakeInvItem index, .CostItem1, .CostValue1
        ElseIf .CostItem3 = 0 Then
        TakeInvItem index, .CostItem, .CostValue
        TakeInvItem index, .CostItem1, .CostValue1
        TakeInvItem index, .CostItem2, .CostValue2
        ElseIf .CostItem4 = 0 Then
        TakeInvItem index, .CostItem, .CostValue
        TakeInvItem index, .CostItem1, .CostValue1
        TakeInvItem index, .CostItem2, .CostValue2
        TakeInvItem index, .CostItem3, .CostValue3
        ElseIf .CostItem4 = 1 Then
        TakeInvItem index, .CostItem, .CostValue
        TakeInvItem index, .CostItem1, .CostValue1
        TakeInvItem index, .CostItem2, .CostValue2
        TakeInvItem index, .CostItem3, .CostValue3
        TakeInvItem index, .CostItem4, .CostValue4
        End If

        GiveInvItem index, .Item, .ItemValue
    End With
```
**to**

```
' it's fine, let's go ahead and steal all your stuff
        If .CostValue1 = 0 Then
        TakeInvItem index, .CostItem, .CostValue
        ElseIf .CostValue2 = 0 Then
        TakeInvItem index, .CostItem, .CostValue
        TakeInvItem index, .CostItem1, .CostValue1
        ElseIf .CostValue3 = 0 Then
        TakeInvItem index, .CostItem, .CostValue
        TakeInvItem index, .CostItem1, .CostValue1
        TakeInvItem index, .CostItem2, .CostValue2
        ElseIf .CostValue4 = 0 Then
        TakeInvItem index, .CostItem, .CostValue
        TakeInvItem index, .CostItem1, .CostValue1
        TakeInvItem index, .CostItem2, .CostValue2
        TakeInvItem index, .CostItem3, .CostValue3
        ElseIf .CostValue4 = 1 Then
        TakeInvItem index, .CostItem, .CostValue
        TakeInvItem index, .CostItem1, .CostValue1
        TakeInvItem index, .CostItem2, .CostValue2
        TakeInvItem index, .CostItem3, .CostValue3
        TakeInvItem index, .CostItem4, .CostValue4
        End If
```
Link to comment
Share on other sites

@Domino_:

> Hmm. did you tryed to sell something in shop? Because I get this "The shop doesn't want that item." but thats maybe a mistake that I have made. ill check.

I don't understand at the moment what governs what can be sold or not to a specific shop. I'm 99.9% sure that I didn't touch anything that would conflict with the selling of items though.
Link to comment
Share on other sites

  • 2 weeks later...
If i set the price of the item in the shop. ex : 1x Stone For 100 Gold ( Gold Type Set to Currency )
When i buy, it doesn't reduce the amount of the Gold in my inventory also doesn't receive the Stone too, and the message says " Trade Success ".

But If I Set the Gold Type to none. It working fine.
Link to comment
Share on other sites

@Prince:

> If i set the price of the item in the shop. ex : 1x Stone For 100 Gold ( Gold Type Set to Currency )
> When i buy, it doesn't reduce the amount of the Gold in my inventory also doesn't receive the Stone too, and the message says " Trade Success ".
>
> But If I Set the Gold Type to none. It working fine.

Sorry I have now updated the tutorial, it should be fully functional. For those who has already implemented this system there is a quick guide of the things that need changing -

Add both these functions in **ModPlayer** (server side)

```
Function HasItemamount(ByVal index As Long, ByVal itemnum As Long) As Long
    Dim i As Long

    ' Check for subscript out of range
    If IsPlaying(index) = False Or itemnum <= 0 Or itemnum > MAX_ITEMS Then
        Exit Function
    End If

    For i = 1 To MAX_INV

        If GetPlayerInvItemNum(index, i) = itemnum Then
            If Item(itemnum).Type = ITEM_TYPE_CURRENCY Then
                HasItemamount = GetPlayerInvItemValue(index, i)
            Else
                HasItemamount = HasItemamount + 1
            End If

        End If

    Next

End Function
```
And

```
Sub HandleTakeItem(ByVal index As Long, ByVal itemname As Long, ByVal Amount As Long)
Dim i As Long
    If Item(itemname).Type = ITEM_TYPE_CURRENCY Then
            TakeInvItem index, itemname, Amount
            Else
                For i = 1 To Amount
                  TakeInvItem index, itemname, 1
              Next
      End If
End Sub
```
Find

```
' check has the cost item
        itemamount = HasItem(index, .CostItem)
        itemamount1 = HasItem(index, .CostItem1)
        itemamount2 = HasItem(index, .CostItem2)
        itemamount3 = HasItem(index, .CostItem3)
        itemamount4 = HasItem(index, .CostItem4)
```
Change this to -

```
' check has the cost item
        itemamount = HasItemamount(index, .CostItem)
        itemamount1 = HasItemamount(index, .CostItem1)
        itemamount2 = HasItemamount(index, .CostItem2)
        itemamount3 = HasItemamount(index, .CostItem3)
        itemamount4 = HasItemamount(index, .CostItem4)
```

Find

   ```
  ' it's fine, let's go ahead and steal all your stuff
        If .CostValue1 = 0 Then
        TakeInvItem index, .CostItem, .CostValue
        ElseIf .CostValue2 = 0 Then
        TakeInvItem index, .CostItem, .CostValue
        TakeInvItem index, .CostItem1, .CostValue1
        ElseIf .CostValue3 = 0 Then
        TakeInvItem index, .CostItem, .CostValue
        TakeInvItem index, .CostItem1, .CostValue1
        TakeInvItem index, .CostItem2, .CostValue2
        ElseIf .CostValue4 = 0 Then
        TakeInvItem index, .CostItem, .CostValue
        TakeInvItem index, .CostItem1, .CostValue1
        TakeInvItem index, .CostItem2, .CostValue2
        TakeInvItem index, .CostItem3, .CostValue3
        ElseIf .CostValue4 = 1 Then
        TakeInvItem index, .CostItem, .CostValue
        TakeInvItem index, .CostItem1, .CostValue1
        TakeInvItem index, .CostItem2, .CostValue2
        TakeInvItem index, .CostItem3, .CostValue3
        TakeInvItem index, .CostItem4, .CostValue4
        End If
```
Change this to

```

        If .CostValue1 = 0 Then
        HandleTakeItem index, .CostItem, .CostValue
        ElseIf .CostValue2 = 0 Then
        HandleTakeItem index, .CostItem, .CostValue
        HandleTakeItem index, .CostItem1, .CostValue1
        ElseIf .CostValue3 = 0 Then
        HandleTakeItem index, .CostItem, .CostValue
        HandleTakeItem index, .CostItem1, .CostValue1
        HandleTakeItem index, .CostItem2, .CostValue2
        ElseIf .CostValue4 = 0 Then
        HandleTakeItem index, .CostItem, .CostValue
        HandleTakeItem index, .CostItem1, .CostValue1
        HandleTakeItem index, .CostItem2, .CostValue2
        HandleTakeItem index, .CostItem3, .CostValue3
        ElseIf .CostValue4 <> 0 Then
        HandleTakeItem index, .CostItem, .CostValue
        HandleTakeItem index, .CostItem1, .CostValue1
        HandleTakeItem index, .CostItem2, .CostValue2
        HandleTakeItem index, .CostItem3, .CostValue3
        HandleTakeItem index, .CostItem4, .CostValue4
        End If
```
This should fix up any issues that where present, now I understand eclipse better I found a few logical errors in my code. Sorry for the inconvenience.
Link to comment
Share on other sites

Change
```
              If .CostValue1 = 0 Then
        HandleTakeItem index, .CostItem, .CostValue
        ElseIf .CostValue2 = 0 Then
        HandleTakeItem index, .CostItem, .CostValue
        HandleTakeItem index, .CostItem1, .CostValue1
        ElseIf .CostValue3 = 0 Then
        HandleTakeItem index, .CostItem, .CostValue
        HandleTakeItem index, .CostItem1, .CostValue1
        HandleTakeItem index, .CostItem2, .CostValue2
        ElseIf .CostValue4 = 0 Then
        HandleTakeItem index, .CostItem, .CostValue
        HandleTakeItem index, .CostItem1, .CostValue1
        HandleTakeItem index, .CostItem2, .CostValue2
        HandleTakeItem index, .CostItem3, .CostValue3
        ElseIf .CostValue4 <> 0 Then
        HandleTakeItem index, .CostItem, .CostValue
        HandleTakeItem index, .CostItem1, .CostValue1
        HandleTakeItem index, .CostItem2, .CostValue2
        HandleTakeItem index, .CostItem3, .CostValue3
        HandleTakeItem index, .CostItem4, .CostValue4
        End If
```
To

```
              If .CostValue1 = 0 Then
        HandleTakeItem index, .CostItem, .CostValue
        GiveInvItem index, .Item, .ItemValue
        ElseIf .CostValue2 = 0 Then
        HandleTakeItem index, .CostItem, .CostValue
        HandleTakeItem index, .CostItem1, .CostValue1
        GiveInvItem index, .Item, .ItemValue
        ElseIf .CostValue3 = 0 Then
        HandleTakeItem index, .CostItem, .CostValue
        HandleTakeItem index, .CostItem1, .CostValue1
        HandleTakeItem index, .CostItem2, .CostValue2
        GiveInvItem index, .Item, .ItemValue
        ElseIf .CostValue4 = 0 Then
        HandleTakeItem index, .CostItem, .CostValue
        HandleTakeItem index, .CostItem1, .CostValue1
        HandleTakeItem index, .CostItem2, .CostValue2
        HandleTakeItem index, .CostItem3, .CostValue3
        GiveInvItem index, .Item, .ItemValue
        ElseIf .CostValue4 <> 0 Then
        HandleTakeItem index, .CostItem, .CostValue
        HandleTakeItem index, .CostItem1, .CostValue1
        HandleTakeItem index, .CostItem2, .CostValue2
        HandleTakeItem index, .CostItem3, .CostValue3
        HandleTakeItem index, .CostItem4, .CostValue4
        GiveInvItem index, .Item, .ItemValue
        End If
```
It works for me.
Link to comment
Share on other sites

The GiveInvItem piece of code I intended to be untouched so it sat just under where you pasted the code that takes the required items.

I just installed this in a fresh copy of eclipse and it works perfectly so perhaps you have missed something out Prince, did you apply the updates correctly?
Link to comment
Share on other sites

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...