1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Stop certain players from receiving chat.

Discussion in 'Skript' started by sandor_1234, Jul 21, 2017.

Thread Status:
Not open for further replies.
  1. sandor_1234

    sandor_1234 Active Member

    Joined:
    Jan 26, 2017
    Messages:
    165
    Likes Received:
    5
    I am searching for a way to stop certain players from receiving the chat.
    Is there a thing in skript to do this:
    https://bukkit.org/threads/disabling-chat-for-a-player.81999/

    I know i could do it with something like this:
    Code (Skript):
    1. on chat:
    2.     cancel event
    3.     loop all players:
    4.         if {chat::%loop-player%} is "On":
    5.             send "%message%" to loop-player
    But by doing it that way a lot off plugins will stop working and the chat messages don't get logged to the console anymore.
     
  2. Best Answer:
    Post #2 by ShaneBee, Jul 21, 2017
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    225
    So, at the moment, your code does this:

    Code (Skript):
    1.  
    2. on chat:
    3.     cancel chat message
    4.     loop all online players:
    5.         if online player has chat enabled:
    6.             send message to player
    7.  
    What if I told you we reverse the logic, while still having the same effect?

    Code (Skript):
    1.  
    2. on chat:
    3.     loop all players:
    4.         if looped player has chat disabled:
    5.             nullify the message
    6.  
    Now, the above was all sudo-code meant to be used to explain things more effectively; here's the above code in Skript-syntax:

    Code (Skript):
    1. on chat:
    2.     loop all players:
    3.         if {chat::%loop-player%} is "Off":
    4.             remove loop-player from chat recipients
    You can also use this, which is the same thing, but is a lot more compact:
    Code (Skript):
    1. on chat:
    2.     loop all players where [{chat::%player input%} is "Off"]:
    3.         remove loop-player from chat recipients
    Note: the chat recipients expression is from RandomSK, but it was merged into Skellett
    the chat recipients expression is vanilla Skript :emoji_thumbsup:
     
    #2 ShaneBee, Jul 21, 2017
    Last edited by a moderator: Jul 22, 2017
    • Useful Useful x 2
    • Informative Informative x 1
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    225
    Code (Skript):
    1. set chat recipients to all players where [{chat::%player input%} is "On"]
    and chat recipients is vanilla
     
Thread Status:
Not open for further replies.

Share This Page

Loading...