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 our 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 Skript if message starts with "!" not working.

Discussion in 'Skript' started by jonawoning, May 24, 2019.

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

    jonawoning Active Member

    Joined:
    May 24, 2019
    Messages:
    26
    Likes Received:
    2
    Title: Skript if message starts with "!" not working. <

    I have skript like:


    Code (Text):
    1. on chat:
    2.     if {kd.%player%} is "Kingdomloos":
    3.         cancel event
    4.         broadcast "&7[&fKingdomloos&7] &7%coloured player's displayname%: &7%message%"
    5.     else:
    6.         set {hash} to "##"
    7.         set {procent} to "@"
    8.         if message starts with "!":
    9.             cancel event
    10.             set {message.%player%} to "%message%"
    11.             replace all "!" with "" in {message.%player%}
    12.             broadcast "&7{&rRoleplay&7} [&f%coloured {kd.prefix.%{kd.%player%}%}%&7] &7[&f%{kd.role.%player%}%&7] &f%coloured player's prefix%&7%coloured player's displayname%: &f%{message.%player%}%"
    13.         else if message starts with "%{hash}%":
    14.             cancel event
    15.             set {message.%player%} to "%message%"
    16.             replace all "%{hash}%" with "" in {message.%player%}
    17.             broadcast "&7{&rP&7} [&f%coloured {kd.prefix.%{kd.%player%}%}%&7] &7[&f%{kd.role.%player%}%&7] &f%coloured player's prefix%&7%coloured player's displayname%: &7%{message.%player%}%"
    18.         else if message starts with "%{procent}%":
    19.             if {kd.role.%player%} is "&6Koning" or "&6Koningin" or "&6Senator" or "&6Keizer" or "&2Hertog" or "&2Hertogin" or "&2Warchief":
    20.                 cancel event
    21.                 set {message.%player%} to "%message%"
    22.                 replace all "%{procent}%" with "" in {message.%player%}
    23.                 loop all players:
    24.                     if {kd.role.%loop-player%} is "&6Koning" or "&6Koningin" or "&6Senator" or "&6Keizer" or "&2Hertog" or "&2Hertogin" or "&2Warchief":
    25.                         send "&7{&cHKM&7} [&f%coloured {kd.prefix.%{kd.%player%}%}%&7] &7[&f%{kd.role.%player%}%&7] &f%coloured player's prefix%&7%coloured player's displayname%: &7%{message.%player%}%" to loop-player
    26.                     else:
    27.                         if loop-player has permission "kd.hkm":
    28.                             send "&7{&cHKM&7} [&f%coloured {kd.prefix.%{kd.%player%}%}%&7] &7[&f%{kd.role.%player%}%&7] &f%coloured player's prefix%&7%coloured player's displayname%: &7%{message.%player%}%" to loop-player
    29.             else:
    30.                 if player has permission "kd.hkm":
    31.                     cancel event
    32.                     set {message.%player%} to "%message%"
    33.                     replace all "%{procent}%" with "" in {message.%player%}
    34.                     loop all players:
    35.                         if {kd.role.%loop-player%} is "&6Koning" or "&6Koningin" or "&6Senator" or "&6Keizer" or "&2Hertog" or "&2Hertogin" or "&2Warchief":
    36.                             send "&7{&cHKM&7} [&f%coloured {kd.prefix.%{kd.%player%}%}%&7] &7[&f%{kd.role.%player%}%&7] &f%coloured player's prefix%&7%coloured player's displayname%: &7%{message.%player%}%" to loop-player
    37.                         else:
    38.                             if loop-player has permission "kd.hkm":
    39.                                 send "&7{&cHKM&7} [&f%coloured {kd.prefix.%{kd.%player%}%}%&7] &7[&f%{kd.role.%player%}%&7] &f%coloured player's prefix%&7%coloured player's displayname%: &7%{message.%player%}%" to loop-player                
    40.                 else:
    41.                     loop all players:
    42.                         if {kd.%loop-player%} is equal to {kd.%player%}:
    43.                             cancel event
    44.                             send "&7[&f%coloured {kd.prefix.%{kd.%player%}%}%&7] &7[&f%{kd.role.%player%}%&7] &f%coloured player's prefix%&7%coloured player's displayname%: &7%message%" to loop-player
    45.         else:
    46.             cancel event
    47.             loop all players:
    48.                 if {kd.%loop-player%} is equal to {kd.%player%}:
    49.                     send "&7[&f%coloured {kd.prefix.%{kd.%player%}%}%&7] &7[&f%{kd.role.%player%}%&7] &f%coloured player's prefix%&7%coloured player's displayname%: &7%message%" to loop-player
    I keep getting an error of ''if message starts with "!":"
    Does someone know how to solve this?

    Thanks!

    (Server version 1.8)
     
    #1 jonawoning, May 24, 2019
    Last edited: May 24, 2019
  2. TPGamesNL

    TPGamesNL Well-Known Member

    Joined:
    Jan 20, 2018
    Messages:
    1,311
    Likes Received:
    73
    Medals:
    Please add your Skript version and insert the code into CODE tags (under the +). Also, send the error
     
    • Agree Agree x 1
  3. jonawoning

    jonawoning Active Member

    Joined:
    May 24, 2019
    Messages:
    26
    Likes Received:
    2
    ''CODE tags (under the +)''
    I cant see an ''+''
     
  4. Blue

    Supporter ++

    Joined:
    Apr 15, 2018
    Messages:
    18
    Likes Received:
    2
    That's some trash code you got there. I suggest rewriting it using lists, uuids, and the chat format expression
     
    • Like Like x 1
  5. jonawoning

    jonawoning Active Member

    Joined:
    May 24, 2019
    Messages:
    26
    Likes Received:
    2
    Yes i know, but do you know an other condition or alternative for ''If message starts with...''?

    Skript version: ''Skript 2.2 Fixes V8b''
    --- Double Post Merged, May 24, 2019, Original Post Date: May 24, 2019 ---
    I will send the error when i am home, right now on school.

    Sorry for my bad English btw, i am Dutch/Netherlands.
     
  6. TPGamesNL

    TPGamesNL Well-Known Member

    Joined:
    Jan 20, 2018
    Messages:
    1,311
    Likes Received:
    73
    Medals:
    Use Skript 2.2-dev36 for 1.8
     
  7. jonawoning

    jonawoning Active Member

    Joined:
    May 24, 2019
    Messages:
    26
    Likes Received:
    2
    Will that work do you think?

    But thanks for the support!
    I will reply later if it has worked out with that version!
    --- Double Post Merged, May 24, 2019, Original Post Date: May 24, 2019 ---
    I've inserted the code btw.
     
  8. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,106
    Likes Received:
    150
    try
    Code (Text):
    1. if first character of message = "!":
     
    • Like Like x 1
    • Informative Informative x 1
    • Useful Useful x 1
  9. jonawoning

    jonawoning Active Member

    Joined:
    May 24, 2019
    Messages:
    26
    Likes Received:
    2
    Thanks! If it don't works i will reply again.
     
  10. TPGamesNL

    TPGamesNL Well-Known Member

    Joined:
    Jan 20, 2018
    Messages:
    1,311
    Likes Received:
    73
    Medals:
    It will work, since that condition was added in dev36. As an alternative (e.g. if dev36 doesn't work) you can use what ShaneBee said. But I do recommend that you use dev36, since it has less bugs and is newer.
     
    • Winner Winner x 1
  11. jonawoning

    jonawoning Active Member

    Joined:
    May 24, 2019
    Messages:
    26
    Likes Received:
    2
    Thanks guys!

    It worked, i simply replaced the % and # by twice.

    Example: ''##''
    Example2: ''%%"

    And updated the version.

    You can close this thread.
     
  12. iCodexx

    iCodexx Member

    Joined:
    May 21, 2019
    Messages:
    3
    Likes Received:
    0
    Voor welke kingdom server maak je dit? Ik zoek een kingdom server ;D
     
    • Funny Funny x 1
  13. jonawoning

    jonawoning Active Member

    Joined:
    May 24, 2019
    Messages:
    26
    Likes Received:
    2
    Ben simpel weg een beetje aan het testen hier en daar.
    Heb al een Java plugin voor Kingdom klaar staan die is gemaakt door een goeie Java Developer.
    Maar vroeg me gewoon af hoe een skript kingdom plugin zou uitwerken.
    En waarvoor dit is? Dit is dus gewoon voor een lolletje.
    Maar ik start uiteindelijk mijn eigen project.
     
  14. TPGamesNL

    TPGamesNL Well-Known Member

    Joined:
    Jan 20, 2018
    Messages:
    1,311
    Likes Received:
    73
    Medals:
    Keep your posts English please.
     
  15. jonawoning

    jonawoning Active Member

    Joined:
    May 24, 2019
    Messages:
    26
    Likes Received:
    2
    Sorry, i didn't mean to.

    He was asking me where i am making this plugin/skript for.
    I will keep it English, thanks.
     
  16. TPGamesNL

    TPGamesNL Well-Known Member

    Joined:
    Jan 20, 2018
    Messages:
    1,311
    Likes Received:
    73
    Medals:
    I know, I'm Dutch too.
     
    • Funny Funny x 1
  17. iCodexx

    iCodexx Member

    Joined:
    May 21, 2019
    Messages:
    3
    Likes Received:
    0
    So you're going to start your own project? Can we talk about this link me your discord or tag
     
  18. jonawoning

    jonawoning Active Member

    Joined:
    May 24, 2019
    Messages:
    26
    Likes Received:
    2
    Yes, but i am starting it in 'secret'.

    Discord: Jona#7797
     
Thread Status:
Not open for further replies.
Loading...