Solved Hide players with cd

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

Hartvig

Member
Apr 18, 2017
39
1
0
22
It dosen't give me any errors when i reload the skript

Code:
code_language.skript:
on rightclick holding a gray dye:
    if {reveal.%player%} is 1:
        wait 1 tick
        hide all players from player
        send "&aDu har gjort alle spillere usynlige"
        set slot 1 of player's inventory to shiny light green dye named "&aVis spillere"
        set {reveal.%player%} to now
        set {_waited} to difference between {reveal.%player%} and now
        if {_waited} is less than 5 seconds:
            message "&cDu skal vente %difference between 60 seconds and {_waited}% sekunder."
            stop
        set {reveal.%player%} to 2

on rightclick holding a light green dye:
    if {reveal.%player%} is 2:
        wait 1 tick
        reveal all players to player
        send "&aDu har gjort alle spillere synlige"
        set slot 1 of player's inventory to shiny gray dye named "&cGem spillere"
        set {reveal.%player%} to now
        set {_waited} to difference between {reveal.%player%} and now
        if {_waited} is less than 5 seconds:
            message "&cDu skal vente %difference between 60 seconds and {_waited}% sekunder."
            stop
        set {reveal.%player%} to 1
        stop

on join:
    set {reveal.%player%} to 0
 
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
 
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?
 
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?
a friend told me that is how you make a cooldown, im new to cooldowns
[doublepost=1499809158,1499809104][/doublepost]
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
oops i forgot, but now it stops work at https://gyazo.com/458d7dc890949595b5272996201a4935
 
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_language.skript:
set {_waited} to difference between {lastUsed::%player%} and now
if {_waited} is less than 5 seconds:
    send "stop"
    stop
set {lastUsed::%player%} to now
set {reveal.%player%} to 2

If that doesn't work, you might need to add this as well to initialize the variable to start.
code_language.skript:
on join:
    set {lastUsed::%player%} to now
 
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_language.skript:
set {_waited} to difference between {lastUsed::%player%} and now
if {_waited} is less than 5 seconds:
    send "stop"
    stop
set {lastUsed::%player%} to now
set {reveal.%player%} to 2

If that doesn't work, you might need to add this as well to initialize the variable to start.
code_language.skript:
on join:
    set {lastUsed::%player%} to now
Dosen't work
[doublepost=1499862352,1499862255][/doublepost]If i rightclick it will hide players and send stop, and after that it's stop working
[doublepost=1499890185][/doublepost]So i made a new version, it works fine the first time, but it stop working after that.

CODE:


code_language.skript:
on rightclick holding a gray dye:
    if {reveal.%player%} is 1:
        wait 1 tick
        hide all players from player
        send "&aDu har gjort alle spillere usynlige"
        set slot 1 of player's inventory to shiny light green dye named "&aVis spillere"
        set {lastUsed.%player%} to 1
    if {lastUsed.%player%} is 1:
        send "&cWait"
        stop
 
on rightclick holding a light green dye:
    if {reveal.%player%} is 2:
        wait 1 tick
        reveal all players to player
        send "&aDu har gjort alle spillere synlige"
        set slot 1 of player's inventory to shiny gray dye named "&cGem spillere"
        set {lastUsed.%player%} to 2
    if {lastUsed.%player%} is 2:
        send "&cWait"
        stop
 

on join:
    set {reveal.%player%} to 1

every second:
    loop all players:
        if {lastUsed.%loop-player%} is 1:
            wait 4 seconds
            clear {lastUsed.%loop-player%}
            set {reveal.%loop-player%} to 2
            stop
        if {lastUsed.%loop-player%} is 2:
            wait 4 seconds
            clear {lastUsed.%loop-player%}
            set {reveal.%loop-player%} to 1
            stop
 
@Hartvig

code_language.skript:
function hideToggle(p: player , status: boolean):
    if {_status} is true:
        hide all players from {_p}
        message "&aDu har gjort alle spillere usynlige" to {_p}
        set slot 1 of {_p}'s inventory to shiny light green dye named "&aVis spillere"
    if {_status} is false:
        reveal all players from {_p}
        message "&aDu har gjort alle spillere synlige" to {_p}
        set slot 1 of {_p}'s inventory to shiny gray dye named "&cGem spillere"
       
on rightclick holding a gray dye:
    set {_waited} to difference between {hidetoggle::%player%} and now
    if {_waited} is less than 5 seconds:
        message "&cYou need to wait %difference between {_waited} and 5 seconds% to perform this action."
        stop
    else:
        set {hidetoggle::%player%} to now
        hideToggle( player , true)

on rightclick holding a light green dye:
    set {_waited} to difference between {hidetoggle::%player%} and now
    if {_waited} is less than 5 seconds:
        message "&cYou need to wait %difference between {_waited} and 5 seconds% to perform this action."
        stop
    else:
        set {hidetoggle::%player%} to now
        hideToggle( player , false)
 
@Hartvig

code_language.skript:
function hideToggle(p: player , status: boolean):
    if {_status} is true:
        hide all players from {_p}
        message "&aDu har gjort alle spillere usynlige" to {_p}
        set slot 1 of {_p}'s inventory to shiny light green dye named "&aVis spillere"
    if {_status} is false:
        reveal all players from {_p}
        message "&aDu har gjort alle spillere synlige" to {_p}
        set slot 1 of {_p}'s inventory to shiny gray dye named "&cGem spillere"
      
on rightclick holding a gray dye:
    set {_waited} to difference between {hidetoggle::%player%} and now
    if {_waited} is less than 5 seconds:
        message "&cYou need to wait %difference between {_waited} and 5 seconds% to perform this action."
        stop
    else:
        set {hidetoggle::%player%} to now
        hideToggle( player , true)

on rightclick holding a light green dye:
    set {_waited} to difference between {hidetoggle::%player%} and now
    if {_waited} is less than 5 seconds:
        message "&cYou need to wait %difference between {_waited} and 5 seconds% to perform this action."
        stop
    else:
        set {hidetoggle::%player%} to now
        hideToggle( player , false)
Thank you so much!!
 
Status
Not open for further replies.