- 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.





Doorbell


By BloodEko
Created: 2017/07/24 11:36:16 UTC-07:00 (7 years and 153 days ago)
Edited: 2017/08/01 11:36:14 UTC-07:00 (7 years and 145 days ago)
Likes: 1

Denizen Version: build 189 (1.10)
Script Version: 1.2
Description:

Sounds are optimized for 1.10.
Now with bungeecord support!
This project is also on GitHub https://github.com/BloodEko/Doorbell



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
16200

#----------------------------------------------+
#Created 24.07.17 - 31.07.17                   |
#doorbell by BloodEko                          |
#                                              |
#Easy way to add a doorbell                    |
#                                              |
#Permission: doorbell.use                      |
#            Access to the /doorbell command   |
#                                              |
#----------------------------------------------+
# Usage: /doorbell                             |
#        /doorbell help                        |
#----------------------------------------------+
#Use /doorbell set while looking at a button   |
#to assign your doorbell.                      |
#Breaking or /doorbell disable, delete it again|
#When players click the doorbell, owner gets   |
#notified.                                     |
#----------------------------------------------+

shelp_reposcripts:
  type: version
  author: BloodEko
  name: doorbell
  usage: /doorbell syntax
  version: 1.2
  id: 132
  linkhttp://old.mcmonkey.org/denizen/repo/entry/132

#--------------------------------------------+

doorbell_bungee:
  type: yaml data
  # true or false
  # requires a proper bungeecord setup
  # how to setup: https://github.com/DenizenScript/Depenizen
  #
  bungee: false
  
doorbell_cmdhandler:
  type: command
  name: doorbell
  usage: /doorbell help|set|disable|off|on|info
  description: Sets and disables doorbells.
  permission: doorbell.use
  permission message: You don't have permission to use this command.
  script:
  # 
  # /doorbell 
  #
  - choose <context.args.get[1]>:
    - case help:
      - narrate "/doorbell help<&nl><&7>- Displays this help page."
      - narrate "/doorbell set<&nl><&7>- Converts a placed button to a doorbell."
      - narrate "/doorbell disable<&nl><&7>- Removes your doorbell."
      - narrate "/doorbell info<&nl><&7>- Displays information about a placed doorbell or your own doorbell."
      - narrate "/doorbell off<&nl><&7>- Disables your doorbell for 12h."
      - narrate "/doorbell on<&nl><&7>- Activates your doorbell again."
    - case set:
      - if <li@stone_button|wood_button.contains[<pl.location.cursor_on.material>]> && <server.has_flag[doorbell.<player.location.cursor_on>]> { 
        - narrate "<&4>This button is already a doorbell!"
        } else if !<server.has_flag[doorbell.<player>]> {
        - narrate "<&2>Created a new doorbell!"
        - flag server doorbell.<player.location.cursor_on>:<player>
        - flag server doorbell.<player>:<player.location.cursor_on>
        }
        else {
        - narrate "<&4>You already have a doorbell!"
        }
    - case info:
      - if <server.has_flag[doorbell.<player.location.cursor_on>]> {
        - narrate "<&2>This doorbell is owned by <&6><server.flag[doorbell.<player.location.cursor_on>].as_player.name>"
        }
        else if <server.has_flag[doorbell.<player>]> {
        - narrate "<&2>Your doorbell is located at <&6><server.flag[doorbell.<player>].as_location.simple>"
        }
        else {
        - narrate "<&2>You have no doorbell."
        }
    - case disable:
      - if <server.has_flag[doorbell.<player>]> {
        - narrate "<&2>Disabled your doorbell."
        - define location "<server.flag[doorbell.<player>]>"
        - flag server doorbell.<player>:!
        - flag server doorbell.<def[location]>:!
        }
        else {
        - narrate "<&2>You have no doorbell."
        }
    - case off:
      - narrate "<&2>Disabled your doorbell. (12h)"
      - define location "<server.flag[doorbell.<player>]>"
      - flag server doorbell.disabled.<def[location]> duration:d@12h
    - case on:
      - define location "<server.flag[doorbell.<player>]>"
      - if <server.has_flag[doorbell.disabled.<def[location]>]> {
        - narrate "<&2>Activated your dorbell again."
        - flag server doorbell.disabled.<def[location]>:!
        } else {
        - narrate "<&9>Your doorbell is already on."
        }
    - default:
      - narrate "<&4>/doorbell help|set|disable|off|on|info"

doorbell_handler:
  type: world
  events:
    on player breaks wood_button:
    - inject locally doorbell_break
    on player breaks stone_button:
    - inject locally doorbell_break
    on player right clicks wood_button:
    - inject locally doorbell_event_<s@doorbell_bungee.yaml_key[bungee]||off>
    on player right clicks stone_button:
    - inject locally doorbell_event_<s@doorbell_bungee.yaml_key[bungee]||off>
  doorbell_event_false:
  - if !<server.has_flag[doorbell.<context.location>]> queue clear
  - if <server.has_flag[doorbell.cooldown.<context.location>]> queue clear
  - if <server.has_flag[doorbell.disabled.<context.location>]> {
    - narrate "Seems like this doorbell isn't activated at the moment."
    - queue clear
    }
  - flag server doorbell.cooldown.<context.location> duration:d@4s
  - if <server.flag[doorbell.<context.location>].as_player.is_online> {
    - narrate "Ring ring ..." targets:<player.location.find.entities[player].within[10]>
    - playsound <player.location> sound:BLOCK_NOTE_PLING
    - playsound <server.flag[doorbell.<context.location>]> sound:BLOCK_NOTE_PLING
    - narrate "<&6><&l>Somebody has used your doorbell!" targets:<server.flag[doorbell.<context.location>]>
    }
    else {
    - narrate "Seems like nobody is there."
    }
  doorbell_event_true:
  - if !<server.has_flag[doorbell.<context.location>]> queue clear
  - if <server.has_flag[doorbell.cooldown.<context.location>]> queue clear
  - if <server.has_flag[doorbell.disabled.<context.location>]> {
    - narrate "Seems like this doorbell isn't activated at the moment."
    - queue clear
    }
  - flag server doorbell.cooldown.<context.location> duration:d@4s
  - narrate "Ring ring ..." targets:<player.location.find.entities[player].within[10]>
  - playsound <context.location> sound:BLOCK_NOTE_PLING
  - define player <server.flag[doorbell.<context.location>]>
  - define back_to_player <player>
  - define back_to <bungee.server>
  - bungee <bungee.list_servers> {
    - if <def[player].as_player.is_online> {
      - playsound <def[player]> sound:BLOCK_NOTE_PLING
      - narrate "<&6><&l>Somebody has used your doorbell!" targets:<def[player]>
      - bungee <def[back_to]> {
        - narrate "He must have heared it for sure!" targets:<def[back_to_player]>
        }
      }
    }
  doorbell_break:
  - if !<server.has_flag[doorbell.<context.location>]> queue clear
  - define user <server.flag[doorbell.<context.location>]>
  - narrate "<&2>Disabled the doorbell from <&6><def[user].as_player.name>"
  - flag server doorbell.<def[user]>:!
  - flag server doorbell.<context.location>:!






View History