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 Message contains "@%player%":

Discussion in 'Skript' started by SWOEN, Apr 26, 2022.

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

    SWOEN Member

    Joined:
    Apr 26, 2022
    Messages:
    10
    Likes Received:
    0
    Hello there!

    I have a problem with my skript that mentions player's when they use @ before a player name.
    This is my code:

    Code (Text):
    1. on chat:
    2.   if message contains "@%player%":
    3.     replace "@%player%" with "&[email protected]%player%&r" in the message
    4.     execute console command "/playsound minecraft:entity.player.levelup player %player% 100 49 0 500 1"

    When I do @SWOEN (my in-game name) it works fine.
    But when I do any other name, for example @Steve, nothing happens.

    Does anyone know why this happens?

    Thanks!
     
  2. Best Answer:
    Post #2 by Minecoll_YT, Apr 26, 2022
  3. Minecoll_YT

    Supporter Forums Helper

    Joined:
    Dec 2, 2018
    Messages:
    650
    Likes Received:
    39
    Yeah... Because you are the %player%. You have to loop all players and then compare. And why are you using a mc command to play sounds?
     
    • Like Like x 1
    • Useful Useful x 1
  4. SWOEN

    SWOEN Member

    Joined:
    Apr 26, 2022
    Messages:
    10
    Likes Received:
    0
    So I have to do like:


    Code (Text):
    1. on chat:
    2.   loop all players:
    3.     if message contains "@%loop-player%":
    4.       replace "@%loop-player%" with "&[email protected]%loop-player%&r" in the message
    5.       execute console command "/playsound minecraft:entity.player.levelup player %loop-player% 100 49 0 500 1"
    I used the sound for if you get notified.
    Like when I do @Steve, it will get yellow and steve gets a sound notification
    --- Double Post Merged, Apr 27, 2022, Original Post Date: Apr 27, 2022 ---
    It worked!

    This is my final code:


    Code (Text):
    1. on chat:
    2.   loop all players:
    3.     if message contains "@%loop-player%":
    4.       replace "@%loop-player%" with "&[email protected]%loop-player%&r" in the message
    5.  
    I removed the sound because that was very glitchy.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...