Word detection

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

aescraft

Well-Known Member
Mar 1, 2017
295
13
0
36
Instead of "message contains", add a "message contains word", to detect only a word.

Example of why this is important:

code_language.skript:
on chat:
  if message contains word "rape":
    # 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_language.skript:
on chat:
  if message contains "rape":
     if message contains "cameraperson" or "drape" or "grape" or "raper" or "parapet" or "skyscraper" or "therapeutic" or "trapeze":
        stop
      #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.
 
code_language.skript:
on chat:
  if message contains " rape " or " rape" or "rape ":
    # ban the player
  else if message is "rape":
    # ban the player

Maybe this one works better

code_language.skript:
on chat:
    set {_msg} to "%message%"
    if "%{_msg}%" is "rape":
        #Ban the player
        message "&4Rape detected"
        cancel event
        stop
    set {_message::*} to {_msg} split at " "
    loop {_message::*}:
        if "%loop-value%" is "rape":
            #Ban the player
            message "&4Rape detected"
            cancel event
            stop