Paste #52936: Chat Pings!

Date: 2019/03/01 07:55:46 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


# +--------------------
# |
# | C h a t   P i n g s
# |
# | Alerts when somebody says your name!
# |
# +----------------------
#
# @author mcmonkey
# @date 2019/03/01
# @denizen-build DEV-670
# @script-version 2.0
#
# Installation:
# Just put the script in your scripts folder and reload.
#
# Usage:
# Just say someone's name, everything is automatic.
#
# ---------------------------- END HEADER ----------------------------

chat_pings_world:
    type: world
    debug: false
    events:
        on player chats:
        # Pure-tag pre-check to avoid unneeded processing
        - if <context.message.contains_any[<server.list_online_players.parse[name]>]>:
            - foreach <server.list_online_players> as:player:
                # You might prefer: contains[regex:\b<def[player].name>\b]
                # As that will test "word borders" (ie, don't match if the name is in the middle of a word)
                - if <context.message.contains[<def[player].name>]>:
                    - narrate targets:<def[player]> "<&6><player.name><&b> mentioned you!"
                    - playsound <def[player]> sound:block_note_block_bell
                    - toast targets:<def[player]> "<&6><player.name><&b> mentioned you!" frame:goal