Solved Hashtag/# in chat disguised as command

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

Andreas

Member
Mar 28, 2020
20
0
1
55
Hello. I want to make a hashtag for staff chat so my staff can write in the chat #Good morning! and then it would send a message to all my staff. I just can't make it wanna use # in the chat. Thanks
 
Code:
on chat:
    if first character of the message is "##":
        if player has permission "staff":
            cancel event
            loop all players:
                if loop-player has permission "staff":
                    send "%message%" to loop-player
                    stop


Make sure you don't delete 1 of the hashtags, as the code will not work with only 1 hashtag in line 2
 
When i use it i get this https://gyazo.com/e86660ff1aed7379366a00f4a0953542 in the chat. I'm not placing any extra hashtags or anything
[doublepost=1588183843,1588183769][/doublepost]
Code:
on chat:
    if first character of the message is "##":
        if player has permission "staff":
            cancel event
            loop all players:
                if loop-player has permission "staff":
                    send "%message%" to loop-player
                    stop


Make sure you don't delete 1 of the hashtags, as the code will not work with only 1 hashtag in line 2

I get this when i type #message in the chat. https://gyazo.com/e86660ff1aed7379366a00f4a0953542

Is there any way to remove the first hashtag?
 
Code:
on chat:
    if first character of the message is "##":
        if player has permission "staff":
            cancel event
            loop all players:
                if loop-player has permission "staff":
                    set {_message} to message
                    replace all "##" in {_message} with ""
                    send "%{_message}%" to loop-player
                    stop

reply if that doesn't work, i didn't test it
 
Code:
on chat:
    if first character of the message is "##":
        if player has permission "staff":
            cancel event
            loop all players:
                if loop-player has permission "staff":
                    set {_message} to message
                    replace all "##" in {_message} with ""
                    send "%{_message}%" to loop-player
                    stop

reply if that doesn't work, i didn't test it
That would remove any "#" in the message
Try this code
Code:
on chat:
    if first character of the message is "##":
        if player has permission "staff":
            cancel event
            loop all players:
                if loop-player has permission "staff":
                    set {_m} to subtext of message from characters 2 to the length of message
                    send "%{_m}%" to loop-player
                    stop
[doublepost=1588184835,1588184760][/doublepost]Also you can use this shorter code, i dont remember which version it needs but in 2.4 version it works.
Code:
on chat:
    if first character of the message is "##":
        if player has permission "staff":
            cancel event
            send "%subtext of message from characters 2 to the length of message%" to all players where [player input have permission "staff"]
            stop
 
Status
Not open for further replies.