- D1 Meta Docs - Denizen Script -
Home Page / Pi to one million places / Contact mcmonkey / Donate / Paste Scripts / Denizen Help /
You are browsing as a guest.
Login | Register








The script repo is an archive of historical scripts. For modern scripts, or to post your own, please use the Scripts forum section.





Staff Pick: dBanker


By Fortifier42
Created: 2015/10/18 18:50:05 UTC-07:00 (9 years and 67 days ago)
Edited: 2015/10/30 22:57:22 UTC-07:00 (9 years and 55 days ago)
Likes: 0

Staff pick as of: 2015/10/18 18:55:18 UTC-07:00 (9 years and 67 days ago)
Denizen Version: 0.9.7
Script Version: 2
Description:

dBanker is an npc assignment script which allows players to have a storage area for items, and allows for the exchange of currency for ingame coins.
Designed as an RPG/Roleplay tool!

Simply assign 'dBanker' to an NPC using '/npc assignment --set dBanker' and the script does the rest!
------------------------------------------------------------------------
Config:
--coin:
----value: # - How many economy dollars each coin is worth.
----item: item name - This is what item will be given and taken from the players in the withdrawals and deposits. Must be written as i@item e.g. 'i@dBankerCoin'
----name:
------singular: single name - The name of a single coin. e.g. Coin
------plural: multiple name - The name of multiple coins. e.g. Coins
--upgrade:
----one: # - The cost to upgrade the bank one time.
----two: # - The cost to upgrade the bank two times.
----three: # - The cost to upgrade the bank three times.


Download script | View raw script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
25500

dBankerConfig:
  type: yaml data
  coin:
    ## This is how many dollars each coin is worth.
    ## Default: 1
    value: 1
    ## This can be an itemscript or a normal minecraft item.
    ## Must be written as i@item e.g. 'i@dBankerCoin'
    ## Default: coin
    item: dBankerCoin
    name:
      ## The name of one coin. e.g. coin
      ## Default: Coin
      singular: Coin
      ## The name of more than one. e.g. coins
      ## Default: Coins
      plural: Coins
  upgrade:
    ## These are the costs for each upgrade of storage.
    ## Default: 1000
    one: 1000
    ## Default: 2000
    two: 2000
    ## Default: 3000
    three: 3000

dBankerCoin:
  type: item
  debug: false
  material: gold_nugget
  display name: A Coin
  lore:
  - <&1>A single dollar coin!

