I need a help

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

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

Dani214

Member
Feb 9, 2020
16
1
3
19
I don’t know how to explain this, but I really need help.
I created a command, and I do not know what to do next, I searched a lot where, but I did not find how to complete this.

What I need:

1) There are two modes in this command, "on" and "off", I want to make it so that when it was "on", it was impossible to write "on" again and vice versa.
2) When I switch to "Moderation" mode, that is, I write "on", then the Action Bar would appear with a "timer", as long as I am in this mode, that is, "You are in Moderation mode: 1 minute, 7 seconds", and so that it later writes to the chat when I write "off", that is, "You were in moderation mode 1 minute, 7 seconds."
Code:
command /spectate [<text>]:
    permission: Essentials.gamemode
    permission message: &cNo perms.
    trigger:
        if arg 1 is "on":
            set gamemode of player to spectator
            apply potion of night vision 2 to the player for 1000 days
            apply potion of speed 1 to the player for 1000 days
            hide the player from all players
            message "&aModeration - ON" to player
            send title "" with subtitle "&fModeration - ON." to player for 10 seconds with fadein 1 second and fade out 1 second
        if arg 1 is "off":
            set gamemode of player to survival
            reveal the player from all players
            remove night vision from the player
            remove speed from the player
            message "&aModeration - OFF" to player
            send title "" with subtitle "&fModeration - OFF" to player for 3 seconds with fadein 1 second and fade out 1 second
        if arg 1 is not "off" or "on":
            message "&fUsage - &a/spectate (on/off)"

If you have any thoughts what is wrong with this command, then you can correct them as well.i
 
The timer's a bit more complicated (You'd want to look into while loops), but what you want is something called a list variable.
Basically, when a player goes into moderator mode (/spectate on), you do set {moderation::%uuid of player%} to true. Now, if they try to turn moderation on again, you can check if {moderation::%uuid of player%} is true. If so, they are already in moderation mode, and you can block the command accordingly.

When a player turns moderation off, you can also do the same check, making sure they were in moderation mode.
If they were in moderation mode ({moderation::%uuid of player%} was set to true), disable moderation for them as normal, and then do delete {moderation::%uuid of player%}. This ensures that the player can turn moderation on again.
All in all, your finished script might look like this:
Code:
command /spectate [<text>]:
    permission: Essentials.gamemode
    permission message: &cNo perms.
    trigger:
        if arg 1 is "on":
            if {moderation::%uuid of player%} is true:
                message "&cYou are already in moderation mode!" to player
            else:
                set {moderation::%uuid of player%} to true
                set gamemode of player to spectator
                apply potion of night vision 2 to the player for 1000 days
                apply potion of speed 1 to the player for 1000 days
                hide the player from all players
                message "&aModeration - ON" to player
                send title "" with subtitle "&fModeration - ON." to player for 10 seconds with fadein 1 second and fade out 1 second
        if arg 1 is "off":
            if {moderation::%uuid of player%} is not true:
                message "&cYou are not in moderation mode!" to player
            else:
                delete {moderation::%uuid of player%}
                set gamemode of player to survival
                reveal the player from all players
                remove night vision from the player
                remove speed from the player
                message "&aModeration - OFF" to player
                send title "" with subtitle "&fModeration - OFF" to player for 3 seconds with fadein 1 second and fade out 1 second
        if arg 1 is not "off" or "on":
            message "&fUsage - &a/spectate (on/off)"
 
  • Like
Reactions: Dani214
Status
Not open for further replies.