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!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Word detection

Discussion in 'Addon Suggestions' started by aescraft, Apr 17, 2017.

  1. aescraft

    aescraft Well-Known Member

    Joined:
    Mar 1, 2017
    Messages:
    295
    Likes Received:
    13
    Instead of "message contains", add a "message contains word", to detect only a word.

    Example of why this is important:

    Code (Skript):
    1. on chat:
    2.   if message contains word "rape":
    3.     # ban the player
    This would detect if the message contains THE WORD rape, not if the message contains "rape" on it.

    Right now, as skript works, I would have to do this to ban the word rape instead of banning all messages that contains "rape" on it:

    Code (Skript):
    1. on chat:
    2.   if message contains "rape":
    3.      if message contains "cameraperson" or "drape" or "grape" or "raper" or "parapet" or "skyscraper" or "therapeutic" or "trapeze":
    4.         stop
    5.       #ban the player
    In the "rape" example, I would have to add another indent and another "if" with a stop command on the words I don't want to get triggered by the skript.
     
    • Agree Agree x 1
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Code (Skript):
    1. on chat:
    2.   if message contains " rape " or " rape" or "rape ":
    3.     # ban the player
    4.   else if message is "rape":
    5.     # ban the player
    6.  
    Maybe this one works better

    Code (Skript):
    1.  
    2. on chat:
    3.     set {_msg} to "%message%"
    4.     if "%{_msg}%" is "rape":
    5.         #Ban the player
    6.         message "&4Rape detected"
    7.         cancel event
    8.         stop
    9.     set {_message::*} to {_msg} split at " "
    10.     loop {_message::*}:
    11.         if "%loop-value%" is "rape":
    12.             #Ban the player
    13.             message "&4Rape detected"
    14.             cancel event
    15.             stop
    16.  
     
    • Useful Useful x 1
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Or use regex
    Code (Skript):
    1. on chat:
    2.     if message matches ".*\brape\b.*":
    3.         #stuff
     
    • Agree Agree x 1
    • Informative Informative x 1
    • Useful Useful x 1
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Regex always better
     
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    What is regex? ".*\b" ?
     
  6. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    It detects a bunch of phrases in one and makes sure it catches it. It is also more efficient and used widely in Skript anti advertisements.
     
    • Funny Funny x 1
  7. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    • Informative Informative x 1
  8. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    what have i just read then.
     

Share This Page

Loading...