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


Click here to create your own public paste ~ ~ click to duplicate and edit this paste


TitleEdit of P#29205 - Edit of P#29204 - Withdraw / Deposit REGEX ?
TypeDenizen Script
Date2016/01/27 05:35:09 UTC-08:00
ByGuest
Other
Paste
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
35100
bank_world:
    type: world

    events:
        on bank command:
        - narrate "<green>Your current bank account balance is β<player.flag[bankbalance]>"
        - determine fulfilled 
        
        on 6:00 in world:
        - ^run "global_announce"
        - ^run "apply_money_interest"
        
        on 18:00 in world:
        - ^run "global_announce"
        
        on player join:
        - ^run "bank_interest_announce"
        
banker_format:
    type: format
    format<white><Bank Clerk><&co> <light_purple><text>

banker:
    type: assignment
    default constants:
        signup_bonus: 1000.0
        daily_interest: 0.0000001
        daily_interest_online: 0.000001
    actions:
        on assignment:
        - trigger name:proximity toggle:true radius:2
        - trigger name:click toggle:true
        - equip i@paper
        
    interact scripts:
    - 10 bankerscript
    
bankerscript:
    type: interact
    steps:
        1:
            proximity trigger:
                entry:
                    script:
                    - if <player.flag[hasBankAccount]> != true {
                      - ^run "welcome_task"
                      }
                      else {
                      - ^run "manage_account_task"
                      }
            click trigger:
                script:
                - if <player.flag[hasBankAccount]> == true {
                    - ^run "manage_account_task"
                  }
                  else {
                  - ^run "welcome_task"
                  }
                exit:
                    script:
                    - narrate format:banker_format "<light_purple>Thank you for visiting! We hope to see you again!"
                    - trigger name:chat toggle:false
        2:
            chat trigger:
                'open_account':
                    trigger'/REGEX:(1|Yes|y)/'
                    script:
                    - if <player.flag[hadBankAccount]> != true {
                      - narrate format:banker_format "<light_purple>That<&sq>s great! Here<&sq>s your <green>β<npc.constant[signup_bonus]> <light_purple> for opening an account"
                      - narrate "<light_purple>Your bank account has been opened and now has a balance of <green>β<npc.constant[signup_bonus]><light_purple>."
                      - announce "<aqua><player.name><light_purple> has just opened a bank account and received <green>β<npc.constant[signup_bonus]><light_purple> for free!  Come open yours today if you haven<&sq>t already!"
                      - ^flag player hadBankAccount:true
                      - ^flag player bankbalance:<npc.constant[signup_bonus]>
                      }
                    - ^flag player hasBankAccount:true
                    - narrate "<light_purple>Your bank account has been opened."
                    - trigger name:chat toggle:false
                    - ^run "manage_account_task"
                'deny_account':
                    trigger'/REGEX:(2|No|n)/'
                    script:
                    - narrate format:banker_format "Oh okay ... Thank you for visiting! We hope to see you again!"
                    - trigger name:chat toggle:false
                    - ^zap step:1
            proximity trigger:
                exit:
                    script:
                    - narrate "<aqua>The Bank Clerk looks sad"
                    - narrate format:banker_format "<light_purple>I<&sq>ll take that as a no."
                    - trigger name:chat toggle:false
                    - ^zap step:1
        3:
            chat trigger:
                'deposit_money':
                    trigger'/REGEX:(1|deposit|d)/'
                    script:
                    - ^run "deposit_money_task"
                'withdraw_money':
                    trigger'/REGEX:(2|withdraw|w)/'
                    script:
                    - ^run "withdraw_money_task"
                'check_balance':
                    trigger'/REGEX:(3|balance|b)/'
                    script:
                    - narrate "<light_purple>Your current balance is <green>β<player.flag[bankbalance]>"
                    - ^run "manage_account_task"
                'close_account':
                    trigger'/REGEX:(4|close|c)/'
                    script:
                    - narrate format:banker_format "<light_purple>Oh no! Are you sure that you<&sq>d like to do that? You<&sq>ve earned <green>β<player.flag[player_overall_interest]><light_purple> in interest so far."
                    - narrate "<light_purple>1<aqua><dark_red>Yes I<&sq>m sure. Close my account"
                    - narrate "<light_purple>2<aqua><dark_green>No, I want to keep my account open!"
                    - trigger name:chat toggle:true
                    - ^zap step:6                    
                'admin_check_ledger':
                    trigger'/REGEX:(5|ledger|l)/'
                    script:
                    - ^run "admin_check_ledger_task"
            proximity trigger:
                exit:
                    script:
                    - narrate format:banker_format "<light_purple>Thank you for visiting! We hope to see you again!"
                    - trigger name:chat toggle:false
                    - ^zap step:1
        4:
            chat trigger:
                'deposit_money_amount':
                    trigger'/REGEX:^\d+.(\d){1,2}$/'
                    script:
                    - ^if '<player.money>' >= <player.chat_history>
                      narrate format:banker_format "<light_purple>There is now <green>β<player.flag[bankbalance]><light_purple> in your account"
                      else narrate format:banker_format "<light_purple>You don<&sq>t have <green>β<player.chat_history><light_purple> to deposit!"
                    - trigger name:chat toggle:false
                    - ^run "manage_account_task"
                'deposit_money_all': 
                    trigger'/all/' 
                    script: 
                    - trigger name:chat toggle:false 
                    - narrate "You have deposited all of your money into the bank!" 
                    - flag player bankbalance:+:<player.money> 
                    - ^take money qty:<player.money> 
                    - ^run "manage_account_task" 
            proximity trigger:
                exit:
                    script:
                    - narrate format:banker_format "<light_purple>Thank you for visiting! We hope to see you again!"
                    - trigger name:chat toggle:false
                    - ^zap step:1
        5:
            chat trigger:
                'withdraw_money_amount':
                    trigger'/REGEX:^\d+.(\d){1,2}$/'
                    script:
                        - ^if '<player.flag[bankbalance]>' >= <player.chat_history>
                          narrate format:banker_format "<light_purple>You have withdrawn <green>β<player.chat_history><light_purple> from your account; your remaining balance is <green>β<player.flag[bankbalance]>"
                          else narrate format:banker_format "<light_purple>You don<&sq>t have <green>β<player.chat_history><light_purple> to withdraw!"
                        - trigger name:chat toggle:false
                        - ^run "manage_account_task"
                'withdraw_money_all':
                    trigger'/all/'
                    script: 
                    - trigger name:chat toggle:false
                    - narrate "<light_purple>You have emptied your bank account!"
                    - narrate "<light_purple>You are now holding <green>β<player.money><light_purple>!"
                    - ^give money qty:<player.flag[bankbalance]>
                    - flag player 'bankbalance:0'
                    - ^run "manage_account_task"
            proximity trigger:
                exit:
                    script:
                    - narrate format:banker_format "<light_purple>Thank you for visiting! We hope to see you again!"
                    - trigger name:chat toggle:false
                    - ^zap step:1
        6:
            chat trigger:
                'close_account':
                    trigger'/REGEX:(1|y|yes|close)/'
                    script:
                    - trigger name:chat toggle:false
                    - narrate "<aqua>The Bank Clerk looks sad"
                    - ^give money qty:<player.flag[bankbalance]>
                    - narrate "<light_purple>You are now holding <green>β<player.money><light_purple>!"
                    - flag player 'bankbalance:0'
                    - flag player 'hasBankAccount:false'
                    - narrate format:banker_format "<light_purple>Your account has been closed."
                    - ^disengage
                'dont_close_account':
                    trigger'/REGEX:(2|n|no|keep)/'
                    script:
                    - trigger name:chat toggle:false
                    - narrate format:banker_format "<light_purple>Oh good!  You had me worried there for a minute!"
                    - ^run "manage_account_task"
            proximity trigger:
                exit:
                    script:
                    - narrate format:banker_format "<light_purple>Thank you for your time with us! We hope to see you again soon!"
                    - trigger name:chat toggle:false
                    - ^zap step:1
 
