Paste #47710: Vote Mute

Date: 2018/06/06 06:18:20 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


VoteMute:
  type: command
  name: VoteMute
  description: "Start a poll to mute a player if a Staff Member isn't online!"
  usage: "/votemute <player> <reason>"
  script:
  - if <server.list_online_players.filter[has_permission[essentials.mute]].size> !== 0 {
    - inject locally path:Deny
    }
    else {
    - inject locally path:Allow
    }
  Deny:
    - narrate "<&6>[<&e>SC<&6>] <&c>You cannot use that command if a staff member is online!"
  Allow:
    - flag server ongoing:1
    - define mp <server.match_player[<c.args.get[1]||null>]||false> 
    - if <context.args.get[1]||null> == null { 
      - narrate "<&c>You must specify a player." 
      - queue clear 
      } 
    - if <def[mp].is[==].to[false]> { 
        - narrate "<&e><context.args.get[1]> <&c>is not a valid player." 
        - queue clear 
        } 
    - if <context.args.get[2]||null> == null { 
      - narrate "<&c>You must specify a reason." 
      - queue clear 
      }
    - announce "<&a>A Vote Poll has been opened!"
    - ^announce "<&a>For player: <&d><context.args.get[1]>"
    - ^announce "<&a>Reason: <&d><context.args.exclude[<context.args.get[1]>]"
    - ^announce ""
    - ^announce "<&a>Vote yes with <&d>/voteyes"
    - ^announce "<&a>Vote no with <&d>/voteno"
    - ^announce "<&7>The poll will end in ten minutes if enough players don't vote!"
    - wait 10m
    - if <player.flag[mute].round> >= 3 {
      - announce "<&a>The Vote Pull has ended!"
      - announce "<&d><c.args.get[1]> <&a>has been muted!"
      - flag server ongoing:!
      }
      else if !<player.has_flag[muted> || <player.flag[muted].round> < 3 {
      - announce "<&a>The vote poll has ended!"
      - announce "<&d><c.args.get[1]> <&a>has not been muted!"
      - flag server ongoing:!
      }

votes_handler:
  type: world
  debug: false
  events:
    on voteyes command:
    - if !<server.has_flag[ongoing]> {
      - narrate "<&6>[<&e>SC<&6>] <&c>No pool is ongoing now! Use /votemute to start a poll if a staff member is not online!"
      - queue clear
      }
    - if <<def[mp]>.flag[mute].round> < 3 {
      - flag <def[mp]> mute:+:1
      - narrate "<&6>[<&e>SC<&6>] <&c>You've successfilly voted!"
      - announce "<&a><player.name> has voted!"
      - announce "<&a><<def[mp]>.flag[mute].round><&f>/<&a>3 votes!"
      }
    on voteno command:
    - flag <def[mp]> mute:-:1
    on system time minutely:
    - if <server.has_flag[ongoing]> {
      - if <<def[mp]>.flag[mute].round> == 3 {
        - flag server ongoing:!
        - flag <def[mp]> mute:!
        - flag <def[mp]> muted:1 d:30m
        - announce "<&6>[<&e>SC<&6>] <&a>The poll has ended!"
        - announce "<&6>[<&e>SC<&6>] <&d><def[mp]> <&a>has been muted!"
        }
      }
    - if <server.has_flag[ongoing] {
      - if <<def[mp]>.flag[mute].round> == -3 {
        - flag server ongoing:!
        - flag <def[mp]> mute:!
        - announce "<&6>[<&e>SC<&6>] <&a>The poll has ended!"
        - announce "<&6>[<&e>SC<&6>] <&d><def[mp]> <&a>is will not be muted!"
        }
      }
    on player chats:
    - if <player.has_flag[muted]> {
      - narrate "<&6>[<&e>SC<&6>] <&c>You cannot talk because you are currently muted!"
      - determine cancelled
    }