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

CS:DE Bank System


JohnPony
 Share

Recommended Posts

#Things that need to be added:
1\. Drag Bank Items To Different Slots.

~~*I added a few anti-leech pieces of code, this way you copy + paste kiddies may actually read the code! They aren't hard to find if you just search through the damn code.~~
I removed the anti leech until the end of the contest, as soon as the winners have been declared i will add it back in.

Ok, first we are going to head over to modDx8 and add this at the bottom:
```
Public Sub DrawBank()
Dim i As Long, x As Long, y As Long, Itemnum As Long, ItemPic As Long, left As Long, top As Long, amount As Long, colour As Long, width As Long
Dim height As Long

    width = 480
    height = 384

    RenderTexture Tex_GUI(41), GUIWindow(GUI_BANK).x, GUIWindow(GUI_BANK).y, 0, 0, width, height, width, height

    ' render the bank items' are you serous? that is it??? maybe... one sec :D :Polol
        For i = 1 To MAX_BANK
            Itemnum = GetBankItemNum(i)
            If Itemnum > 0 And Itemnum <= MAX_ITEMS Then
                ItemPic = Item(Itemnum).Pic
                    If ItemPic > 0 And ItemPic <= Count_Item Then

                    top = GUIWindow(GUI_BANK).y + BankTop + ((BankOffsetX + 32) * ((i - 1) \ BankColumns))
                    left = GUIWindow(GUI_BANK).x + BankLeft + ((BankOffsetY + 32) * (((i - 1) Mod BankColumns)))

                        RenderTexture Tex_Item(ItemPic), left, top, 0, 0, 32, 32, 32, 32

                        ' If the bank item is in a stack, draw the amount...
                        If GetBankItemValue(i) > 1 Then
                            y = top + 22
                            x = left - 4
                            amount = CStr(GetBankItemValue(i))

                            ' Draw the currency
                            If CLng(amount) < 1000000 Then
                        colour = White
                    ElseIf CLng(amount) > 1000000 And CLng(amount) < 10000000 Then
                        colour = Yellow
                    ElseIf CLng(amount) > 10000000 Then
                        colour = BrightGreen
                    End If

                    RenderText Font_Default, ConvertCurrency(amount), x, y, colour
                End If
            End If
        End If
    Next

            DrawBankItemDesc

End Sub
```
That just handles the bank interface being drawn, along with the items and there amounts

Next we are going to add:
```
Public Sub DrawBankItemDesc()
Dim bankNum As Long
    If Not GUIWindow(GUI_BANK).visible Then Exit Sub

        bankNum = IsBankItem(GlobalX, GlobalY)

    If bankNum > 0 Then
        If bankNum > 0 Then
            If GetBankItemNum(bankNum) > 0 Then
                DrawItemDesc GetBankItemNum(bankNum), GUIWindow(GUI_CHARACTER).x - GUIWindow(GUI_DESCRIPTION).width - 10, GUIWindow(GUI_CHARACTER).y
          End If
        End If
    End If

End Sub
```At the bottom of modDX8

