Paste #43227: Edit of P#43173 Dorbell

Date: 2017/07/30 10:08:43 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


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

shelp_reposcripts:
  type: version
  author: BloodEko
  name: Dorbell
  usage: /dorbell syntax
  version: 0.6
  id: 132
  link: http://old.mcmonkey.org/denizen/repo/entry/132

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

dorbell_cmdhandler:
  type: command
  name: dorbell
  usage: /dorbell  set|disable|info
  description:
  permission: dorbell.use
  permission message: You don't have the permission for using this command.
  script:
  #
  # /dorbell
  #
  - if <context.args.size> == 1 {
    #
    # set
    #
    - if <context.args.get[1]> == set {
      - if <li@stone_button|wood_button.contains[<pl.location.cursor_on.material>]> 
        && <server.has_flag[dorbell.<player.location.cursor_on.simple>]> {
        - narrate "<&4>There is already a dorbell!"
        } else if !<server.has_flag[dorbell.<player>]> {
        - narrate "<&2>Created a new dorbell!"
        - flag server dorbell.<player.location.cursor_on.simple>:<player>
        - flag server dorbell.<player>:<player.location.cursor_on.simple>
        }
        else {
        - narrate "<&4>You already have a dorbell!"
        }
      }
      #
      # info
      #
      else if <context.args.get[1]> == info {
      - if <server.has_flag[dorbell.<player.location.cursor_on.simple>]> {
        - narrate "<&2>This dorbell is owned by <&6><server.flag[dorbell.<player.location.cursor_on.simple>].as_player.name>"
        }
        else if <server.has_flag[dorbell.<player>]> {
        - narrate "<&2>Your dorbell is located at <&6><server.flag[dorbell.<player>]>"
        }
        else {
        - narrate "<&2>You have no dorbell."
        }
      }
      #
      # disable
      #
      else if <context.args.get[1]> == disable {
      - if <server.has_flag[dorbell.<player>]> {
        - narrate "<&2>Disabled your dorbell."
        - define location "<server.flag[dorbell.<player>]>"
        - flag server dorbell.<player>:!
        - flag server dorbell.<def[location]>:!
        }
        else {
        - narrate "<&2>You have no dorbell."
        }
      }
      else {
      - inject locally dorbell_false_syntax
      }
    }
    else {
    - inject locally dorbell_false_syntax
    }
  dorbell_false_syntax:
  - narrate "<&4>/dorbell  set|disable|info"

dorbell_handler:
  type: world
  events:
    on player breaks wood_button:
    - inject locally dorbell_break
    on player breaks stone_button:
    - inject locally dorbell_break
    on player right clicks wood_button:
    - inject locally dorbell_event
    on player right clicks stone_button:
    - inject locally dorbell_event
  dorbell_event:
  - if !<server.has_flag[dorbell.<context.location.simple>]> queue clear
  - if <server.has_flag[dorbell.cooldown.<context.location.simple>]> queue clear
  - flag server dorbell.cooldown.<context.location.simple> duration:d@4s
  - if <server.flag[dorbell.<context.location.simple>].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[dorbell.<context.location.simple>]> sound:BLOCK_NOTE_PLING
    - narrate "<&l><&6>Somebody has used your dorbell!" targets:<server.flag[dorbell.<context.location.simple>]>
    }
    else {
    - narrate "Seems like nobody is there."
    }
  dorbell_break:
  - if !<server.has_flag[dorbell.<context.location.simple>]> queue clear
  - define user <server.flag[dorbell.<context.location.simple>]>
  - narrate "<&2>Disabled the dorbell from <&6><def[user].as_player.name>"
  - flag server dorbell.<def[user]>:!
  - flag server dorbell.<context.location.simple>:!