Solved Help with TimeSpan.

  • 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.
There its a Cooldown Tutorial in your Scripts folder...
code_language.skript:
#
# This script is a template for commands which have a cooldown.
# I will add a more intuitive way of handling cooldowns/countdowns in the future,
# But for now please use something like this.
# Make sure that you do not use delays for cooldowns as they stop when the server stops.
#

# This command allows each player to get infinite cakes
# but the command has a cooldown of one minute (per player)
command /cake:
    description: Recieve a cake, but you can only do this once per minute!
    permission: cake.is_a_lie
    executable by: players
    trigger:
        # stores how long it's been since the player last used this command
        set {_waited} to difference between {cake.%player%.lastused} and now
        # checks whether the player has used the command within the last minute
        if {_waited} is less than a minute:
            message "You have to wait %difference between a minute and {_waited}% before you can use this command again!"
            stop
        
        # some condition which sould not start the cooldown
        # (if the player doesn't get the cake he should be able to use the command again immediately)
        player doesn't have space for a cake:
            message "You do not have enough space in your inventory to hold the cake!"
            stop
            
        # do the action of the command
        give a cake to the player
        
        # and finally start the cooldown
        set {cake.%player%.lastused} to now
 
There its a Cooldown Tutorial in your Scripts folder...
code_language.skript:
#
# This script is a template for commands which have a cooldown.
# I will add a more intuitive way of handling cooldowns/countdowns in the future,
# But for now please use something like this.
# Make sure that you do not use delays for cooldowns as they stop when the server stops.
#

# This command allows each player to get infinite cakes
# but the command has a cooldown of one minute (per player)
command /cake:
    description: Recieve a cake, but you can only do this once per minute!
    permission: cake.is_a_lie
    executable by: players
    trigger:
        # stores how long it's been since the player last used this command
        set {_waited} to difference between {cake.%player%.lastused} and now
        # checks whether the player has used the command within the last minute
        if {_waited} is less than a minute:
            message "You have to wait %difference between a minute and {_waited}% before you can use this command again!"
            stop
       
        # some condition which sould not start the cooldown
        # (if the player doesn't get the cake he should be able to use the command again immediately)
        player doesn't have space for a cake:
            message "You do not have enough space in your inventory to hold the cake!"
            stop
           
        # do the action of the command
        give a cake to the player
       
        # and finally start the cooldown
        set {cake.%player%.lastused} to now
Returns <none>
send "%difference between {kits::%arg-1%::delay} and {kits::%arg-1%::usage::%player%}%"
 
set {kits::%arg-1%::usage::%player%} to now
set {_delay} to arg 3 parsed as timespan
set {kits::%arg-2%::delay} to {_delay}
[doublepost=1516377537,1516377496][/doublepost]Okie, I made like this:
```
set {_waited} to difference between {kits::%arg-1%::usage::%player%} and now
if {_waited} was less than {kits::%arg-1%::delay}:```
And now there is no cooldown
 
code_language.skript:
set {kits::%arg-1%::usage::%player%} to now
set {_delay} to arg 3 parsed as timespan
set {kits::%arg-2%::delay} to {_delay}
Okie, I made like this:
code_language.skript:
set {_waited} to difference between {kits::%arg-1%::usage::%player%} and now
            if {_waited} was less than {kits::%arg-1%::delay}:
And now there is no cooldown
 
Cuz you did "was"

btw here, Tested, Worked.

code_language.skript:
command /kit [<text>] [<text>]:
    trigger:
        set {kits::%arg-1%::usage::%player%} to now
        set {_delay} to arg 2 parsed as timespan
        set {kits::%arg-1%::delay} to {_delay}

command /check [<text>]:
    trigger:
        set {_waited} to difference between {kits::%arg-1%::usage::%player%} and now
        broadcast "%{_waited}%"
        broadcast "%{kits::%arg-1%::delay}%"
        if {_waited} is less than {kits::%arg-1%::delay}:
            send "You have wait!"
            set {_wait} to difference between {Kits::%arg-1%::delay} and {_waited}
            send "%{_wait}%"
upload_2018-1-19_17-7-46.png
 
i already checked. It working fine for me with this code...

Tell me what you did...

