Paste #5058: Chat controller

Date: 2014/06/03 16:49:30 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


Normal Chat:
    type: world
    events:
        on player chats:
        - if <player.flag[talkingallowed]> {
          - ^narrate "<&7>You say, "<context.message><&7>"."
          - ^flag player lastchat:<context.message>
          - ^run localchatdisplayer
          }
          else {
            - if <player.flag[chatblockedreason]> != null {
              - ^narrate "<&7><player.flag[chatblockedreason]>"
              }
        - determine cancelled

'localchatdisplayer':
    type: task
    script:
        - flag player "hearsyourmessage:false"
        - foreach <server.list_players> {
          - if <player.location.distance[<%value%.location>].horizontal> < 5000 {
            - narrate '<player.flag[currentrank]> <&7><player.name> <&7>is heard in the distance saying, "<context.message>".' t:<%value%>
            - flag player "hearsyourmessage:true"
            }
            else <player.location.distance[<%value%.location>].horizontal> < 3000 {
              - narrate '<player.flag[currentrank]> <&7><player.name> <&7>yells, "<context.message>".' t:<%value%>
              - flag player "hearsyourmessage:true"
              }
            else <player.location.distance[<%value%.location>].horizontal> < 1000 {
              - narrate '<player.flag[currentrank]> <&7><player.name> <&7>says, "<context.message>".' t:<%value%>
              - flag player "hearsyourmessage:true"
              }
            else <player.location.distance[<%value%.location>].horizontal> < 20 {
              - narrate '<player.flag[currentrank]> <&7><player.name> <&7>whispers, "<context.message>".' t:<%value%>
              - flag player "hearsyourmessage:true"
              }
          }
          - if <player.flag[hearsyourmessage]> == false narrate "<&7>No one hears you."