welcome_task:
    type: task
    speed: 1t
    script:
    - if <player.flag[hadBankAccount]> != true {
      - narrate format:banker_format "<light_purple>Open a bank account today and get <green>β<npc.constant[signup_bonus]><light_purple>!"
      - narrate format:banker_format "<light_purple>It looks like you don<&sq>t have an account. Would you like to open one? You<&sq>ll get a special bonus for doing so."
      - narrate "<light_purple>1<aqua><dark_green>Yes let<&sq>s open an account"
      - narrate "<light_purple>2<aqua><dark_red>No thank you, not today"
      - trigger name:chat toggle:true
      - ^zap step:2 "s@bankerscript"
      } else {
        - narrate format:banker_format "<light_purple>It looks like you don<&sq>t have an account with us; open a bank account today and earn money on your savings!"
      - narrate "<light_purple>1<aqua><dark_green>Yes let<&sq>s open an account"
      - narrate "<light_purple>2<aqua><dark_red>No thank you, not today"
      - trigger name:chat toggle:true
      - ^zap step:2 "s@bankerscript"
      }
manage_account_task:
    type: task
    speed: 1t
    script:
    - trigger name:chat toggle:true
    - narrate format:banker_format "<light_purple>What would you like to do?"
    - narrate "<light_purple>1<aqua><green>Deposit<light_purple> money"
    - narrate "<light_purple>2<aqua><green>Withdraw<light_purple> money"
    - narrate "<light_purple>3<aqua><light_purple>Check your <green>balance"
    - narrate "<light_purple>4<aqua><dark_red>Close <light_purple>your account"
    - ^if <player.in_group[admin]> || <player.in_group[owner]> || <player.is_op> {
        - narrate "<gold> --- Admin Menu ---"
        - narrate "<light_purple>5<aqua><light_purple>Check Ledger"
        }
    - ^zap step:3 "s@bankerscript"