btw i did:

/kit test 3 Days

then

/check test
 
Hey, give this try.

code_language.skript:
set  {_waited} to difference between {kits::%arg-1%::usage::%player%} and now
if  {_waited} is less than 30 minutes:
  send "You cannot do this, you have to wait &6%difference between (replace with the amount of time you have to wait before doing it again) (years/days/hours/minutes/seconds) and {_waited}% &ebefore doing this again." to player
  stop
else:
  set {kits::%arg-1%::usage::%player%} to now
  message "You can remove this or change this to what you want"
If this doesn't work I'm not sure what will, you will have to add this to your code too.
 
Kit delay = 3 days
code_language.skript:
            set {_waited} to difference between {kits::%arg-1%::usage::%player%} and now
            if {_waited} is less than {kits::%arg-1%::delay}:
                set {_wait} to difference between {Kits::%arg-1%::delay} and {_waited}
                send "%{_wait}%"
                stop
 
No clue what the problem its.

Doing debugs, then can i/we help you faster.

(Debugs the all varaibles)
 
Maybe your Delay variables wasn't setting to Timespan

This should be fine...

Try to create a new other kits
 
code_language.skript:
function KitDonorMenu(p: player):
        wait 1 tick
        open virtual chest inventory with size 3 named "&b&nKITS &8- &5&nDONOR" to {_p}


command /kit [<text>]:
    trigger:
        if arg 1 is not set:
            open virtual chest inventory with size 3 named "&b&nKITS" to player
            set {_slot} to 0
            loop 46 times:
                make a gui slot {_slot} of player with MAGENTA STAINED GLASS PANE to do nothing
                add 1 to {_slot}
            make a gui slot 15 of player with enchanted book named "&a&nDEFAULT KITS" to do nothing
            if player does not have permission "core.kits.donor":
                make a gui slot 11 of player with RED STAINED GLASS PANE named "&5&nDONOR KITS" with lore "&cLocked.||&5&l* &7Buy ranks at /buy"
            if player have permission "core.kits.donor":
                make a gui slot 11 of player with MAGENTA STAINED GLASS PANE named "&5&nDONOR KITS" to close then run function KitDonorMenu(player)
            wait 2 ticks
            set {_slot} to 0
            while inventory name of player's current inventory = "&b&nKITS":
                set {_slot} to 0
                if slot 1 of player's current inventory is MAGENTA STAINED GLASS PANE:
                    loop 46 times:
                        if inventory name of player's current inventory = "&b&nKITS":
                            make a gui slot 15 of player with enchanted book named "&a&nDEFAULT KITS" to do nothing
                            if player does not have permission "core.kits.donor":
                                make a gui slot 11 of player with RED STAINED GLASS PANE named "&5&nDONOR KITS" with lore "&cLocked.||&5&l* &7Buy ranks at /buy"
                            else if player have permission "core.kits.donor":
                                make a gui slot 11 of player with diamond sword named "&5&nDONOR KITS" to close then run function KitDonorMenu(player)
                            wait 1 ticks
                            make a gui slot {_slot} of player with PURPLE STAINED GLASS PANE to do nothing
                            add 1 to {_slot}
                if slot 1 of player's current inventory is PURPLE STAINED GLASS PANE:
                    set {_slot} to 0
                    loop 46 times:
                        if inventory name of player's current inventory = "&b&nKITS":

                            make a gui slot 15 of player with enchanted book named "&a&nDEFAULT KITS" to do nothing
                            if player does not have permission "core.kits.donor":
                                make a gui slot 11 of player with RED STAINED GLASS PANE named "&5&nDONOR KITS" with lore "&cLocked.||&5&l* &7Buy ranks at /buy"
                            else if player have permission "core.kits.donor":
                                make a gui slot 11 of player with diamond sword named "&5&nDONOR KITS" to close then run function KitDonorMenu(player)
                            wait 3 ticks
                            make a gui slot {_slot} of player with MAGENTA STAINED GLASS PANE to do nothing
                            add 1 to {_slot}
                    wait 1 tick
        if arg 1 is set:
            broadcast "%{kits::%arg-1%::usage::%player%}%"
            broadcast "%{kits::%arg-1%::delay}%"
            set {_waited} to difference between {kits::%arg-1%::usage::%player%} and now
            if {_waited} is less than {kits::%arg-1%::delay}:
                set {_wait} to difference between {Kits::%arg-1%::delay} and {_waited}
                send "%{_wait}%"
                stop
            set {_Car} to uncoloured arg-1
            set {_perm} to convert {_Car} to all lowercase
            if player have permission "core.kits.%{_perm}%":
                if {kits::%arg-1%::set} is true:
                    set {_m} to 0
                    loop {kits::%arg-1%::items::*}:
                        add 1 to {_m}
                    set {_slot} to 0
                    loop {_m} times:
                        if player can hold {_m} of {kits::%arg-1%::items::%{_slot}%}:
                            give player {kits::%arg-1%::items::%{_slot}%}
                        else if player can't hold {_m} of {kits::%arg-1%::items::%{_slot}%}:
                            set {_loc} to location of player
                            set {_loc::y} to y coord of player's location + 1
                            set y-coordinate of {_loc} to {_loc::y}
                            drop {kits::%arg-1%::items::%{_slot}%} at {_loc}
                        add 1 to {_slot}
                    set {kits::%arg-1%::usage::%player%} to now 
