Solved 1 Player at a time

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

JackyBoy

Member
Feb 4, 2017
104
1
18
21
Hey there! I am making a mystery crate type system and I have got everything working but I am unsure how to make it so that only 1 player can do the command at a time. Is there a way to do this?
 
Could you send us the code, so we can look?

A possibility for example is:
code_language.skript:
variables:
    {lastused::command::%command} = 0

command /YourCommand:
    trigger:
        difference between {lastused::command::%command} and now is more than 30 seconds:
            # do stuff
            
        else:
            send "Command has cooldown. Wait 30 seconds."
 
Yeah sure, this is my code
code_language.skript:
command /crate [<Text>]:
    trigger:
        if arg 1 is "normal":
            send "&a&o&lYou have spawned a &f&o&lNormal Crate!"
            make console execute command "setblock -16 2 -3 redstone_block"
            wait 1 seconds
            make console execute command "setblock -13 2 0 redstone_block"
            wait 10.6 seconds
            make console execute command "setblock -14 2 -1 redstone_block"
            wait 5 seconds
            make console execute command "setblock -17 2 -4 redstone_block"
        if chance of 25%:
            make console execute command "eco give %player% 100"
        else if chance of 25%:
            make console execute command "eco give %player% 200"
        else if chance of 25%:
            make console execute command "eco give %player% 500"
        else:
            stop
 
code_language.skript:
variables:
    {lastused::command::crate} = 0

command /crate [<Text>]:
    trigger:
        if arg 1 is "normal":
            difference between {lastused::command::crate} and now is more than 30 seconds:
                set {lastused::command::crate} to now
                send "&a&o&lYou have spawned a &f&o&lNormal Crate!"
                make console execute command "setblock -16 2 -3 redstone_block"
                wait 1 seconds
                make console execute command "setblock -13 2 0 redstone_block"
                wait 10.6 seconds
                make console execute command "setblock -14 2 -1 redstone_block"
                wait 5 seconds
                make console execute command "setblock -17 2 -4 redstone_block"
                
                chance of 25%:
                    make console execute command "eco give %player% 100"
                chance of 25%:
                    make console execute command "eco give %player% 200"
                chance of 25%:
                    make console execute command "eco give %player% 500"
            else:
                send "Command has cooldown. Try again later."
 
code_language.skript:
difference between {lastused::command::crate} and now is more than 30 seconds:
Change "30 seconds" to every timespan you want.
 
Status
Not open for further replies.