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.

Solved Issues With Variables

Discussion in 'Skript' started by Lanchester, Jan 20, 2018.

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

    Lanchester New Member

    Joined:
    Jan 14, 2018
    Messages:
    9
    Likes Received:
    0
    Skript Version: Skript 2.2 (dev20c)
    Skript Author: Bensku
    Minecraft Version: 1.12.2
    ---
    I'm trying to create a command that when used hides a moderator from other players by using /spec, /vanish, and /dynmap hide, however I have a gui that opens using the command as well that mods will likely be using multiple times before they wish to become visible again, so to avoid them cycling on and off of /vanish and /dynmap each time they use the command, I want to set it so that after the first time they use it it won't repeat those commands any subsequent times, and I figured variables would be the best way to do so:

    Code (Skript):
    1.     trigger:
    2.         if arg-1 is "on":
    3.             if gamemode of player is not spectator:
    4.                 execute player command "/spec"
    5.             if {_vanish.%player%} is not set:
    6.                 execute player command "/vanish"
    7.                 set {_vanish.%player%} to true
    8.             if {_dynmap.%player%} is not set:
    9.                 execute player command "/dynmap hide"
    10.                 set {_dynmap.%player%} to true
    11.  
    12.         if arg-1 is "off":
    13.             if gamemode of player is spectator:
    14.                 execute player command "/spec"
    15.             if {_vanish.%player%} is 1:
    16.                 execute player command "/vanish"
    17.                 delete {_vanish.%player%}
    18.             if {_dynmap.%player%} is 1:
    19.                 execute player command "/dynmap show"
    20.                 delete {_dynmap.%player%}
    21.  
    the spec gamemode line is working fine I'm assuming because I didn't have to set any variables for that, but /vanish and /dynmap hide still activates on every use of the command. I'm guessing I'm not using the variables correctly, but I don't see any errors on the console so I'm not sure what I'm doing wrong
     
  2. Best Answer:
    Post #2 by Donut, Jan 20, 2018
  3. Donut

    Donut Well-Known Member

    Joined:
    Mar 27, 2017
    Messages:
    1,340
    Likes Received:
    176
    Medals:
    get rid of the underscores. that makes it a local variable which only holds its value for that event, command or whatever trigger it is in. Also you should use list variables {vanish::%player%}
     
  4. Lanchester

    Lanchester New Member

    Joined:
    Jan 14, 2018
    Messages:
    9
    Likes Received:
    0
    Donut you're my hero, thank you so much!
     
Thread Status:
Not open for further replies.

Share This Page

Loading...