Date: 2016/10/28 16:58:14 UTC-07:00
Type: Denizen 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
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
352
353
354
355
356
357
358
359
Casino_Data:
type: yaml data
config:
keys:
Diamond:
display: "&bDiamond Key"
rewards:
money:
1:
chance: 4450
amount: 100
material: coal
2:
chance: 3500
amount: 150
material: iron_ingot
3:
chance: 1500
amount: 300
material: gold_ingot
4:
chance: 500
amount: 500
material: diamond
5:
chance: 50
amount: 5000
material: emerald
Emerald:
display: "&aEmerald Key"
rewards:
money:
1:
chance: 4450
amount: 150
material: coal
2:
chance: 3500
amount: 300
material: iron_ingot
3:
chance: 1500
amount: 600
material: gold_ingot
4:
chance: 500
amount: 1000
material: diamond
5:
chance: 50
amount: 10000
material: emerald
Casino_Event:
type: world
debug: false
events:
on player join:
- if <player.has_flag[Casino_Running]> {
- flag player Casino_Running:!
}
on player right clicks CHEST:
- if <player.has_flag[Casino_Running]> {
- determine cancelled
}
- foreach <s@Casino_Data.list_keys[config.keys]> {
- if <server.has_flag[Casino_Chest_<def[value]>]> {
- if <server.flag[Casino_Chest_<def[value]>].as_list.contains[<context.location>]> {
- determine cancelled passively
- inject Casino_Chest_Key_Checker
- queue clear
}
}
}
- foreach <s@Casino_Data.list_keys[config.keys]> {
- if <player.has_flag[Casino_Setup_<def[value]>]> {
- determine cancelled passively
- define flag "Casino_Chest_<def[value]>"
- flag server "<def[flag]>:->:<context.location>"
- narrate "<&a>Casino Chest <&b><def[value]> <&a>setup at <&b><context.location.simple.formatted>"
- define flag "Casino_Setup_<def[value]>"
- flag player "<def[flag]>:!"
- queue clear
}
}
- if <context.item.scriptname||false> {
- queue clear
}
on player breaks CHEST:
- if <player.is_op.not> {
- queue clear
}
- foreach <s@Casino_Data.list_keys[config.keys]> {
- if <server.has_flag[Casino_Chest_<def[value]>]> {
- if <server.flag[Casino_Chest_<def[value]>].as_list.contains[<context.location>]> {
- define flag "Casino_Chest_<def[value]>"
- flag server "<def[flag]>:<-:<context.location>"
- narrate "<&c>Casino Chest <&b><def[value]> <&c>fjernet ved <&b><context.location.simple.formatted>"
- queue clear
}
}
}
on player drags in Casino_GUI:
- determine cancelled
on player clicks in Casino_GUI:
- determine cancelled passively
- inventory close d:<context.inventory>
on player drags in Casino_GUI_Won:
- determine cancelled
on player clicks in Casino_GUI_Won:
- determine cancelled passively
- inventory close d:<context.inventory>
Casino_Chest_Key_Checker:
type: task
debug: false
script:
- if <player.item_in_hand.display_name||null> != "<s@Casino_Data.yaml_key[config.keys.<def[value]>.display].parse_color>" {
- narrate format:Util_FF "<&7>Du har ikke en <&6><def[value]> <&7>key"
- queue clear
}
# - narrate "Du har den rigtige key! <&co> <def[value]>"
- if <server.flag[Casino_Running].as_list.size||0> >= 2 {
- narrate format:Util_FF "<&c>Der er for mange som bruger casino! vent lidt..."
- queue clear
}
- flag server Casino_Running:->:<player>
- flag player Casino_Running duration:1m
- take iteminhand
- define key <def[value]>
## playsound
# <el@element.replace_text[((first)regex:)<element>].with[<element>]>
- define size <s@Casino_Data.list_keys[config.keys.<def[key]>.rewards.money].size>
- flag player Casino_Menu_Items:!
- repeat 50 {
- if <def[value]> == 40 {
- define real <proc[Casino_Real_Chance].context[<def[key]>]>
- flag player Casino_Menu_Items:->:<proc[Casino_GUI_Proc_Main].context[<def[real]>|1|<def[key]>]>[display_name=<proc[Casino_GUI_Proc_Main].context[<def[real]>|2|<def[key]>]>]
}
else {
- define random <util.random.int[1].to[5]>
- flag player Casino_Menu_Items:->:<proc[Casino_GUI_Proc_Main].context[<def[random]>|1|<def[key]>]>[display_name=<proc[Casino_GUI_Proc_Main].context[<def[random]>|2|<def[key]>]>]
}
}
- flag player Casino_Menu_Place:0
- repeat 25 {
- flag player Casino_Menu_Place:++
- playsound <player> sound:note_pling pitch:2.0
- inventory open d:in@Casino_GUI
- wait 1t
}
- if <player.is_online.not||true> {
- flag server Casino_Running:<-:<player>
- queue clear
}
- repeat 10 {
- flag player Casino_Menu_Place:++
- playsound <player> sound:note_pling pitch:2.0
- inventory open d:in@Casino_GUI
- wait 5t
}
- if <player.is_online.not||true> {
- flag server Casino_Running:<-:<player>
- queue clear
}
- repeat 1 {
- flag player Casino_Menu_Place:++
- playsound <player> sound:note_pling pitch:2.0
- inventory open d:in@Casino_GUI
- wait 1s
}
- if <player.is_online.not||true> {
- flag server Casino_Running:<-:<player>
- queue clear
}
## show GUI won
- inventory open d:in@Casino_GUI_Won
- define moneywon <s@Casino_Data.yaml_key[config.keys.<def[key]>.rewards.money.<def[real]>.amount]>
- narrate FORMAT:Util_FF "<&7>Du vandt <&6>$<def[moneywon]>"
- give money quantity:<def[moneywon]>
- playsound <player> sound:LEVEL_UP pitch:1.0
- flag player Casino_Running:!
- flag server Casino_Money:-:<def[moneywon]>
- if <def[size]> == <def[real]> {
- announce FORMAT:Util_FF "<&6><player.name> <&a>vandt jackpot med en <s@Casino_Data.yaml_key[config.keys.<def[key]>.display].parse_color>! <&8>(<&6>$<def[moneywon]><&8>)"
- repeat 4 {
- repeat 5 {
- playsound <server.list_online_players> sound:ORB_PICKUP pitch:<def[value].div[5]>
- wait 2t
}
}
}
- flag player Casino_Menu_Place:!
- flag player Casino_Menu_Items:!
- flag server Casino_Running:<-:<player>
- queue clear
Casino_Real_Chance:
type: procedure
definitions: key
script:
- define random <util.random.int[1].to[10000]>
- define max 0
- foreach <s@Casino_Data.list_keys[config.keys.<def[key]>.rewards.money]> {
- define min <def[max]>
- define max <def[min].add_int[<s@Casino_Data.yaml_key[config.keys.<def[key]>.rewards.money.<def[loop_index]>.chance]>]>
# - narrate "<&e><def[min]> <&a><def[random]> <&e><def[max]>"
- if <def[random]> >= <def[min]> {
- if <def[random]> <= <def[max]> {
# - define moneywon <s@Casino_Data.yaml_key[config.keys.<def[key]>.rewards.money.<def[loop_index]>.amount]>
- determine <def[loop_index]>
}
}
}
Casino_GUI_Proc_C:
type: procedure
script:
- determine "STAINED_GLASS_PANE,<util.random.int[0].to[15]>"
# - define target <server.flag[Teams_Target_Menu]>
Casino_GUI_Proc_Main:
type: procedure
definitions: pos|line|key
script:
- choose "<def[line]>":
- case "1":
- determine <s@Casino_Data.yaml_key[config.keys.<def[key]>.rewards.money.<def[pos]>.material]>
- case "2":
- determine "<&6><&l>$<s@Casino_Data.yaml_key[config.keys.<def[key]>.rewards.money.<def[pos]>.amount]>"
- default:
- determine "Chosen default"
Casino_GUI:
type: inventory
inventory: CHEST
title: <&6>Casino Roller
size: 27
definitions:
T: REDSTONE_TORCH_ON[display_name=<&8>]
C: <proc[Casino_GUI_Proc_C]>[display_name=<&8>]
slots:
- "[C] [C] [C] [C] [T] [C] [C] [C] [C]"
- "[] [] [] [] [] [] [] [] []"
- "[C] [C] [C] [C] [T] [C] [C] [C] [C]"
procedural items:
- define place <player.flag[Casino_Menu_Place].round>
- define items <player.flag[Casino_Menu_Items].as_list.get[<def[place]>].to[<def[place].add_int[8]>]>
- determine <def[items]>
Casino_GUI_Won:
type: inventory
inventory: CHEST
title: <&6>Casino Roller
size: 27
definitions:
T: REDSTONE_TORCH_ON[display_name=<&8>]
C: <proc[Casino_GUI_Proc_C]>[display_name=<&8>]
slots:
- "[C] [C] [C] [C] [T] [C] [C] [C] [C]"
- "[C] [C] [C] [C] [] [C] [C] [C] [C]"
- "[C] [C] [C] [C] [T] [C] [C] [C] [C]"
procedural items:
- define place <player.flag[Casino_Menu_Place].round||0>
- define items <player.flag[Casino_Menu_Items].as_list.get[40]||air>
- determine <def[items]>
Casino_Command:
type: command
name: casino
description: Commands for teams.
usage: /casino
aliases:
- casinorino
permission: casino.admin
permission message: Sorry, <player.name>, you don't have the permission '<permission>'!
script:
- if <context.args.size> >= 1 {
- if <context.args.get[1]> == "status" {
- narrate "<&d>--- <&c>Casino Status <&d>---"
- narrate "<&a>Casino Indtjening<&co> <&6><server.flag[Casino_money]>"
}
else if <context.args.get[1]> == "give" {
- if <s@Casino_Data.list_keys[config.keys].contains[<context.args.get[3]>]> {
- define Target <server.match_offline_player[<context.args.get[2]>]||null>
- if <def[Target]> == null {
- narrate "Ingen spiller fundet!"
- queue clear
}
- run Casino_Key_Giver player:<def[Target]> d:<context.args.get[3]>
}
else {
- narrate "Ingen keys fundet!"
}
}
else if <context.args.get[1]> == "setup" {
- if <s@Casino_Data.list_keys[config.keys].contains[<context.args.get[2]>]> {
- narrate "Højre-klik for at setup kiste for <context.args.get[2]>"
- define flag "Casino_Setup_<context.args.get[2]>"
- flag player "<def[flag]>:True"
}
}
else if <context.args.get[1]> == "giveall" {
- foreach <server.list_online_players> {
- execute as_server "casino give <def[value].name> <context.args.get[2]>"
}
}
else if <context.args.get[1]> == "jackpot" {
- if <context.args.size> >= 3 {
- define Target <server.match_offline_player[<context.args.get[3]>]||null>
- if <def[Target]> == null {
- narrate "Ingen spiller fundet!"
- queue clear
}
- define key <context.args.get[2]>
- define size <s@Casino_Data.list_keys[config.keys.<def[key]>.rewards.money].size>
- define moneywon <s@Casino_Data.yaml_key[config.keys.<def[key]>.rewards.money.<def[size]>.amount]>
- announce FORMAT:Util_FF "<&6><def[Target].name> <&a>vandt jackpot med en <s@Casino_Data.yaml_key[config.keys.<def[key]>.display].parse_color>! <&8>(<&6>$<def[moneywon]><&8>)"
- repeat 4 {
- repeat 5 {
- playsound <server.list_online_players> sound:ORB_PICKUP pitch:<def[value].div[5]>
- wait 2t
}
}
}
}
else {
- narrate "<&b>/casino give (spiller) (key)"
- narrate "<&b>/casino setup (key)"
- narrate "<&b>/casino giveall (key)"
- narrate "<&b>/casino status"
- narrate "<&b>/casino jackpot (key) (spiller)"
- queue clear
}
}
else {
- narrate "<&b>/casino give (spiller) (key)"
- narrate "<&b>/casino setup (key)"
- narrate "<&b>/casino giveall (key)"
- narrate "<&b>/casino status"
- narrate "<&b>/casino jackpot (key) (spiller)"
- queue clear
}
Casino_Key_Giver:
type: task
definitions: key
script:
- give i@TRIPWIRE_HOOK[display_name=<s@Casino_Data.yaml_key[config.keys.<def[key]>.display].parse_color>] quantity:1