Date: 2017/07/25 21:32:28 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
top_balance_sign_cmd:
type: command
debug: false
name: topbalancesign
description: Makes a sign display the user with the highest balance (money).
usage: /topbalancesign (set|remove|update|list|help)
aliases:
- tbs
- topbalsign
allowed help:
- determine <player.is_op||<player.has_permission[topbalancesign.use]||<context.server>>>
tab complete:
- if <player.is_op||<player.has_permission[topbalancesign.use]||<context.server>>>
{
- if <context.args.size> == 0
{
- determine <li@set|remove|update|list>
}
else if <context.args.size> == 1 && !<li@set|remove.contains[<context.args.get[1]>]>
{
- determine <li@set|remove|update|list.filter[starts_with[<context.args.get[1]>]]>
}
}
script:
- if <context.server>
{
- narrate '<&c>You must use this command in-game!' 'format:top_balance_sign_format'
- queue clear
}
- if !<player.is_op||<player.has_permission[topbalancesign.use]>>
{
- queue clear
}
- if !<li@wall_sign|sign_post.contains[<player.location.cursor_on[5].material.name>]> && !<li@list|update|help.contains[<context.args.get[1]||null>]>
{
- narrate '<&c>You must be looking at a sign to run this command!' 'format:top_balance_sign_format'
- queue clear
}
- if <context.args.size> > 1 && <li@remove|update|help.contains[<context.args.get[1]||null>]>
{
- narrate '<&c>Too many arguments!' 'format:top_balance_sign_format'
- queue clear
}
else if <context.args.size> > 2 && !<li@remove|update|help.contains[<context.args.get[1]||null>]>
{
- narrate '<&c>Too many arguments!' 'format:top_balance_sign_format'
- queue clear
}
- define loc_display <player.location.cursor_on[5].simple>
- run top_balance_sign_task 'def:true|<context.args.get[1]>|<def[loc_display]>|<context.args.get[2]||null>' 'player:<player>'
top_balance_sign_task:
type: task
debug: false
speed: 0
definitions: rfc|act|loc|page
script:
- choose '<def[act]>':
- case 'remove':
- define loc_retrieve <server.flag[top_balance_sign_locations].as_list.map_get[<def[loc]>]||null>
- if <server.flag[top_balance_sign_locations].as_list.contains[<def[loc]>/<def[loc_retrieve]>]>
{
- flag server 'top_balance_sign_locations:<-:<def[loc]>/<def[loc_retrieve]>'
- if <def[rfc]>
{
- narrate '<&a>Removed TopBalanceSign sign at <def[loc]>!' 'format:top_balance_sign_format'
- sign '|||' <def[loc]>
}
}
- queue clear
- case 'list':
- define disp_list <server.flag[top_balance_sign_locations].as_list.get_sub_items[1]>
- if <server.flag[top_balance_sign_locations].as_list.size||0> == 0
{
- narrate '<&c>There are no TopBalanceSigns!' 'format:top_balance_sign_format'
- queue clear
}
- if <def[page].as_decimal||null> == null
{
- define page 1
}
else if <def[page].mod[1]> != 0 || <def[page]> <= 0
{
- define page 1
}
- define disp_list <def[disp_list].get[<def[page].mul[10].sub[9]>].to[<def[page].mul[10]>]||null>
- if <def[disp_list]> == null
{
- define page 1
- define disp_list <server.flag[top_balance_sign_locations].as_list.get_sub_items[1].get[1].to[10]>
}
- narrate '<&e>== <&6><&l>List of TopBalanceSigns (<def[page]>/<server.flag[top_balance_sign_locations].as_list.get_sub_items[1].size.div[10].round_up>)<&r> <&e>==<&r><&nl>- <def[disp_list].separated_by[<&nl>- ]><&nl><&7>To see more locations, use /topbalancesign list #'
- queue clear
- case 'update':
- if <server.flag[top_balance_sign_locations].as_list.size> == 0
{
- if <def[rfc]>
{
- narrate '<&c>There are no TopBalanceSigns!' 'format:top_balance_sign_format'
}
- queue clear
}
- foreach <server.flag[top_balance_sign_locations].as_list>
{
- define tb_player <server.list_players.sort_by_number[money].reverse.get[<def[value].split[/].get[2]>]>
- sign '<&6><&l>[Top Balance]<&r>|<&e>= #<def[value].split[/].get[2]> <&e>=<&r>|<&a><def[tb_player].name><&r>|<&2>Right click to see balance!<&r>' '<def[value].split[/].get[1]>'
}
- if <def[rfc]>
{
- narrate '<&a>Updated all TopBalanceSigns!' 'format:top_balance_sign_format'
}
- case 'help':
- narrate '<&6><&l>TopBalanceSign Help<&r><&nl><&e>/topbalancesign set #<&7><&co> Sets a sign to display the #th highest balance.<&r><&nl><&e>/topbalancesign remove<&7><&co> Removes a TopBalanceSign.<&r><&nl><&e>/topbalancesign update<&7><&co> Updates all TopBalanceSigns.<&r><&nl><&e>/topbalancesign list #<&7><&co> Lists current TopBalanceSigns.<&r><&nl><&e>/topbalancesign help<&7><&co> Displays this help page.'
- default:
- if <def[page].as_decimal||null> == null
{
- define page 1
}
else if <def[page].mod[1]> != 0 || <def[page]> <= 0
{
- define page 1
}
- if <def[page]> > <server.list_players.size>
{
- narrate '<&c>You can<&sq>t create a TopBalanceSign for a user who doesn<&sq>t exist!' 'format:top_balance_sign_format'
- queue clear
}
- if <server.flag[top_balance_sign_locations].as_list.contains[<def[loc]>/<def[page]>]>
{
- narrate '<&c>This is already a TopBalanceSign for #<def[page]>!' 'format:top_balance_sign_format'
- queue clear
}
- if <server.flag[top_balance_sign_locations].as_list.get_sub_items[1].contains[<def[loc]>]>
{
- define rem_loc '<server.flag[top_balance_sign_locations].as_list.get_sub_items[1].find_all[<def[loc]>]>'
- flag server 'top_balance_sign_locations:<-:<server.flag[top_balance_sign_locations].as_list.get[<def[rem_loc]>]>'
}
- define tb_player <server.list_players.sort_by_number[money].reverse.get[<def[page]>]>
- flag server 'top_balance_sign_locations:->:<def[loc]>/<def[page]>'
- if <def[rfc]>
{
- narrate '<&a>Set a sign at <def[loc]> as a TopBalanceSign!' 'format:top_balance_sign_format'
}
- sign '<&6><&l>[Top Balance]<&r>|<&e>= #<def[page]> <&e>=<&r>|<&a><def[tb_player].name><&r>|<&2>Right click to see balance!<&r>' '<def[loc]>'
- queue clear
top_balance_sign_format:
type: format
debug: false
format: '<&a>[<&2><&l>TopBalanceSigns<&r><&a>]<&r> <text>'
top_balance_sign_events:
type: world
debug: false
events:
on system time minutely:
- repeat 14
{
- run top_balance_sign_task 'def:false|update'
- wait '4s'
}
on player breaks sign_post:
- inject locally 'events.on player breaks wall_sign'
on player breaks wall_sign:
- run top_balance_sign_task 'def:true|remove|<context.location.simple>' 'player:<player>'
on player right clicks sign_post:
- inject locally 'events.on player right clicks wall_sign'
on player right clicks wall_sign:
- if <server.flag[top_balance_sign_locations].as_list.get_sub_items[1].contains[<context.location.simple>]>
{
- define tb_player <context.location.sign_contents.get[3].strip_color>
- narrate '<&f><def[tb_player]> has $<def[tb_player].as_player.money.as_money>.' 'format:top_balance_sign_format'
}