admin_check_ledger_task:
    type: task
    speed: 1t
    script:
    - ^if <player.in_group[admin]> || <player.in_group[owner]> || <player.is_op> {
        - narrate "<gold> --- Ledger ---"
        - flag global total_balance:0
        - foreach <server.list_players> {
            - define player %value%
            - ^if <%player%.flag[hasBankAccount]> == true {
                - narrate "<aqua><%player%.name> <white>has <yellow>$<%player%.flag[bankbalance]>"
                - flag global total_balance:+:<%player%.flag[bankbalance]>
                }
            }
        }
    - ^zap step:3 "s@bankerscript"
deposit_money_task:
    type: task 
    speed: 1t 
    script: 
    - narrate "<light_purple>You have <green>β<player.money><light_purple>." 
    - narrate format:banker_format "<light_purple>How much money would you like to deposit?" 
    - narrate "<light_purple>Please wait one moment then type the amount you would like to deposit or type <aqua>all<light_purple> to deposit all of your money." 
    - ^zap step:4 "s@bankerscript"
deposit_procedure:
    type: procedure
    script:
    - define to_deposit '<player.chat_history>'
    - flag player 'bankbalance:+:%to_deposit%'
    - ^take money qty:%to_deposit%
    - determine "<flag.p:bankbalance>"
withdraw_money_task:
    type: task
    speed: 1t
    script:
    - narrate "<light_purple>Your account balance is <green>β<player.flag[bankbalance]>"
    - narrate format:banker_format "<light_purple>How much would you like to withdraw?"
    - narrate "<light_purple>Please wait one moment then type the amount to withdraw or type <aqua>all<light_purple> to withdraw all"
    - ^zap step:5 "s@bankerscript"
withdraw_procedure:
    type: procedure
    script:
    - define to_withdraw '<player.chat_history>'
    - flag player 'bankbalance:-:%to_withdraw%'
    - ^give money qty:%to_withdraw%
    - determine "<flag.p:bankbalance>"
global_announce:
    type: task
    script:
    - foreach <server.get_npcs_assigned[banker]> {
      - define signup_bonus '<%value%.constant[signup_bonus]>'
      }
    - foreach <server.list_online_players> { 
        - ^if <%value%.flag[hadBankAccount]> != true {
            - narrate "<aqua>The bank is now open!" targets:%value%
            - narrate "<aqua>Come open your account today and get a bonus <green>β%signup_bonus%<aqua>!" targets:%value%
            } 
        - ^if <%value%.flag[hasBankAccount]> != true {
            - narrate "<aqua>The bank is now open!" targets:%value%
            - narrate "<aqua>Come open your account today and earn money on your savings!" targets:%value%
            }
        } 
apply_money_interest:
    type: task
    script:
    - foreach <server.get_npcs_assigned[banker]> {
      - define interest '<%value%.constant[daily_interest]>'
      - define interest_online '<%value%.constant[daily_interest_online]>'
      }
    - foreach <server.list_players> {
        - define player %value%
        - ^if <%player%.flag[hasBankAccount]> == true {
            - flag %player% player_interest:<%player%.flag[bankbalance]>
            - ^if <%player%.is_online> {
                - flag %player% player_interest:*:%interest_online%
                } else {
                - flag %player% player_interest:*:%interest%
                }
                
            - flag %player% player_interest:*:100
            - flag %player% player_interest:<%player%.flag[player_interest].asint>
            - flag %player% player_interest:/:100
            
            - flag %player% player_overall_interest:+:<%player%.flag[player_interest]>
            - flag %player% player_overall_interest:*:100
            - flag %player% player_overall_interest:<%player%.flag[player_overall_interest].asint>
            - flag %player% player_overall_interest:/:100
            
            - flag %player% player_sincelogin_interest:+:<%player%.flag[player_interest]>
            - flag %player% player_sincelogin_interest:*:100
            - flag %player% player_sincelogin_interest:<%player%.flag[player_sincelogin_interest].asint>
            - flag %player% player_sincelogin_interest:/:100
            
            - flag %player% bankbalance:+:<%player%.flag[player_interest]>
            - flag %player% bankbalance:*:100
            - flag %player% bankbalance:<%player%.flag[bankbalance].asint>
            - flag %player% bankbalance:/:100
            
            - ^if <%player%.is_online> {
                - narrate "<aqua>Bank<&co> <light_purple>You received <green>β<%player%.flag[player_interest]><light_purple> in interest, and now have <green>β<%player%.flag[bankbalance]><light_purple> in your bank." targets:%player%
                - flag %player% player_sincelogin_interest:0
                }
            }
        }
    - execute as_server 'denizen save'
    - execute as_server 'citizens save'
    
bank_interest_announce:
    type: task
    speed: 1t
    script:
    - ^if <player.flag[hasBankAccount]> == true {
        - ^if <player.flag[player_sincelogin_interest]> > 0 {
            - narrate '<aqua>Bank<&co> <light_purple>You have earned <green>β<player.flag[player_sincelogin_interest]><light_purple> in interest since you last logged on.'
            - narrate '<aqua>Bank<&co> <light_purple>You have earned <green>β<player.flag[player_overall_interest]><light_purple> in overall interest.'
            - flag player player_sincelogin_interest:0
            }
        }



RawRaw



Pastes made: 52679