FAQ
FAQ
Search
Search
Memberlist
Memberlist
Usergroups
Usergroups
Profile
Profile
Log out [ genusis ]
Log out [ genusis ]
You have no new messages
You have no new messages
Elysium Source Forum Index » Approved Tutorials

Post new topic   This topic is locked: you cannot edit posts or make replies.
Bank Tutorial (Code from Deloria) Goto page 1, 2, 3  Next
View previous topic :: View next topic  
Author Message
Griff
Moderator


Joined: 23 Feb 2006
Posts: 312
Location: A User Created World
Points

PostPosted: Thu Feb 23, 2006 8:23 pm    Post subject: Bank Tutorial (Code from Deloria) Reply with quote

==========CLIENT============

Good gawd it took longer than I thought to do this, cause its been a couple of
months since I got it working. But here you go, IT SHOULD WORK CAUSE I RAN IT!
I used the Asgard (LilN00b Bug fixed) Source, but I did this before with DeBugged so it should be fine with most Elysium sources (Before Diamond).
EDIT: Tested with DeBugged v2 and it works.

Go to modTypes, find
Code:
Public Const MAX_INV = 24

Paste
Code:
Public Const MAX_BANK = 50
under it

Find
Code:
Public Const TILE_TYPE_NPC_SPAWN = 20

Paste
Code:
Public Const TILE_TYPE_BANK = 23
under it
(Reason for it being 23 is because the server has constants which use 21 & 22, so I just want it to be the same for both client & server)

Find
Code:
Type ChatBubble

Paste
Code:
Type BankRec
    Num As Long
    Value As Long
    Dur As Long
End Type
under it (after the ChatBubble End Type)

Find
Code:
Spell(1 To MAX_PLAYER_SPELLS) As Long
which is in Type PlayerRec
Paste
Code:
Bank(1 To MAX_BANK) As BankRec
under that

Find
Code:
For n = 1 To MAX_INV
which should be in the ClearPlayer sub
Paste
Code:
    For n = 1 To MAX_BANK
        Player(index).Bank(n).Num = 0
        Player(index).Bank(n).Value = 0
        Player(index).Bank(n).Dur = 0
    Next n
under that FOR loop

Go to the bottom of modTypes and paste this in
Code:
Function GetPlayerBankItemNum(ByVal Index As Long, ByVal BankSlot As Long) As Long
    If BankSlot > MAX_BANK Then Exit Function
    GetPlayerBankItemNum = Player(Index).Bank(BankSlot).Num
End Function

Sub SetPlayerBankItemNum(ByVal Index As Long, ByVal BankSlot As Long, ByVal ItemNum As Long)
    Player(Index).Bank(BankSlot).Num = ItemNum
End Sub

Function GetPlayerBankItemValue(ByVal Index As Long, ByVal BankSlot As Long) As Long
    GetPlayerBankItemValue = Player(Index).Bank(BankSlot).Value
End Function

Sub SetPlayerBankItemValue(ByVal Index As Long, ByVal BankSlot As Long, ByVal ItemValue As Long)
    Player(Index).Bank(BankSlot).Value = ItemValue
End Sub

Function GetPlayerBankItemDur(ByVal Index As Long, ByVal BankSlot As Long) As Long
    GetPlayerBankItemDur = Player(Index).Bank(BankSlot).Dur
End Function

Sub SetPlayerBankItemDur(ByVal Index As Long, ByVal BankSlot As Long, ByVal ItemDur As Long)
    Player(Index).Bank(BankSlot).Dur = ItemDur
End Sub


Now we switch to modGameLogic...
Find
Code:
If .Type = TILE_TYPE_NPC_SPAWN Then
which is in EditorMouseDown sub
Under that IF statement paste this (I mean after the NPCSpawn IF Statement which is after its END IF)
Code:
If .Type = TILE_TYPE_BANK Then frmAttributes.optBank.Value = True


Find
Code:
If frmAttributes.optNPC.Value = True Then

Under that IF statement paste this
Code:
                            If frmAttributes.optBank.Value = True Then
                                .Type = TILE_TYPE_BANK
                                .Data1 = 0
                                .Data2 = 0
                                .Data3 = 0
                                .String1 = ""
                                .String2 = ""
                                .String3 = ""
                            End If


Go to the bottom of modGameLogic and paste this
Code:
Sub UpdateBank()
Dim i As Long

frmBank.lstInventory.Clear
frmBank.lstBank.Clear

