Solved Issues With Variables

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

Lanchester

New Member
Jan 14, 2018
9
0
0
27
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_language.skript:
    trigger:
        if arg-1 is "on":
            if gamemode of player is not spectator:
                execute player command "/spec"
            if {_vanish.%player%} is not set:
                execute player command "/vanish"
                set {_vanish.%player%} to true
            if {_dynmap.%player%} is not set:
                execute player command "/dynmap hide"
                set {_dynmap.%player%} to true

        if arg-1 is "off":
            if gamemode of player is spectator:
                execute player command "/spec"
            if {_vanish.%player%} is 1:
                execute player command "/vanish"
                delete {_vanish.%player%}
            if {_dynmap.%player%} is 1:
                execute player command "/dynmap show"
                delete {_dynmap.%player%}

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
 
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_language.skript:
    trigger:
        if arg-1 is "on":
            if gamemode of player is not spectator:
                execute player command "/spec"
            if {_vanish.%player%} is not set:
                execute player command "/vanish"
                set {_vanish.%player%} to true
            if {_dynmap.%player%} is not set:
                execute player command "/dynmap hide"
                set {_dynmap.%player%} to true

        if arg-1 is "off":
            if gamemode of player is spectator:
                execute player command "/spec"
            if {_vanish.%player%} is 1:
                execute player command "/vanish"
                delete {_vanish.%player%}
            if {_dynmap.%player%} is 1:
                execute player command "/dynmap show"
                delete {_dynmap.%player%}

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
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%}
 
Status
Not open for further replies.