1
1
import { ActionType , RunePlugin } from '@server/plugins/plugin' ;
2
2
import { objectIds } from '@server/world/config/object-ids' ;
3
- import { widgets } from '@server/world/config/widget' ;
3
+ import { widgets , widgetScripts } from '@server/world/config/widget' ;
4
4
import { objectAction } from '@server/world/actor/player/action/object-action' ;
5
5
import { ItemContainer } from '@server/world/items/item-container' ;
6
6
import { itemAction } from '@server/world/actor/player/action/item-action' ;
7
- import { Item } from '@server/world/items/item' ;
7
+ import { fromNote , Item } from '@server/world/items/item' ;
8
8
import { buttonAction } from '@server/world/actor/player/action/button-action' ;
9
+ import { logger } from '@runejs/logger/dist/logger' ;
10
+ import { hasValueNotNull } from '@server/util/data' ;
9
11
10
12
const buttonIds : number [ ] = [
11
13
92 , // as note
@@ -24,6 +26,8 @@ export const openBankInterface: objectAction = (details) => {
24
26
25
27
details . player . outgoingPackets . sendUpdateAllWidgetItems ( widgets . bank . tabWidget , details . player . inventory ) ;
26
28
details . player . outgoingPackets . sendUpdateAllWidgetItems ( widgets . bank . screenWidget , details . player . bank ) ;
29
+ details . player . outgoingPackets . updateClientConfig ( widgetScripts . bankInsertMode , details . player . settings . bankInsertMode ) ;
30
+ details . player . outgoingPackets . updateClientConfig ( widgetScripts . bankWithdrawNoteMode , details . player . settings . bankWithdrawNoteMode ) ;
27
31
} ;
28
32
29
33
export const depositItem : itemAction = ( details ) => {
@@ -35,17 +39,26 @@ export const depositItem: itemAction = (details) => {
35
39
}
36
40
37
41
// Check if the player has the item
42
+
38
43
if ( ! details . player . hasItemInInventory ( details . itemId ) ) {
39
44
return ;
40
45
}
41
46
47
+
48
+ let itemIdToAdd : number = details . itemId ;
49
+ let fromNoteId : number = fromNote ( details . itemId ) ;
50
+ if ( fromNoteId > - 1 ) {
51
+ itemIdToAdd = fromNoteId ;
52
+ }
53
+
42
54
let countToRemove : number ;
43
55
if ( details . option . endsWith ( 'all' ) ) {
44
56
countToRemove = - 1 ;
45
57
} else {
46
58
countToRemove = + details . option . replace ( 'deposit-' , '' ) ;
47
59
}
48
60
61
+
49
62
const playerInventory : ItemContainer = details . player . inventory ;
50
63
const playerBank : ItemContainer = details . player . bank ;
51
64
const slotsWithItem : number [ ] = playerInventory . findAll ( details . itemId ) ;
@@ -55,13 +68,13 @@ export const depositItem: itemAction = (details) => {
55
68
countToRemove = itemAmount ;
56
69
}
57
70
58
- if ( ! playerBank . canFit ( { itemId : details . itemId , amount : countToRemove } , true ) ) {
71
+ if ( ! playerBank . canFit ( { itemId : itemIdToAdd , amount : countToRemove } , true ) ) {
59
72
details . player . sendMessage ( 'Your bank is full.' ) ;
60
73
return ;
61
74
}
62
75
63
76
64
- const itemToAdd : Item = { itemId : details . itemId , amount : 0 } ;
77
+ const itemToAdd : Item = { itemId : itemIdToAdd , amount : 0 } ;
65
78
while ( countToRemove > 0 && playerInventory . has ( details . itemId ) ) {
66
79
const invIndex = playerInventory . findIndex ( details . itemId ) ;
67
80
const invItem = playerInventory . items [ invIndex ] ;
@@ -75,6 +88,7 @@ export const depositItem: itemAction = (details) => {
75
88
countToRemove = 0 ;
76
89
}
77
90
}
91
+
78
92
playerBank . addStacking ( itemToAdd ) ;
79
93
80
94
0 commit comments