For i = 1 To MAX_INV
    If GetPlayerInvItemNum(MyIndex, i) > 0 Then
        If Item(GetPlayerInvItemNum(MyIndex, i)).Type = ITEM_TYPE_CURRENCY Then
            frmBank.lstInventory.AddItem i & "> " & Trim(Item(GetPlayerInvItemNum(MyIndex, i)).name) & " (" & GetPlayerInvItemValue(MyIndex, i) & ")"
        Else
            If GetPlayerWeaponSlot(MyIndex) = i Or GetPlayerArmorSlot(MyIndex) = i Or GetPlayerHelmetSlot(MyIndex) = i Or GetPlayerShieldSlot(MyIndex) = i Then
                frmBank.lstInventory.AddItem i & "> " & Trim(Item(GetPlayerInvItemNum(MyIndex, i)).name) & " (worn)"
            Else
                frmBank.lstInventory.AddItem i & "> " & Trim(Item(GetPlayerInvItemNum(MyIndex, i)).name)
            End If
        End If
    Else
        frmBank.lstInventory.AddItem i & "> Empty"
    End If
    DoEvents
Next i

For i = 1 To MAX_BANK
    If GetPlayerBankItemNum(MyIndex, i) > 0 Then
        If Item(GetPlayerBankItemNum(MyIndex, i)).Type = ITEM_TYPE_CURRENCY Then
            frmBank.lstBank.AddItem i & "> " & Trim(Item(GetPlayerBankItemNum(MyIndex, i)).name) & " (" & GetPlayerBankItemValue(MyIndex, i) & ")"
        Else
            If GetPlayerWeaponSlot(MyIndex) = i Or GetPlayerArmorSlot(MyIndex) = i Or GetPlayerHelmetSlot(MyIndex) = i Or GetPlayerShieldSlot(MyIndex) = i Then
                frmBank.lstBank.AddItem i & "> " & Trim(Item(GetPlayerBankItemNum(MyIndex, i)).name) & " (worn)"
            Else
                frmBank.lstBank.AddItem i & "> " & Trim(Item(GetPlayerBankItemNum(MyIndex, i)).name)
            End If
        End If
    Else
        frmBank.lstBank.AddItem i & "> Empty"
    End If
    DoEvents
Next i
frmBank.lstBank.ListIndex = 0
frmBank.lstInventory.ListIndex = 0
End Sub


Now go over to frmMapEditor and go to mnuFill
Find
Code:
If frmAttributes.optNPC.Value = True Then

Then under that IF statement paste this
Code:
                If frmAttributes.optBank.Value = True Then
                    .Type = TILE_TYPE_BANK
                    .Data1 = 0
                    .Data2 = 0
                    .Data3 = 0
                    .String1 = ""
                    .String2 = ""
                    .String3 = ""
                End If


Find the GameLoop sub and search for
Code:
If .Light > 0 Then Call DrawText


Then under that paste
Code:
If .Type = TILE_TYPE_BANK Then Call DrawText(TexthDC, x * PIC_X + sx + 8 - (NewPlayerX * PIC_X) - NewXOffset, y * PIC_Y + sx + 8 - (NewPlayerY * PIC_Y) - NewYOffset, "BANK", QBColor(BrightRed))


Now you go over to the HandleData sub (inside modClientTCP) and search for

Code:
Player worn equipment packet

