- 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: TopBalanceSigns


By GrandPartyMask
Created: 2017/07/25 21:31:31 UTC-07:00 (4 years and 135 days ago)
Edited: 2019/05/26 06:41:23 UTC-07:00 (2 years and 195 days ago)
Likes: 0

Staff pick as of: 2018/11/06 19:50:57 UTC-08:00 (3 years and 31 days ago)
Denizen Version: Developmental 196
Script Version: 0.1.3
Description:

TopBalanceSigns is a simple script meant to allow server owners to display the people with the largest balance on any set of signs.

COMMANDS:
/topbalancesign help
- Displays the help list of commands.
/topbalancesign set [#]
- Makes a sign a TopBalanceSign, with the optional #th place argument.
/topbalancesign remove
- Removes the TopBalanceSign property from a sign.
/topbalancesign list [#]
- Lists all existing TopBalanceSigns.
/topbalancesign update
- Updates all TopBalanceSigns with current balances. This command is automatically run ever 4 seconds.
/topbalancesign togglenick
- Toggles between nicknames and usernames.
/topbalancesign can be abbreviated to /tbs or /topbalsign.

PERMISSIONS:
topbalancesign.use
- Allows access to the TopBalanceSign commands.

WARNING: This script will not work without Vault and an economy plugin!

UPDATES:
- 26 May 2019: Continued support for this script in general is tenuous. When a GitHub repo is opened, a feature request may be opened to further support for this script.


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
20800

top_balance_sign_cmd:
    type: command
    debug: false
    name: topbalancesign
    description: Makes a sign display the user with the highest balance (money).
    usage: /topbalancesign (help #|set #|remove|update|list|togglenick)
    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>>>
    {
        - define argList li@help|set|remove|update|list|togglenick
        - if <context.args.size> == 0
        {
            - determine <def[argList]>
        }
        else if <context.args.size> == 1 && !<li@set|remove.contains[<context.args.get[1]>]>
        {
            - determine <def[argList].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@help|update|list|togglenick.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@help|update|list|togglenick.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@help|update|list|togglenick.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 'help':
            - narrate '<&6><&l>TopBalanceSign Help<&r><&nl><&e>/topbalancesign help<&7><&co> Displays this help page.<&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 togglenick<&7><&co> Toggles whether to display nicknames or usernames.'
        - 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 'update':
            - if <server.flag[top_balance_sign.locations].as_list.size||0> == 0
            {
                - if <def[rfc]>
                {
                    - narrate '<&c>There are no TopBalanceSigns!' 'format:top_balance_sign_format'
                }
                - queue clear
            }
            - if <server.flag[top_balance_sign.toggle_nick]||false>
            {
                - define name_type name.display
            }
            else
            {
                - define name_type name
            }
            - 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_type%><&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 '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 'togglenick':
            - if <server.flag[top_balance_sign.toggle_nick]||false>
            {
                - flag server 'top_balance_sign.toggle_nick:false'
                - define stat Disabled
            }
            else
            {
                - flag server 'top_balance_sign.toggle_nick:true'
                - define stat Enabled
            }
            - if <def[rfc]>
            {
                - narrate '<&a><def[stat]> nicknames for all TopBalanceSigns.' 'format:top_balance_sign_format'
            }
        - 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]>]>'
            }
            - if <server.flag[top_balance_sign.toggle_nick]||false>
            {
                - define name_type name.display
            }
            else
            {
                - define name_type name
            }
            - 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_type%><&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].as_player.name.display> has $<def[tb_player].as_player.money.as_money>.' 'format:top_balance_sign_format'
        }







View History