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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

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

How to make Toggleable commands

Discussion in 'Skript' started by SpawnRusher, Apr 15, 2020.

Thread Status:
Not open for further replies.
  1. SpawnRusher

    Supporter

    Joined:
    Jan 9, 2020
    Messages:
    8
    Likes Received:
    0
    I couldn't find anything like this, probably due to me searching 1 thing, but let's get on with it.

    When I say a "toggleable" command, I mean a command that is used to turn on/off something. Like the command /fly. If you are not in flight mode, you'll be put into flight mode. If you're in flight mode, you will be taken out of flight mode. Here's an easy way to make a toggleable command:
    Code (Text):
    1. command /test:
    2.   trigger:
    3.     if {var} isn't set:
    4.       set {var} to true
    5.       # your code
    6.     else:
    7.       delete {var}
    8.       # your code
    Now you no longer need to have /commandon and /commandoff commands.

    EDIT: Some of you may want to make these player-specific. It's very simple. Take your variable, in this case {var}, and add ::%player's uuid% after the name of the variable.
    {var} --> {var::%player's uuid%}
     
  2. zTak

    zTak Active Member

    Joined:
    Mar 3, 2018
    Messages:
    84
    Likes Received:
    6
    command /toggle:
    trigger:
    if {var.%player%} is set:
    delete {var.%player%}
    else:
    set {var.%player%} to true
     
Thread Status:
Not open for further replies.

Share This Page

Loading...