How to detect a word?

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

    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.

aescraft

Well-Known Member
Mar 1, 2017
295
13
0
I've looked up in the docs but is really hard to find.

I'm using

code_language.skript:
if message contains "":

To get the content of the message. But, for example, I want to detect "gg", if I use "message contains gg", words like egg, eggplant, exaggerating, etc.

How to detect if its ONLY "gg"?

Thanks!
 
I've looked up in the docs but is really hard to find.

I'm using

code_language.skript:
if message contains "":

To get the content of the message. But, for example, I want to detect "gg", if I use "message contains gg", words like egg, eggplant, exaggerating, etc.

How to detect if its ONLY "gg"?

Thanks!
Code:
if message is "gg"
 
A single word, or a letter?
Word: Hello!
Letter: H
Single word.
Example:

if message contains "play":

Player message 1: I play minecraft
Player message 2: I'm a minecraft player

The first message works as intended, but the second one is also triggered. I don't want to trigger it when part of the word is detected, only if it's all the word.

How to make only the first message be detected, not the second one?
 
Single word.
Example:

if message contains "play":

Player message 1: I play minecraft
Player message 2: I'm a minecraft player

The first message works as intended, but the second one is also triggered. I don't want to trigger it when part of the word is detected, only if it's all the word.

How to make only the first message be detected, not the second one?
Try
code_language.skript:
on chat:
    if message contains "play":
        if message is "play":
            cancel event
            message "Hey!"
It works for me, as I just tested it just now.
 
You can split the message by a space, loop it, see if the looped text is gg and do your stuff.
 
You can split the message by a space, loop it, see if the looped text is gg and do your stuff.
I was just going to say, yes.
code_language.skript:
on chat:
    if message contains " play ":
        send "nu swearing"
 
I was just going to say, yes.
code_language.skript:
on chat:
    if message contains " play ":
        send "nu swearing"
This does not help much.
What about hen the massage is: "Do you play?"
or the response "play what?"
Both messages have "play" but won't be triggered by the lack of space, in the first one, instead of a space, there's a "?", and the second one, it lacks the first space before the word.
 
This does not help much.
What about hen the massage is: "Do you play?"
or the response "play what?"
Both messages have "play" but won't be triggered by the lack of space, in the first one, instead of a space, there's a "?", and the second one, it lacks the first space before the word.
The just put all possibilities:

code_language.skript:
on chat:
    if message contains "play " or " play " or " play":
        send "nu swearing"
 
The just put all possibilities:

code_language.skript:
on chat:
    if message contains "play " or " play " or " play":
        send "nu swearing"
I know I can do this, but as I said, "play " (the first option in your code) would also trigger another words like:

fairplay
overplay
display, etc.

I know how to use the "IF", I was looking for another way to detect words instead manually doing it.

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.
 
I know I can do this, but as I said, "play " (the first option in your code) would also trigger another words like:

fairplay
overplay
display, etc.

I know how to use the "IF", I was looking for another way to detect words instead manually doing it.

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.
Not the second player. Honestly, it is hard to do this type of thing in script with every possibility... :/
 
I know I can do this, but as I said, "play " (the first option in your code) would also trigger another words like:

fairplay
overplay
display, etc.

I know how to use the "IF", I was looking for another way to detect words instead manually doing it.

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.

just put spaces (?) like " kys "
 
Status
Not open for further replies.