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 Hide players with cd

Discussion in 'Skript' started by Hartvig, Jul 11, 2017.

Tags:
Thread Status:
Not open for further replies.
  1. Hartvig

    Hartvig Member

    Joined:
    Apr 18, 2017
    Messages:
    39
    Likes Received:
    1
    It dosen't give me any errors when i reload the skript

    Code:
    Code (Skript):
    1.  
    2. on rightclick holding a gray dye:
    3.     if {reveal.%player%} is 1:
    4.         wait 1 tick
    5.         hide all players from player
    6.         send "&aDu har gjort alle spillere usynlige"
    7.         set slot 1 of player's inventory to shiny light green dye named "&aVis spillere"
    8.         set {reveal.%player%} to now
    9.         set {_waited} to difference between {reveal.%player%} and now
    10.         if {_waited} is less than 5 seconds:
    11.             message "&cDu skal vente %difference between 60 seconds and {_waited}% sekunder."
    12.             stop
    13.         set {reveal.%player%} to 2
    14.  
    15. on rightclick holding a light green dye:
    16.     if {reveal.%player%} is 2:
    17.         wait 1 tick
    18.         reveal all players to player
    19.         send "&aDu har gjort alle spillere synlige"
    20.         set slot 1 of player's inventory to shiny gray dye named "&cGem spillere"
    21.         set {reveal.%player%} to now
    22.         set {_waited} to difference between {reveal.%player%} and now
    23.         if {_waited} is less than 5 seconds:
    24.             message "&cDu skal vente %difference between 60 seconds and {_waited}% sekunder."
    25.             stop
    26.         set {reveal.%player%} to 1
    27.         stop
    28.  
    29. on join:
    30.     set {reveal.%player%} to 0
    31.  
     
  2. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    What's not working about it? We need some info
    Where does it stop working?
     
  3. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    it's not working it all, not saying or doing anything when i rightclick on a gray or lime dye.
     
  4. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    well then im guessing {reveal.%player%} isnt set to 1 or 2. maybe you meant to set it to 1 on join? right now you're setting it to 0
     
  5. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    From looking at a glance,
    The first time it's used {reveal.%player%} will not be set to 1 or 2. I'm assuming it wouldn't be set yet and therefore, the if statement is failing and nothing is happening.
    There is a problem with that if statement at the start of each of the events.


    Following on from this, what's going on here
    <code>
    set {reveal.%player%} to now
    set {_waited} to difference between {reveal.%player%} and now
    if {_waited} is less than 5 seconds:
    </code>
    You're setting it to now, and one line later checking difference between now and now?
     
  6. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    a friend told me that is how you make a cooldown, im new to cooldowns
    --- Double Post Merged, Jul 11, 2017, Original Post Date: Jul 11, 2017 ---
    oops i forgot, but now it stops work at https://gyazo.com/458d7dc890949595b5272996201a4935
     
  7. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    Try something like this you need to introduce a new variable somewhere in there. Your entire skript is using 1 variable and it's overriding itself.
    Code (Skript):
    1.  
    2. set {_waited} to difference between {lastUsed::%player%} and now
    3. if {_waited} is less than 5 seconds:
    4.     send "stop"
    5.     stop
    6. set {lastUsed::%player%} to now
    7. set {reveal.%player%} to 2
    8.  
    If that doesn't work, you might need to add this as well to initialize the variable to start.
    Code (Skript):
    1.  
    2. on join:
    3.     set {lastUsed::%player%} to now
    4.  
     
  8. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    Dosen't work
    --- Double Post Merged, Jul 12, 2017, Original Post Date: Jul 12, 2017 ---
    If i rightclick it will hide players and send stop, and after that it's stop working
    --- Double Post Merged, Jul 12, 2017 ---
    So i made a new version, it works fine the first time, but it stop working after that.

    CODE:


    Code (Skript):
    1. on rightclick holding a gray dye:
    2.     if {reveal.%player%} is 1:
    3.         wait 1 tick
    4.         hide all players from player
    5.         send "&aDu har gjort alle spillere usynlige"
    6.         set slot 1 of player's inventory to shiny light green dye named "&aVis spillere"
    7.         set {lastUsed.%player%} to 1
    8.     if {lastUsed.%player%} is 1:
    9.         send "&cWait"
    10.         stop
    11.  
    12. on rightclick holding a light green dye:
    13.     if {reveal.%player%} is 2:
    14.         wait 1 tick
    15.         reveal all players to player
    16.         send "&aDu har gjort alle spillere synlige"
    17.         set slot 1 of player's inventory to shiny gray dye named "&cGem spillere"
    18.         set {lastUsed.%player%} to 2
    19.     if {lastUsed.%player%} is 2:
    20.         send "&cWait"
    21.         stop
    22.  
    23.  
    24. on join:
    25.     set {reveal.%player%} to 1
    26.  
    27. every second:
    28.     loop all players:
    29.         if {lastUsed.%loop-player%} is 1:
    30.             wait 4 seconds
    31.             clear {lastUsed.%loop-player%}
    32.             set {reveal.%loop-player%} to 2
    33.             stop
    34.         if {lastUsed.%loop-player%} is 2:
    35.             wait 4 seconds
    36.             clear {lastUsed.%loop-player%}
    37.             set {reveal.%loop-player%} to 1
    38.             stop
     
  9. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    @Hartvig

    Code (Skript):
    1. function hideToggle(p: player , status: boolean):
    2.     if {_status} is true:
    3.         hide all players from {_p}
    4.         message "&aDu har gjort alle spillere usynlige" to {_p}
    5.         set slot 1 of {_p}'s inventory to shiny light green dye named "&aVis spillere"
    6.     if {_status} is false:
    7.         reveal all players from {_p}
    8.         message "&aDu har gjort alle spillere synlige" to {_p}
    9.         set slot 1 of {_p}'s inventory to shiny gray dye named "&cGem spillere"
    10.        
    11. on rightclick holding a gray dye:
    12.     set {_waited} to difference between {hidetoggle::%player%} and now
    13.     if {_waited} is less than 5 seconds:
    14.         message "&cYou need to wait %difference between {_waited} and 5 seconds% to perform this action."
    15.         stop
    16.     else:
    17.         set {hidetoggle::%player%} to now
    18.         hideToggle( player , true)
    19.  
    20. on rightclick holding a light green dye:
    21.     set {_waited} to difference between {hidetoggle::%player%} and now
    22.     if {_waited} is less than 5 seconds:
    23.         message "&cYou need to wait %difference between {_waited} and 5 seconds% to perform this action."
    24.         stop
    25.     else:
    26.         set {hidetoggle::%player%} to now
    27.         hideToggle( player , false)
     
  10. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    Thank you so much!!
     
Thread Status:
Not open for further replies.

Share This Page

Loading...