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


By Talamar1
Created: 2015/10/27 03:57:47 UTC-07:00 (8 years and 177 days ago)
Edited: 2019/05/26 06:13:09 UTC-07:00 (4 years and 329 days ago)
Likes: 0

Staff pick as of: 2015/11/08 01:36:09 UTC-08:00 (8 years and 165 days ago)
Denizen Version:
Script Version: 1.0
Description:




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
16000


# dBroadcasting system
# Allows for colorized broadcasts
# Users require op or dbroadcast.command permission
# Broadcasts are stored in dBroadcasts_saves.yml and is 
# Editable and reloadable.
# Created by Talamar1

Broadcast:
  type: world
  debug: false
  events:
    on server start:
    - if <server.has_file[dbroadcast_saves.yml]> { 
      - announce "<red><&lb>dBroadcast<&rb> <green>Loading Broadcast Config File"
      - yaml load:dbroadcast_saves.yml id:dbroadcast_saves
      }
      else { 
      - announce "<red><&lb>dBroadcast<&rb> <green>Creating Broadcast Config File"
      - yaml create id:dbroadcast_saves
      - yaml savefile:dbroadcast_saves.yml id:dbroadcast_saves
      } 
    - run InitdBroadcast delay:10t

    on dbc command:
    - determine passively fulfilled
    - if !<context.server> && !<player.has_permission[dbroadcast.command]> {
      - narrate "<&6>You do not have permission to use the dbroadcast command."
      - queue clear
      }
    - if <el@val[add].is[==].to[<context.args.get[1]>]> {
      - inject dbroadcast_command_add
      }
      else if <context.args.get[1].matches[^(rem|remove|del|delete)$]> {
      - inject dbroadcast_command_remove
      }
      else if <el@val[list].is[==].to[<context.args.get[1]>]>  {
      - inject dbroadcast_command_list
      }
      else if <el@val[reload].is[==].to[<context.args.get[1]>]>  {
      - inject dbroadcast_command_reload
      }
      else {
      - narrate "<&6>/dBc add <&lt>timer<&gt> <&lt>message<&gt>"
      - narrate "<&6>/dBc remove <&lt>dbid<&gt>"
      - narrate "<&6>/dBc list"
      - narrate "<&6>/dBc reload"
      }
InitdBroadcast:
  type: task
  debug: false
  script:
    - while true {
      - define broadcasts <yaml[dbroadcast_saves].list_keys[bclist]||li@>
      - if <def[broadcasts].size> > 0 {
        - foreach %broadcasts% {
          - if <util.date.time.minute.mod[<yaml[dbroadcast_saves].read[bclist.%value%.timer]>].is[==].to[0]> {
            - announce "<yaml[dbroadcast_saves].read[bclist.%value%.message]>"
            }
          }
        }
      - wait 1m
      }