dBanker:
  type: assignment
  debug: false
  actions:
    on assignment:
      - trigger name:click state:true
      - trigger name:chat state:true
      - trigger name:proximity state:true radius:5

    on exit proximity:
      - if <pl.has_flag[dBankerStep]> {
        - flag player dBankerStep:!
        - narrate format:dBankerChat "Please, do come back soon!"
      }

    on click:
      - if <pl.has_flag[dBankerStep]> queue clear
      - look <npc> <pl.eye_location>
      - narrate format:dBankerChat "Hello <pl.name>!"
      - wait 10t
      - narrate format:dBankerChat "What can I do for you today?"
      - narrate "Type <&8>Store<&f><&8>Deposit<&f><&8>Withdraw<&f><&8>Upgrade<&f>, or <&8>Nothing<&f>."
      - flag player dBankerStep:Choose

    on chat:
      - if <player.has_flag[dBankerStep].not> queue clear
      - determine passively cancelled
      - wait 5t
      - choose <player.flag[dBankerStep]>:
        - case choose:
          - choose <context.message>:
            - case store:
              - if <server.list_notables[inventories].contains[in@dBank_<pl.uuid>].not> {
                - note "in@generic[size=27;title=<&3><pl.name><&f>'s Bank;contents=li@i@air|i@air|i@air|i@air|i@diamond]" as:dBank_<pl.uuid>
                - narrate format:dBankerChat "I've had to create a new account for you!"
                - wait 5t
                - narrate format:dBankerChat "You'll find a complimentary diamond in there for you!"
                - wait 5t
              }
              - inventory open d:in@dBank_<pl.uuid>
              - flag player dBankerStep:!

            - case withdraw:
              - define Amt <pl.money.as_int||0>
              - narrate format:dBankerChat "Okay, it looks like you have <&6><def[Amt]><&f> dollars in your account."
              - wait 5t
              - if <def[Amt]> == 0 {
                - narrate format:dBankerChat "So, I'm sorry. I can't let you withdraw at the moment!"
                - flag player dBankerStep:!
                - queue clear
              }
              - narrate format:dBankerChat "Please tell me how many <s@dBankerConfig.yaml_key[coin.name.plural]> you would like."
              - wait 5t
              - narrate format:dBankerChat "One <s@dBankerConfig.yaml_key[coin.name.singular]> is worth <&6><s@dBankerConfig.yaml_key[coin.value].as_int><&f> <t[<s@dBankerConfig.yaml_key[coin.value].as_int.is[==].to[1]>]:dollar||dollars>."
              - narrate "Type an integer. <&8>e.g. 5"
              - flag player dBankerStep:Withdraw

            - case deposit:
              - define Amt <pl.inventory.quantity[<s@dBankerConfig.yaml_key[coin.item].as_item>]>
              - narrate format:dBankerChat "Okay, it looks like you have <&6><def[Amt]><&f> <proc[CoinName].context[<def[Amt]>]>."
              - wait 5t
              - if <def[Amt]> == 0 {
                - narrate format:dBankerChat "So, I'm sorry. I can't let you deposit at the moment!"
                - flag player dBankerStep:!
                - queue clear
              }
              - narrate format:dBankerChat "Please tell me how many <s@dBankerConfig.yaml_key[coin.name.plural]> you'd like to deposit!"
              - narrate "Type an integer. <&8>e.g. 5"
              - flag player dBankerStep:Deposit

            - case upgrade:
              - if <server.list_notables[inventories].contains[in@dBank_<pl.uuid>].not> {
                - narrate format:dBankerChat "Sorry, you don't seem to have an account with us at the moment."
                - narrate format:dBankerChat "Please, ask to store items to open an account!"
                - flag player dBankerStep:!
                - queue clear
              }
              - define B in@dBank_<pl.uuid>
              - define Upgrade <def[B].size.sub[27].div[9]>
              - if <def[Upgrade]> == 3 {
                - narrate format:dBankerChat "Your bank is fully upgraded!"
                - flag player dBankerStep:!
                - queue clear
              }
              - narrate format:dBankerChat "It would seem your current upgrade tier is <&6><def[Upgrade]><&f>."
              - wait 5t
              - narrate format:dBankerChat "Would you like to upgrade to the next tier for <&6><proc[dBankerUCost].context[<def[Upgrade]>]><&f> dollars?"
              - narrate "Type <&8>Yes<&f> or <&8>No<&f>."
              - flag player dBankerStep:Upgrade

            - case nothing:
              - narrate format:dBankerChat "Okay, come back at any time!"
              - flag player dBankerStep:!

            - default:
              - narrate format:dBankerChat "I'm sorry, I have no idea what you mean!"
              - narrate "Type <&8>Store<&f><&8>Deposit<&f><&8>Withdraw<&f><&8>Upgrade<&f>, or <&8>Nothing<&f>."

        - case deposit:
          - define Amt <context.message.as_int||null>
          - if <def[Amt]> == null {
            - narrate format:dBankerChat "Sorry, I don't understand that amount. Please tell me again."
            - queue clear
          }
          - if <def[Amt]> <= 0 {
            - narrate format:dBankerChat "I can't let you do that.."
            - flag player dBankerStep:!
            - queue clear
          }
          - if <def[Amt]> > <pl.inventory.quantity[<s@dBankerConfig.yaml_key[coin.item].as_item>]> {
            - narrate format:dBankerChat "It would seem you don't have that many <s@dBankerConfig.yaml_key[coin.name.plural]>.."
            - flag player dBankerStep:!
            - queue clear
          }
          - give money quantity:<def[Amt].mul[<s@dBankerConfig.yaml_key[coin.value]>]>
          - take <s@dBankerConfig.yaml_key[coin.item].as_item> quantity:<def[Amt]>
          - narrate format:dBankerChat "I put the <proc[CoinName].context[<def[Amt]>]> in your account for you and you now have <&6><pl.money.as_int||0><&f> dollars."
          - flag player dBankerStep:!

        - case withdraw:
          - define Amt <context.message.as_int||null>
          - if <def[Amt]> == null {
            - narrate format:dBankerChat "Sorry, I don't understand that amount. Please tell me again."
            - queue clear
          }
          - if <def[Amt]> <= 0 {
            - narrate format:dBankerChat "I can't let you do that.."
            - flag player dBankerStep:!
            - queue clear
          }
          - define Val <def[Amt].mul[<s@dBankerConfig.yaml_key[coin.value]>]>
          - if <def[Val]> > <pl.money> {
            - narrate format:dBankerChat "It would seem you don't have enough money.."
            - flag player dBankerStep:!
            - queue clear
          }
          - if <pl.inventory.can_fit[<s@dBankerConfig.yaml_key[coin.item].as_item>].quantity[<def[Amt]>].not> {
            - narrate format:dBankerChat "Sorry, it looks like you can't hold the <s@dBankerConfig.yaml_key[coin.name.plural]>, you might try a few less!"
            - flag player dBankerStep:!
            - queue clear
          }
          - wait 5t
          - take money quantity:<def[Val]>
          - give <s@dBankerConfig.yaml_key[coin.item].as_item> quantity:<def[Amt]>
          - narrate format:dBankerChat "I've withdrawn the money from your account, and given you <&6><def[Amt]><&f> <proc[CoinName].context[<def[Amt]>]>."
          - flag player dBankerStep:!

        - case upgrade:
          - define Answer <li@Yes|No.filter[starts_with[<context.message>]].get[1]||null>
          - choose <def[Answer]>:
            - case yes:
              - define B in@dBank_<pl.uuid>
              - define Upgrade <def[B].size.sub[27].div[9]>
              - define Amt <el@val[1000].mul[<def[Upgrade].add[1]>]>
              - if <pl.money||0> < <def[Amt]> {
                - narrate format:dBankerChat "You don't seem to have enough money!"
                - flag player dBankerStep:!
                - queue clear
              }
              - narrate format:dBankerChat "I'll do that for you now!"
              - adjust <def[B]> size:<def[B].size.add[9]> save:B
              - take money quantity:<proc[dBankerUCost].context[<def[Upgrade]>]>
              - note <entry[B].result> as:dBank_<pl.uuid>
              - flag player dBankerStep:!
              - narrate format:dBankerChat "Your bank is now upgraded to level <&6><def[Upgrade].add[1]><&f>."

            - case no:
              - narrate format:dBankerChat "Please move along then. I have customers to serve!"
              - flag player dBankerStep:!

            - default:
              - narrate format:dBankerChat "Sorry?"
              - narrate "Type <&8>Yes<&f> or <&8>No<&f>."

