Determine if text contains RGB color codes

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

amoosing

Member
Aug 4, 2022
1
0
1
55
Hi all,
I'm trying to determine if text provided as an argument to a command contains RGB color codes - in a relatively simple way and probably not super reliable, but all I really want to do is check if the text contains the &# characters in that order and if so remove the & characters from the text. I keep getting errors saying either my variable is not a location (it should be text..) or Invalid use of quotes. I've tried a bunch of different ways to test for this and I can't get any to work. This is one example of what I've tried:


Code:
command /customrank <text>:
    executable by: players
    permission: rainbow.customrank
    permission message: &cSorry! You don't have access to that command!
    cooldown: 5 days
    cooldown message: You last set your custom rank %elapsed time% ago, you need to wait %remaining time% before setting it again.
    trigger:
        set {newrank} to arg-1
        set {amp} to "&#"
        if "%{newrank}%" contains "%{amp}%":
            replace all "&" in {newrank} with ""
        make console execute command "/lp user %player% meta removeprefix 200"
        make console execute command "/lp user %player% meta addprefix 200 &7[%{newrank}%&7]"

This code gives me this error:
Invalid use of quotes ("). If you want to use quotes in "quoted text", double them: "".

Please help :emoji_slight_smile:
[doublepost=1659728788,1659644670][/doublepost]Just FYI in case anyone comes across this, i sorted it out - I was sure I tried this but apparently not - i changed this line:

Code:
set {amp} to "&#"

to this:

Code:
set {amp} to "&##"

and it's all good; don't know why I couldn't find any mention of that in the documentation, though I can't find a lot of things in it so maybe I'm just dumb haha.
 
Status
Not open for further replies.