dbroadcast_command_add:
  type: task
  debug: false
  script:
    - if <context.args.get[3].is[==].to[null]||true> {
      - narrate "<&6>/dBc add <&lt>timer<&gt> <&lt>message<&gt>"
      - narrate "<&6>Timer - Amount of time between rebroadcasts"
      - narrate "<&6>Message - message you want broadcasts"
      - queue clear
      }
    - if <context.args.get[2].as_int.is[LESS].than[5]||true> {
      - narrate "<gold>dBroadcast Invalid time argument"
      - narrate "<gold>Value must be greater than 5"
      - queue clear
      }
    - define dBtimer <context.args.get[2].as_int>
    - define dBmsg <context.args.get[3].to[<context.args.size>].as_string>
    - define dBmsg <def[dBmsg].replace[&0].with[<&0>]>
    - define dBmsg <def[dBmsg].replace[&1].with[<&1>]>
    - define dBmsg <def[dBmsg].replace[&2].with[<&2>]>
    - define dBmsg <def[dBmsg].replace[&3].with[<&3>]>
    - define dBmsg <def[dBmsg].replace[&4].with[<&4>]>
    - define dBmsg <def[dBmsg].replace[&5].with[<&5>]>
    - define dBmsg <def[dBmsg].replace[&6].with[<&6>]>
    - define dBmsg <def[dBmsg].replace[&7].with[<&7>]>
    - define dBmsg <def[dBmsg].replace[&8].with[<&8>]>
    - define dBmsg <def[dBmsg].replace[&9].with[<&9>]>
    - define dBmsg <def[dBmsg].replace[&a].with[<&a>]>
    - define dBmsg <def[dBmsg].replace[&b].with[<&b>]>
    - define dBmsg <def[dBmsg].replace[&c].with[<&c>]>
    - define dBmsg <def[dBmsg].replace[&d].with[<&d>]>
    - define dBmsg <def[dBmsg].replace[&e].with[<&e>]>
    - define dBmsg <def[dBmsg].replace[&f].with[<&f>]>
    - define dBmsg <def[dBmsg].replace[&k].with[<&k>]>
    - define dBmsg <def[dBmsg].replace[&l].with[<&l>]>
    - define dBmsg <def[dBmsg].replace[&m].with[<&m>]>
    - define dBmsg <def[dBmsg].replace[&n].with[<&n>]>
    - define dBmsg <def[dBmsg].replace[&o].with[<&o>]>
    - define dBmsg <def[dBmsg].replace[&r].with[<&r>]>
    - narrate "Timer %dBtimer%"
    - narrate "Message %dBmsg%"
    - define bcount <yaml[dbroadcast_saves].list_keys[bclist].size||0>
    - yaml set bclist.<def[bcount].add[1].as_int>.timer:%dBtimer% id:dbroadcast_saves
    - yaml set bclist.<def[bcount].add[1].as_int>.message:%dBmsg% id:dbroadcast_saves
    - yaml savefile:dbroadcast_saves.yml id:dbroadcast_saves

dbroadcast_command_list:
  type: task
  debug: false
  script:
    - if <yaml[dbroadcast_saves].list_keys[bclist].size.is[more].than[0]||null> == true {
      - foreach <yaml[dbroadcast_saves].list_keys[bclist]> {
        - narrate "Key<&co> %value% <&co> <yaml[dbroadcast_saves].read[bclist.%value%.timer]> <&co> <yaml[dbroadcast_saves].read[bclist.%value%.message]> "
      }
    }

dbroadcast_command_reload:
  type: task
  debug: false
  script:
    - if <server.has_file[dbroadcast_saves.yml]> { 
      - narrate "<red><&lb>dBroadcast<&rb> <green>Loading Broadcast Config File"
      - yaml load:dbroadcast_saves.yml id:dbroadcast_saves
      }
      else { 
      - narrate "<red><&lb>dBroadcast<&rb> <green>Creating Broadcast Config File"
      - yaml create id:dbroadcast_saves
      - yaml savefile:dbroadcast_saves.yml id:dbroadcast_saves
      } 

dbroadcast_command_remove:
  type: task
  debug: true
  script:
    - define bcid <context.args.get[2].as_int>
    - if <def[bcid].is[LESS].than[1]||false> || <yaml[dbroadcast_saves].contains[bclist.%bcid%].not> {
      - narrate "<gold>dBroadcast Invalid broadcast id number"
      - narrate "<gold>Check IDs with /bc list"
      - queue clear
      }
    - yaml set bclist.%bcid%:! id:dbroadcast_saves
    - yaml create id:temp_broadcast
    - if <yaml[dbroadcast_saves].list_keys[bclist].size||0> != 1 {
      - yaml savefile:dbroadcast_saves.yml id:dbroadcast_saves
      }
      else {
      - foreach <yaml[dbroadcast_saves].list_keys[bclist]> {
        - yaml set bclist.%loop_index%.timer:<yaml[dbroadcast_saves].read[bclist.%value%.timer]> id:temp_broadcast
        - yaml set bclist.%loop_index%.message:<yaml[dbroadcast_saves].read[bclist.%value%.message]> id:temp_broadcast
        }
      - yaml savefile:dbroadcast_saves.yml id:temp_broadcast
      - yaml unload id:temp_broadcast
      }
    - inject dbroadcast_command_reload






View History