under that packet code, paste this
Code:
    ' ::::::::::::::::::::::::
    ' :: Player bank packet ::
    ' ::::::::::::::::::::::::
    If LCase(Parse(0)) = "playerbank" Then
        n = 1
        For i = 1 To MAX_BANK
            Call SetPlayerBankItemNum(MyIndex, i, Val(Parse(n)))
            Call SetPlayerBankItemValue(MyIndex, i, Val(Parse(n + 1)))
            Call SetPlayerBankItemDur(MyIndex, i, Val(Parse(n + 2)))
           
            n = n + 3
        Next i
       
        If frmBank.Visible = True Then Call UpdateBank
        Exit Sub
    End If
   
    ' :::::::::::::::::::::::::::::::
    ' :: Player bank update packet ::
    ' :::::::::::::::::::::::::::::::
    If LCase(Parse(0)) = "playerbankupdate" Then
        n = Val(Parse(1))
       
        Call SetPlayerBankItemNum(MyIndex, n, Val(Parse(2)))
        Call SetPlayerBankItemValue(MyIndex, n, Val(Parse(3)))
        Call SetPlayerBankItemDur(MyIndex, n, Val(Parse(4)))
        If frmBank.Visible = True Then Call UpdateBank
        Exit Sub
    End If
   
    If LCase(Parse(0)) = "openbank" Then
        frmBank.lblBank.Caption = Trim(Map(GetPlayerMap(MyIndex)).name)
        frmBank.lstInventory.Clear
        frmBank.lstBank.Clear
        For i = 1 To MAX_INV
            If GetPlayerInvItemNum(MyIndex, i) > 0 Then
                If Item(GetPlayerInvItemNum(MyIndex, i)).Type = ITEM_TYPE_CURRENCY Then
                    frmBank.lstInventory.AddItem i & "> " & Trim(Item(GetPlayerInvItemNum(MyIndex, i)).name) & " (" & GetPlayerInvItemValue(MyIndex, i) & ")"
                Else
                    If GetPlayerWeaponSlot(MyIndex) = i Or GetPlayerArmorSlot(MyIndex) = i Or GetPlayerHelmetSlot(MyIndex) = i Or GetPlayerShieldSlot(MyIndex) = i Then
                        frmBank.lstInventory.AddItem i & "> " & Trim(Item(GetPlayerInvItemNum(MyIndex, i)).name) & " (worn)"
                    Else
                        frmBank.lstInventory.AddItem i & "> " & Trim(Item(GetPlayerInvItemNum(MyIndex, i)).name)
                    End If
                End If
            Else
                frmBank.lstInventory.AddItem i & "> Empty"
            End If
            DoEvents
        Next i
       
        For i = 1 To MAX_BANK
            If GetPlayerBankItemNum(MyIndex, i) > 0 Then
                If Item(GetPlayerBankItemNum(MyIndex, i)).Type = ITEM_TYPE_CURRENCY Then
                    frmBank.lstBank.AddItem i & "> " & Trim(Item(GetPlayerBankItemNum(MyIndex, i)).name) & " (" & GetPlayerBankItemValue(MyIndex, i) & ")"
                Else
                    If GetPlayerWeaponSlot(MyIndex) = i Or GetPlayerArmorSlot(MyIndex) = i Or GetPlayerHelmetSlot(MyIndex) = i Or GetPlayerShieldSlot(MyIndex) = i Then
                        frmBank.lstBank.AddItem i & "> " & Trim(Item(GetPlayerBankItemNum(MyIndex, i)).name) & " (worn)"
                    Else
                        frmBank.lstBank.AddItem i & "> " & Trim(Item(GetPlayerBankItemNum(MyIndex, i)).name)
                    End If
                End If
            Else
                frmBank.lstBank.AddItem i & "> Empty"
            End If
            DoEvents
        Next i
        frmBank.lstBank.ListIndex = 0
        frmBank.lstInventory.ListIndex = 0
       
        frmBank.Show vbModal
        Exit Sub
    End If
   
    If LCase(Parse(0)) = "bankmsg" Then
        frmBank.lblMsg.Caption = Trim(Parse(1))
        Exit Sub
    End If


