Solved Detect username from a chat message

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

Deleted member 21021

Skript Version (do not put latest): Skript 2.6.1
Skript Author: Bensku
Minecraft Version: 1.17.1
--
Hello everyone! I need some help with this Skript as I'm stuck and cannot figure out what to do.

Description:
When someone right-clicks a glow ink sac named "Glow Dust", the game asks you to type in the username of your target to make them glow for 300 seconds (5 minutes). As of now, this Skript ONLY works when you type in the FULL username in chat, but I also want my Skript to detect the username properly when someone decides to type it in partially.

I have not been able to find a solution to my Skript problem on the forums, as well as in the documentation and other resources. I do not have any errors in console as the Skript already works fine, but I want to add this feature onto it.

Help would be much appreciated! :emoji_grin:

An example of how I want my Skript to work:
A player has gotten this glow ink sac named "Glow Dust" and they want to make TimmieTRM glow for 5 minutes. They decide to type "Timmie" into the chat. The Skript then looks for anyone with "Timmie" in their username and decide to make them glow, but if there are multiple players with "Timmie" in their username, the game asks them to be more specific in which "Timmie" they want to choose.

Full Code:
(For Context: "Glow Dust" is a rare artifact you are able to get out of a Treasure Chest, which has a 1% of dropping when digging specific blocks. This code runs the functionality of this artifact.)

Code:
on right click with glow ink sac:
    if name of player's tool contains "&cGlow Dust":
        set {treasurechest.%player%.choosing} to true
        message "&cType in chat the username of your target to make them glow.."
  
on chat:
    if {treasurechest.%player%.choosing} = true:
        loop all players:
            if message contains "%loop-player%":
                cancel event
                apply potion of glowing potion of tier 1 to loop-player for 300 seconds
                message "&cYou successfully made %loop-player% glow.."
                set {treasurechest.%player%.choosing} to false
    remove 1 of player's tool from player's tool

Here is how to give the item to yourself incase you're testing this yourself:
(The artifact drops at your location in-game.)

Code:
command /test:
    trigger:
        drop glow ink sac named "&cGlow Dust" with lore "&7Reveal someones location", "&7to everyone in the world" and "&6&lArtifact"
 
Last edited by a moderator:
Skript Version (do not put latest): Skript 2.6.1
Skript Author: Bensku
Minecraft Version: 1.17.1
--
Hello everyone! I need some help with this Skript as I'm stuck and cannot figure out what to do.

Description:
When someone right-clicks a glow ink sac named "Glow Dust", the game asks you to type in the username of your target to make them glow for 300 seconds (5 minutes). As of now, this Skript ONLY works when you type in the FULL username in chat, but I also want my Skript to detect the username properly when someone decides to type it in partially.

I have not been able to find a solution to my Skript problem on the forums, as well as in the documentation and other resources. I do not have any errors in console as the Skript already works fine, but I want to add this feature onto it.

Help would be much appreciated! :emoji_grin:

An example of how I want my Skript to work:
A player has gotten this glow ink sac named "Glow Dust" and they want to make TimmieTRM glow for 5 minutes. They decide to type "Timmie" into the chat. The Skript then looks for anyone with "Timmie" in their username and decide to make them glow, but if there are multiple players with "Timmie" in their username, the game asks them to be more specific in which "Timmie" they want to choose.

Full Code:
(For Context: "Glow Dust" is a rare artifact you are able to get out of a Treasure Chest, which has a 1% of dropping when digging specific blocks. This code runs the functionality of this artifact.)

Code:
on right click with glow ink sac:
    if name of player's tool contains "&cGlow Dust":
        set {treasurechest.%player%.choosing} to true
        message "&cType in chat the username of your target to make them glow.."
 
on chat:
    if {treasurechest.%player%.choosing} = true:
        loop all players:
            if message contains "%loop-player%":
                cancel event
                apply potion of glowing potion of tier 1 to loop-player for 300 seconds
                message "&cYou successfully made %loop-player% glow.."
                set {treasurechest.%player%.choosing} to false
    remove 1 of player's tool from player's tool

Here is how to give the item to yourself incase you're testing this yourself:
(The artifact drops at your location in-game.)

Code:
command /test:
    trigger:
        drop glow ink sac named "&cGlow Dust" with lore "&7Reveal someones location", "&7to everyone in the world" and "&6&lArtifact"
I think that only works for command using tab completions from skbee add on https://skripthub.net/docs/
 
I think that only works for command using tab completions from skbee add on https://skripthub.net/docs/

Thank you for the reply, this is indeed a solution! Luckily I managed to find the issue on my own though.

In the on chat: part of the code, I had to change the following line from this:
Code:
if message contains "%loop-player%":

to this:
Code:
if "%loop-player%" contains message:

I had to switch loop-player and message around for it to work like it's supposed to do.
 
  • Like
Reactions: Mich
Status
Not open for further replies.