dBankerUCost:
  type: procedure
  definitions: tier
  script:
  - choose <def[Tier]>:
    - case 0:
      - if <s@dBankerConfig.yaml_key[upgrade.one].as_int||1000> == "" {
        - define Cost 1000
      }
      else {
        - define Cost <s@dBankerConfig.yaml_key[upgrade.one].as_int||1000>
      }
    - case 1:
      - if <s@dBankerConfig.yaml_key[upgrade.two].as_int||2000> == "" {
        - define Cost 2000
      }
      else {
        - define Cost <s@dBankerConfig.yaml_key[upgrade.two].as_int||2000>
      }
    - case 2:
      - if <s@dBankerConfig.yaml_key[upgrade.three].as_int||3000> == "" {
        - define Cost 3000
      }
      else {
        - define Cost <s@dBankerConfig.yaml_key[upgrade.three].as_int||3000>
      }
  - determine <def[Cost]>

CoinName:
  type: procedure
  definitions: Amt
  script:
    - choose <def[Amt]>:
      - case 1:
        - determine <s@dBankerConfig.yaml_key[coin.name.singular]>
      - default:
        - determine <s@dBankerConfig.yaml_key[coin.name.plural]>

dBankerChat:
  type: format
  debug: false
  format<&6><npc.name>:<&f> <text>









View History