Now in modInput lets add:
```
Public Sub Bank_DoubleClick()
Dim bankNum As Long
    bankNum = IsBankItem(GlobalX, GlobalY)

    If bankNum > 0 Then
        ' withdraw item
      Call WithdrawItem(bankNum, 0)
    End If
End Sub
```Below:```
Public Sub Shop_DoubleClick()
Dim shopSlot As Long

    shopSlot = IsShopItem(GlobalX, GlobalY)

    If shopSlot > 0 Then
        ' buy item code
        BuyItem shopSlot
    End If
End Sub
```
Now still in modInput find:```
Public Sub HandleDoubleClick()
```And in that sub find:```
Case GUI_SHOP
```And right below that case add:
```
  Case GUI_BANK
                            Bank_DoubleClick

```
Now back into modDX8, find```
Public Sub DrawGUI()
```And in that sub find:```
If GUIWindow(GUI_SHOP).visible Then DrawShop
```Below that add:```
If GUIWindow(GUI_BANK).visible Then DrawBank
```
Now in modGameLogic find:
```
Public Function IsBankItem(ByVal x As Single, ByVal y As Single, Optional ByVal emptySlot As Boolean = False) As Long
```Replace that whole sub with:
```
Public Function IsBankItem(ByVal x As Single, ByVal y As Single, Optional ByVal emptySlot As Boolean = False) As Long
Dim tempRec As RECT, skipThis As Boolean
Dim i As Long

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

    IsBankItem = 0

    For i = 1 To MAX_BANK
        If Not emptySlot Then
            If GetBankItemNum(i) <= 0 And GetBankItemNum(i) > MAX_ITEMS Then skipThis = True
        End If

        If Not skipThis Then
            With tempRec
                .top = GUIWindow(GUI_BANK).x + BankTop + ((BankOffsetY + 32) * ((i - 1) \ BankColumns))
                .bottom = .top + PIC_Y
                .left = GUIWindow(GUI_BANK).y + BankLeft + ((BankOffsetX + 32) * (((i - 1) Mod BankColumns)))
                .Right = .left + PIC_X
            End With

            If x >= tempRec.left And x <= tempRec.Right Then
                If y >= tempRec.top And y <= tempRec.bottom Then

                    IsBankItem = i
                    Exit Function
                End If
            End If
        End If
        skipThis = False
    Next

    ' Error handler
    Exit Function
errorhandler:
    HandleError "IsBankItem", "frmGameLogic", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Function
End Function
```
Now in modClientTcp find:```
Public Sub CloseBank()
```And below:```
Set Buffer = Nothing
```Add:
```
  InBank = False
    GUIWindow(GUI_BANK).visible = False
```
In modConstants find:```
Public Const GUI_SHOP As Byte = 12
```Below it add:```
Public Const GUI_BANK As Byte = 13
```
In modGeneral find:```
' 12 - Shop
    With GUIWindow(GUI_SHOP)
        .x = 118
        .y = 110
        .width = 252
        .height = 317
        .visible = False
    End With
```Below that add:

 ```
  ' 13 - Bank
    With GUIWindow(GUI_BANK)
        .x = 118
        .y = 110
        .width = 480
        .height = 384
        .visible = False

    End With
```

Next in modHandleData find:```
Private Sub HandleBank(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
```In that sub below```
Next
```Add:
```
InBank = True
    GUIWindow(GUI_BANK).visible = True
```
Finally download the attachment below, now depending on your client's gui graphics you may need to rename it to the next number such as 39 or 40\. And if you have to do that, simple change```
    RenderTexture Tex_GUI(Your Bank Gui Number), GUIWindow(GUI_BANK).x, GUIWindow(GUI_BANK).y, 0, 0, width, height, width, height
```to your gui bank number.

Edit:
Forgot, in modDX8 find:```
DrawPlayerSpellDesc
```in```
Public Sub DrawGUI()
```And below it add:
```
DrawBankItemDesc
```
And in modConstants change```
Public Const GUI_Count As Long = 12
```to```
Public Const GUI_Count As Long = 12
```
You may also want to add this:
```
    If GUIWindow(GUI_BANK).visible Then
        If keyCode = vbKeyEscape Then
            GUIWindow(GUI_BANK).visible = Not GUIWindow(GUI_BANK).visible
            InBank = False
    End If
    End If
```Sorry, i thought i forgot some things xD

Ill clean up this tutorial ASAP, im just tired tonight…

That should be it, if i forgot something, tell me and ill be sure to get it in :)
Have a nice day
Link to comment
Share on other sites

@WÑ–ng:

> If you can figure it out without asking for my help then you get a cookie.

I figured the bank system out, Jc helped me with one fragment of code:```
GUIWindow(GUI_BANK).y
```Which i forgot to add somehow xD
Link to comment
Share on other sites

@jcsnider:

> :P

Idk what he is talking about, i totally asked jc for help with that one missing piece xD
Totally stealing your glory ;]

TROLOL:

>! ![](http://www.freemmorpgmaker.com/files/imagehost/pics/15fb5263e3dcfebe8a1f0b23bb54b40a.png)

Ill finish working on it tomorrow ;]
Link to comment
Share on other sites

You should add in sub handlekeyup

```
    If GUIWindow(GUI_BANK).visible Then
        If keyCode = vbKeyEscape Then
            GUIWindow(GUI_BANK).visible = Not GUIWindow(GUI_BANK).visible
            InBank = False
    End If
    End If
```
Link to comment
Share on other sites

It's fairly simple anyway.. It's the EO trade system with the rendering modified to CS:DE. Anyone that's halfway serious about it *should* be able to pull it off if they want to, or ask for help regarding certain parts of the process. :]
Link to comment
Share on other sites

It was literately the easiest thing i have ever done after i figured out how rendering works. I didn't need any help with the trade system. But i admit JC helped me with a fragment in the bank system (Still cannot believe i forgot that xD)
Link to comment
Share on other sites

  • 2 weeks later...
hi there i put this banking system in and it seems to crash my client when i step on a bank tile.  The only thing that pops up is a black box that is ment to be the bank window then it stops responding. Any ideas?
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...