Solved Message contains "@%player%":

  • 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!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

SWOEN

Member
Apr 26, 2022
12
0
1
Somewhere
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:
on chat:
  if message contains "@%player%":
    replace "@%player%" with "&e@%player%&r" in the message
    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!
 
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?

So I have to do like:


Code:
on chat:
  loop all players:
    if message contains "@%loop-player%":
      replace "@%loop-player%" with "&e@%loop-player%&r" in the message
      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
[doublepost=1651049371,1651047204][/doublepost]It worked!

This is my final code:


Code:
on chat:
  loop all players:
    if message contains "@%loop-player%":
      replace "@%loop-player%" with "&e@%loop-player%&r" in the message

I removed the sound because that was very glitchy.
 
Status
Not open for further replies.