command /admin$kits [<text>] [<text>] [<text>]:
    trigger:
        if player don't have permission "core.editkits":
            send "&7Unknown command, type ""/help"" for help!"
            stop
        else:
            if arg 1 is not set:
                send "&8&l&m--+=+---------------------+=+--"
                send ""
                send "&5&l*&7 /admin$kits create <name> <delay>"
                send "&5&l*&7 /admin$kits setDisplayName <name of kit> <display name>"
                send "&5&l*&7 /admin$kits create <name> <delay>"
                send "&5&l*&7 /admin$kits SetDir <name of kit> <category>"
                send "&5&l*&7 /admin$kits SetDelay <name of kit> <delay>"
                send ""
                send "&7^^^^^^^ Delay format is: 4 months, 3 weeks, 1 hour, 1 second"
                send ""
                send "&aThere are few caterogies, DONOR, DEFAULT"
                send "&bMade by The best Siilk"
                send ""
                send "&8&l&m--+=+---------------------+=+--"
            if arg 1 is "create":
                if arg 2 is set:
                    if arg 3 is set:
                        if {kits::%arg-2%::set} is not set:
                            set {kits::%arg-2%::set} to true
                            set {_delay} to arg 3 parsed as timespan
                            set {_slot} to 0
                            set {_n} to 0
                            loop all items in player's inventory:
                                add 1 to {_n}
                            loop {_n} times:
                                set {kits::%arg-2%::items::%{_slot}%} to slot {_slot} of player's inventory
                                add 1 to {_slot}
                            set {kits::%arg-2%::delay} to {_delay}
                            set {kits::%arg-2%::dsplayname} to arg-2
                            send "&8(&a!&8)&7 Kit: &a&n%arg-2%&7 have been created!"
                        else:
                            send "&cThis kit already exists!"
            if arg 1 is "delete":
                if arg 2 is set:
                    if arg 3 is not set:
                        if {kits::%arg-2%::set} is true:
                            set {kits::%arg-2%::set} to false
                            delete {kits::%arg-2%::*}
                            send "&8(&a!&8)&7 Kit: &a&n%arg-2%&7 have been deleted!"
                        else:
                            send "&cThis kit does not exists!"
            if arg 1 is "sdn":
                if arg 2 is set:
                    if arg 3 is set:
                        if {kits::%arg-2%::set} is true:
                            send "&7New name for kit: &a&n%arg-2%&7 is: %coloured arg-3%"
                        else:
                            send "&cThis kit does not exists!"
            if arg 1 is "setdelay":
                if arg 2 is set:
                    if arg 3 is set:
                        if {kits::%arg-2%::set} is true:
                            set {_var} to arg-3 parsed as timespan
                            set {kits::%arg-2%::delay} to {_var}
                            send "&7Cooldown for kit: &a&n%arg-2% &7is now: &a&n%{_var}%"
command /kitgetrid <text>:
    trigger:
        set {kits::%arg-1%::set} to false
 
Status
Not open for further replies.