Now download the Bank Form from Deloria (http://chaosfusion.com/elysiumwiki/DELORIA_BANK_FORM.rar)
And add it to the project (Right click the FORMS folder, go to Add, then "Add File...", last browse for the bank form, wherever you extracted it)

Now the code part is over for the client, but we have to add some items so they are declared, otherwise it would just make errors asking where are those vars.

I think we just have to add the optBank item, go to the frmAttributes
Then drag the Layers frame to the right abit so you can insert the optBank item
Click the attributes frame, then click the OptionButton item on the toolbar
Then put it in the attributes frame, This is the current style if you want to

keep the same look :(Tahoma, Size 7, Regular Style)
_________________
fix sig later


Last edited by Griff on Sun May 28, 2006 5:40 pm; edited 4 times in total
Back to top
View user's profile Send private message Visit poster's website AIM Address
Griff
Moderator


Joined: 23 Feb 2006
Posts: 312
Location: A User Created World
Points

PostPosted: Thu Feb 23, 2006 8:24 pm    Post subject: Reply with quote

===========================================================
===========================================================
===========================================================
ATTENTION!!! CHANGING TO SERVER CODE!!!
===========================================================
===========================================================
===========================================================

Ok, now to the Server!

Go to modTypes, find
Code:
Public Const MAX_INV = 24

Paste
Code:
Public Const MAX_BANK = 50
under it

Find
Code:
Public Const TILE_TYPE_SAVEPOINT = 22

Paste
Code:
Public Const TILE_TYPE_BANK = 23
under it

Find
Code:
Public Const TARGET_TYPE_ATTRIBUTE_NPC = 2

Paste
Code:
Type BankRec
    Num As Long
    Value As Long
    Dur As Long
End Type
under it

Find
Code:
Spell(1 To MAX_PLAYER_SPELLS) As Long
which is in Type

PlayerRec
Paste
Code:
Bank(1 To MAX_BANK) As BankRec
under that

Find
Code:
For n = 1 To MAX_INV
which should be in the ClearPlayer sub
Paste
Code:
    For n = 1 To MAX_BANK
        Player(index).Char(i).Bank(n).Num = 0
        Player(index).Char(i).Bank(n).Value = 0
        Player(index).Char(i).Bank(n).Dur = 0
    Next n
under that FOR loop

Find
Code:
For n = 1 To MAX_INV
which should be in the ClearChar sub
Paste
Code:
    For n = 1 To MAX_BANK
        Player(index).Char(CharNum).Bank(n).Num = 0
        Player(index).Char(CharNum).Bank(n).Value = 0
        Player(index).Char(CharNum).Bank(n).Dur = 0
    Next n
under that FOR loop

Go to the bottom of modTypes and paste this in
Code:
Function GetPlayerBankItemNum(ByVal index As Long, ByVal BankSlot As Long) As Long
    GetPlayerBankItemNum = Player(index).Char(Player(index).CharNum).Bank(BankSlot).Num
End Function

Sub SetPlayerBankItemNum(ByVal index As Long, ByVal BankSlot As Long, ByVal ItemNum As Long)
    Player(index).Char(Player(index).CharNum).Bank(BankSlot).Num = ItemNum
    Call SendBankUpdate(index, BankSlot)
End Sub

Function GetPlayerBankItemValue(ByVal index As Long, ByVal BankSlot As Long) As Long
    GetPlayerBankItemValue = Player(index).Char(Player(index).CharNum).Bank(BankSlot).Value
End Function

Sub SetPlayerBankItemValue(ByVal index As Long, ByVal BankSlot As Long, ByVal ItemValue As Long)
    Player(index).Char(Player(index).CharNum).Bank(BankSlot).Value = ItemValue
    Call SendBankUpdate(index, BankSlot)
End Sub

Function GetPlayerBankItemDur(ByVal index As Long, ByVal BankSlot As Long) As Long
    GetPlayerBankItemDur = Player(index).Char(Player(index).CharNum).Bank(BankSlot).Dur
End Function

Sub SetPlayerBankItemDur(ByVal index As Long, ByVal BankSlot As Long, ByVal ItemDur As Long)
    Player(index).Char(Player(index).CharNum).Bank(BankSlot).Dur = ItemDur
End Sub


Go to modGameLogic, and under the FindOpenInvSlot Function
Paste this
Code:
Function FindOpenBankSlot(ByVal index As Long, ByVal ItemNum As Long) As Long
Dim i As Long
   
    FindOpenBankSlot = 0
   
    ' Check for subscript out of range
    If IsPlaying(index) = False Or ItemNum <= 0 Or ItemNum > MAX_ITEMS Then
        Exit Function
    End If
   
    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_BANK
            If GetPlayerBankItemNum(index, i) = ItemNum Then
                FindOpenBankSlot = i
                Exit Function
            End If
        Next i
    End If
   
    For i = 1 To MAX_BANK
        ' Try to find an open free slot
        If GetPlayerBankItemNum(index, i) = 0 Then
            FindOpenBankSlot = i
            Exit Function
        End If
    Next i
End Function


Find the GiveItem sub and under that sub, paste this
Code:
Sub TakeBankItem(ByVal index As Long, ByVal ItemNum As Long, ByVal ItemVal As Long)
Dim i As Long, n As Long
Dim TakeBankItem As Boolean

    TakeBankItem = False
   
    ' Check for subscript out of range
    If IsPlaying(index) = False Or ItemNum <= 0 Or ItemNum > MAX_ITEMS Then
        Exit Sub
    End If
   
    For i = 1 To MAX_BANK
        ' Check to see if the player has the item
        If GetPlayerBankItemNum(index, i) = ItemNum Then
            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 >= GetPlayerBankItemValue(index, i) Then
                    TakeBankItem = True
                Else
                    Call SetPlayerBankItemValue(index, i, GetPlayerBankItemValue(index, i) - ItemVal)
                    Call SendBankUpdate(index, i)
                End If
            Else
                ' Check to see if its any sort of ArmorSlot/WeaponSlot
                Select Case Item(GetPlayerBankItemNum(index, i)).Type
                    Case ITEM_TYPE_WEAPON
                        If GetPlayerWeaponSlot(index) > 0 Then
                            If i = GetPlayerWeaponSlot(index) Then
                                Call SetPlayerWeaponSlot(index, 0)
                                Call SendWornEquipment(index)
                                TakeBankItem = True
                            Else
                                ' Check if the item we are taking isn't already equipped
                                If ItemNum <> GetPlayerBankItemNum(index,GetPlayerWeaponSlot(index)) Then
                                    TakeBankItem = True
                                End If
                            End If
                        Else
                            TakeBankItem = True
                        End If
               
                    Case ITEM_TYPE_ARMOR
                        If GetPlayerArmorSlot(index) > 0 Then
                            If i = GetPlayerArmorSlot(index) Then
                                Call SetPlayerArmorSlot(index, 0)
                                Call SendWornEquipment(index)
                                TakeBankItem = True
                            Else
                                ' Check if the item we are taking isn't already equipped
                                If ItemNum <> GetPlayerBankItemNum(index,GetPlayerArmorSlot(index)) Then
                                    TakeBankItem = True
                                End If
                            End If
                        Else
                            TakeBankItem = True
                        End If
                   
                    Case ITEM_TYPE_HELMET
                        If GetPlayerHelmetSlot(index) > 0 Then
                            If i = GetPlayerHelmetSlot(index) Then
                                Call SetPlayerHelmetSlot(index, 0)
                                Call SendWornEquipment(index)
                                TakeBankItem = True
                            Else
                                ' Check if the item we are taking isn't already equipped
                                If ItemNum <> GetPlayerBankItemNum(index,GetPlayerHelmetSlot(index)) Then
                                    TakeBankItem = True
                                End If
                            End If
                        Else
                            TakeBankItem = True
                        End If
                   
                    Case ITEM_TYPE_SHIELD
                        If GetPlayerShieldSlot(index) > 0 Then
                            If i = GetPlayerShieldSlot(index) Then
                                Call SetPlayerShieldSlot(index, 0)
                                Call SendWornEquipment(index)
                                TakeBankItem = True
                            Else
                                ' Check if the item we are taking isn't already equipped
                                If ItemNum <> GetPlayerBankItemNum(index,GetPlayerShieldSlot(index)) Then
                                    TakeBankItem = True
                                End If
                            End If
                        Else
                            TakeBankItem = True
                        End If
                End Select

               
                n = Item(GetPlayerBankItemNum(index, i)).Type
                ' Check if its not an equipable weapon, and if it isn't then take it away
                If (n <> ITEM_TYPE_WEAPON) And (n <> ITEM_TYPE_ARMOR) And (n <> ITEM_TYPE_HELMET) And (n <> ITEM_TYPE_SHIELD) Then
                    TakeBankItem = True
                End If
            End If
                           
            If TakeBankItem = True Then
                Call SetPlayerBankItemNum(index, i, 0)
                Call SetPlayerBankItemValue(index, i, 0)
                Call SetPlayerBankItemDur(index, i, 0)
               
                ' Send the Bank update
                Call SendBankUpdate(index, i)
                Exit Sub
            End If
        End If
    Next i
End Sub

Sub GiveBankItem(ByVal index As Long, ByVal ItemNum As Long, ByVal ItemVal As Long, ByVal BankSlot 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 Sub
    End If
   
    i = BankSlot
   
    ' Check to see if Bankentory is full
    If i <> 0 Then
        Call SetPlayerBankItemNum(index, i, ItemNum)
        Call SetPlayerBankItemValue(index, i, GetPlayerBankItemValue(index, i) + ItemVal)
       
        If (Item(ItemNum).Type = ITEM_TYPE_ARMOR) Or (Item(ItemNum).Type = ITEM_TYPE_WEAPON) Or (Item(ItemNum).Type = ITEM_TYPE_HELMET) Or (Item(ItemNum).Type = ITEM_TYPE_SHIELD) Then
            Call SetPlayerBankItemDur(index, i, Item(ItemNum).Data1)
        End If
    Else
        Call SendDataTo(index, "bankmsg" & SEP_CHAR & "Bank full!" & SEP_CHAR & END_CHAR)
    End If
End Sub


Go to the PlayerMove sub, and at the end of the sub, but BEFORE the command End Sub, paste this
Code:
    ' Check if player stepped on Bank tile
    If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type = TILE_TYPE_BANK Then
        Call SendDataTo(index, "openbank" & SEP_CHAR & END_CHAR)
    End If

Go to the JoinGame sub and find
Code:
Call SendInventory(index)

Paste
Code:
    Call SendBank(index)
under that

Go to modGeneral and go to the InitServer sub, find
Code:
If LCase(Dir(App.Path & "\shops", vbDirectory)) <> "shops" Then

Under that IF statement, paste this
Code:
    If LCase(Dir(App.Path & "\banks",vbDirectory)) <> "banks" Then
        Call MkDir(App.Path & "\Banks")
    End If


Go to modServerTCP, then go to SendInventory sub, and above that, paste this
Code:
Sub SendBank(ByVal index As Long)
Dim Packet As String
Dim i As Long

    Packet = "PLAYERBANK" & SEP_CHAR
    For i = 1 To MAX_BANK
        Packet = Packet & GetPlayerBankItemNum(index, i) & SEP_CHAR & GetPlayerBankItemValue(index, i) & SEP_CHAR & GetPlayerBankItemDur(index, i) & SEP_CHAR
    Next i
    Packet = Packet & END_CHAR
   
    Call SendDataTo(index, Packet)
End Sub

Sub SendBankUpdate(ByVal index As Long, ByVal BankSlot As Long)
Dim Packet As String
   
    Packet = "PLAYERBANKUPDATE" & SEP_CHAR & BankSlot & SEP_CHAR & GetPlayerBankItemNum(index, BankSlot) & SEP_CHAR & GetPlayerBankItemValue(index, BankSlot) & SEP_CHAR & GetPlayerBankItemDur(index, BankSlot) & SEP_CHAR & END_CHAR
    Call SendDataTo(index, Packet)
End Sub


Go to clsCommands, and at the bottom, paste this
Code:
Function GetPlayerBankItemNum(ByVal index As Long, ByVal BankSlot As Long) As Long
    GetPlayerBankItemNum = Player(index).Char(Player(index).CharNum).Bank(BankSlot).Num
End Function

Sub SetPlayerBankItemNum(ByVal index As Long, ByVal BankSlot As Long, ByVal ItemNum As Long)
    Player(index).Char(Player(index).CharNum).Bank(BankSlot).Num = ItemNum
    Call SendBankUpdate(index, BankSlot)
End Sub

Function GetPlayerBankItemValue(ByVal index As Long, ByVal BankSlot As Long) As Long
    GetPlayerBankItemValue = Player(index).Char(Player(index).CharNum).Bank(BankSlot).Value
End Function

Sub SetPlayerBankItemValue(ByVal index As Long, ByVal BankSlot As Long, ByVal ItemValue As Long)
    Player(index).Char(Player(index).CharNum).Bank(BankSlot).Value = ItemValue
    Call SendBankUpdate(index, BankSlot)
End Sub

Function GetPlayerBankItemDur(ByVal index As Long, ByVal BankSlot As Long) As Long
    GetPlayerBankItemDur = Player(index).Char(Player(index).CharNum).Bank(BankSlot).Dur
End Function

Sub SetPlayerBankItemDur(ByVal index As Long, ByVal BankSlot As Long, ByVal ItemDur As Long)
    Player(index).Char(Player(index).CharNum).Bank(BankSlot).Dur = ItemDur
End Sub


Go to the HandleData sub which is in modServerTCP, and search for
Code:
Call SendDataTo(index, Packs)

Under that paste this
Code:
                If FileExist("banks\" & Trim(Name) & ".ini") = False Then
                    For i = 1 To MAX_CHARS
                        For n = 1 To MAX_BANK
                            Call PutVar(App.Path & "\banks\" & Trim(Name) & ".ini", "CHAR" & i, "BankItemNum" & n, STR(Player(index).Char(i).Bank(n).Num))
                            Call PutVar(App.Path & "\banks\" & Trim(Name) & ".ini", "CHAR" & i, "BankItemVal" & n, STR(Player(index).Char(i).Bank(n).Value))
                            Call PutVar(App.Path & "\banks\" & Trim(Name) & ".ini", "CHAR" & i, "BankItemDur" & n, STR(Player(index).Char(i).Bank(n).Dur))
                        Next n
                    Next i
                End If


Go to HandleData sub, and under the last variable being declared, paste this
Code:
Dim TempNum As Long, TempVal As Long


Go to the end of the HandleData sub, and right before the HackingAttempt call,

paste this
Code:
Select Case LCase(Parse(0))
    Case "bankdeposit"
        x = GetPlayerInvItemNum(index, Val(Parse(1)))
        i = FindOpenBankSlot(index, x)
        If i = 0 Then
            Call SendDataTo(index, "bankmsg" & SEP_CHAR & "Bank full!" & SEP_CHAR & END_CHAR)
            Exit Sub
        End If
       
        If Val(Parse(2)) > GetPlayerInvItemValue(index, Val(Parse(1))) Then
            Call SendDataTo(index, "bankmsg" & SEP_CHAR & "You cant deposit more than you have!" & SEP_CHAR & END_CHAR)
            Exit Sub
        End If
       
        If GetPlayerWeaponSlot(index) = Val(Parse(1)) Or GetPlayerArmorSlot(index) = Val(Parse(1)) Or GetPlayerShieldSlot(index) = Val(Parse(1)) Or GetPlayerHelmetSlot(index) = Val(Parse(1)) Then
            Call SendDataTo(index, "bankmsg" & SEP_CHAR & "You cant deposit worn equipment!" & SEP_CHAR & END_CHAR)
            Exit Sub
        End If
       
        If Item(x).Type = ITEM_TYPE_CURRENCY Then
            If Val(Parse(2)) <= 0 Then
                Call SendDataTo(index, "bankmsg" & SEP_CHAR & "You must deposit more than 0!" & SEP_CHAR & END_CHAR)
                Exit Sub
            End If
        End If
       
        Call TakeItem(index, x, Val(Parse(2)))
        Call GiveBankItem(index, x, Val(Parse(2)), i)
       
        Call SendBank(index)
        Exit Sub
   
    Case "bankwithdraw"
        i = GetPlayerBankItemNum(index, Val(Parse(1)))
        TempVal = Val(Parse(2))
        x = FindOpenInvSlot(index, i)
        If x = 0 Then
            Call SendDataTo(index, "bankmsg" & SEP_CHAR & "Inventory full!" & SEP_CHAR & END_CHAR)
            Exit Sub
        End If
       
        If Val(Parse(2)) > GetPlayerBankItemValue(index, Val(Parse(1))) Then
            Call SendDataTo(index, "bankmsg" & SEP_CHAR & "You cant withdraw more than you have!" & SEP_CHAR & END_CHAR)
            Exit Sub
        End If
               
        If Item(i).Type = ITEM_TYPE_CURRENCY Then
            If Val(Parse(2)) <= 0 Then
                Call SendDataTo(index, "bankmsg" & SEP_CHAR & "You must withdraw more than 0!" & SEP_CHAR & END_CHAR)
                Exit Sub
            End If

            If Trim(LCase(Item(GetPlayerInvItemNum(index, x)).Name)) <> "gold" Then
                If GetPlayerInvItemValue(index, x) + Val(Parse(2)) > 100 Then
                    TempVal = 100 - GetPlayerInvItemValue(index, x)
                End If
            End If
        End If
               
        Call GiveItem(index, i, TempVal)
        Call TakeBankItem(index, i, TempVal)
       
        Call SendBank(index)
        Exit Sub
End Select


Go to modDatabase, and then go to SavePlayer sub, after the SPELLS FOR loop and

before the Next i, paste this
Code:
        FileName = App.Path & "\banks\" & Trim(Player(index).Login) & ".ini"
        ' Bank
        For n = 1 To MAX_BANK
            Call PutVar(FileName, "CHAR" & i, "BankItemNum" & n, STR(Player(index).Char(i).Bank(n).Num))
            Call PutVar(FileName, "CHAR" & i, "BankItemVal" & n, STR(Player(index).Char(i).Bank(n).Value))
            Call PutVar(FileName, "CHAR" & i, "BankItemDur" & n, STR(Player(index).Char(i).Bank(n).Dur))
        Next n


Scroll down to LoadPlayer, and in the same spot, paste this
Code:
        FileName = App.Path & "\banks\" & Trim(Name) & ".ini"
        ' Bank
        For n = 1 To MAX_BANK
            Player(index).Char(i).Bank(n).Num = Val(GetVar(FileName, "CHAR" & i,"BankItemNum" & n))
            Player(index).Char(i).Bank(n).Value = Val(GetVar(FileName, "CHAR" & i, "BankItemVal" & n))
            Player(index).Char(i).Bank(n).Dur = Val(GetVar(FileName, "CHAR" & i,"BankItemDur" & n))
        Next n

_________________
fix sig later


Last edited by Griff on Tue Feb 28, 2006 4:01 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website AIM Address
Moo
Newcomer


Joined: 26 Feb 2006
Posts: 35

Points

PostPosted: Sun Feb 26, 2006 2:40 pm    Post subject: Reply with quote

When I shut down the server and restart it the bank tile doesn't work anymore. However, it still shows the tile as a bank tile in the map editor.

Any help would be greatly appreciated.

Edit: I found that if you edit the map the tiles will work again. Still looking for the cause of the problem.
Back to top
View user's profile Send private message
vman
Jr. Member


Joined: 24 Feb 2006
Posts: 64
Location: UK
Points

PostPosted: Mon Feb 27, 2006 3:03 pm    Post subject: Reply with quote

umm, Whats the code for the attributes bank option???
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Griff
Moderator


Joined: 23 Feb 2006
Posts: 312
Location: A User Created World
Points

PostPosted: Mon Feb 27, 2006 4:28 pm    Post subject: Reply with quote

@moo - what engine you using and version?

@vman - what do mean? code for option? i hope you arent asking how to put it on there
_________________
fix sig later
Back to top
View user's profile Send private message Visit poster's website AIM Address
Moo
Newcomer


Joined: 26 Feb 2006
Posts: 35

Points

PostPosted: Mon Feb 27, 2006 6:07 pm    Post subject: Reply with quote

Elysium DB v2

(With some other additions)
Back to top
View user's profile Send private message
Griff
Moderator


Joined: 23 Feb 2006
Posts: 312
Location: A User Created World
Points

PostPosted: Mon Feb 27, 2006 9:14 pm    Post subject: Reply with quote

well i tested on that, and it worked fine, so you will just have to double check
_________________
fix sig later
Back to top
View user's profile Send private message Visit poster's website AIM Address
Moo
Newcomer


Joined: 26 Feb 2006
Posts: 35

Points

PostPosted: Mon Feb 27, 2006 10:43 pm    Post subject: Reply with quote

I'll do that (again).

I'll get back to you, thanks.
Back to top
View user's profile Send private message
marsh
Sr. Member


Joined: 28 Feb 2006
Posts: 256

Points

PostPosted: Tue Feb 28, 2006 12:52 pm    Post subject: Reply with quote

didnt give any credit to Rafiki. he didnt make the actaully code but he is the one that took the time to make it. looks like he put alot of hard work into it. Btw if you our copying his 100% its missing a line of code. Smile
Back to top
View user's profile Send private message
Griff
Moderator


Joined: 23 Feb 2006
Posts: 312
Location: A User Created World
Points

PostPosted: Tue Feb 28, 2006 3:53 pm    Post subject: Reply with quote

I am Rafiki also lol, and what code did I miss? :S
_________________
fix sig later
Back to top
View user's profile Send private message Visit poster's website AIM Address
marsh
Sr. Member


Joined: 28 Feb 2006
Posts: 256

Points

PostPosted: Tue Feb 28, 2006 5:53 pm    Post subject: Reply with quote

Griff wrote:
I am Rafiki also lol, and what code did I miss? :S


Cant post the exact line here but the tutorial didnt work i got your blank d-bugged with this addedd and check all the code over and you had a line of code that the tut did not have. i addedd it and it worked. Maybe it was just me
Back to top
View user's profile Send private message
Yossarian
Moderator


Joined: 23 Feb 2006
Posts: 363

Points

PostPosted: Tue Feb 28, 2006 6:02 pm    Post subject: Reply with quote

If this was copied and pasted right from greentail then it should work perfect.
Back to top
View user's profile Send private message
vman
Jr. Member


Joined: 24 Feb 2006
Posts: 64
Location: UK
Points

PostPosted: Tue Feb 28, 2006 6:03 pm    Post subject: Reply with quote

Quote:
@vman - what do mean? code for option? i hope you arent asking how to put it on there


No i have put all the code in and got no error's what so ever, It just doesn't work when i goto attributes and try to lay a bank tile on the ground.[/quote]
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Griff
Moderator


Joined: 23 Feb 2006
Posts: 312
Location: A User Created World
Points

PostPosted: Tue Feb 28, 2006 7:51 pm    Post subject: Reply with quote

well it works fine, but for the double inv and/or bank bug, I have this temp fix until someone posts a better one.

Make a timer on frmBank called tmCheck and at the bottom of the frmBank code paste this
Code:
Private Sub tmCheck_Timer()
    If frmBank.Visible = True Then
        If (lstInventory.ListCount > MAX_INV) Or (lstBank.ListCount > MAX_BANK) Then
            Call UpdateBank
        End If
    End If
End Sub


If the list count is over the max inv, or bank then updatebank is run to clear the extra and set it back to normal, the only problem is that when withdrawing or depositing, it flashes like 3 times but thats not as bad as double slots that cant be used.
_________________
fix sig later
Back to top
View user's profile Send private message Visit poster's website AIM Address
Yossarian
Moderator


Joined: 23 Feb 2006
Posts: 363

Points

PostPosted: Tue Feb 28, 2006 8:46 pm    Post subject: Reply with quote

Griff wrote:
well it works fine, but for the double inv and/or bank bug, I have this temp fix until someone posts a better one.

Make a timer on frmBank called tmCheck and at the bottom of the frmBank code paste this
Code:
Private Sub tmCheck_Timer()
    If frmBank.Visible = True Then
        If (lstInventory.ListCount > MAX_INV) Or (lstBank.ListCount > MAX_BANK) Then
            Call UpdateBank
        End If
    End If
End Sub


If the list count is over the max inv, or bank then updatebank is run to clear the extra and set it back to normal, the only problem is that when withdrawing or depositing, it flashes like 3 times but thats not as bad as double slots that cant be used.


Beiler posted something about fixing this in gt i believe, is this it, that is if I'm not mistaken? Did you update this in to the the tut because when I downloaded your copy I didn't work, when I did it by hand it worked fine.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    Elysium Source Forum Index » Approved Tutorials All times are GMT - 5 Hours
Goto page 1, 2, 3  Next
Page 1 of 3
Watch this topic for replies
 
Jump to:  
You cannot post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum

Powered by phpBB © 2001, 2002 phpBB Group
iCGstation v1.0 Template By Ray © 2003, 2004 iOptional