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 Help with TimeSpan.

Discussion in 'Skript' started by Zoya, Jan 19, 2018.

Thread Status:
Not open for further replies.
  1. Zoya

    Zoya Member

    Joined:
    Jun 5, 2017
    Messages:
    10
    Likes Received:
    0
  2. ChisleLP

    ChisleLP Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    789
    Likes Received:
    60
    There its a Cooldown Tutorial in your Scripts folder...
    Code (Skript):
    1. #
    2. # This script is a template for commands which have a cooldown.
    3. # I will add a more intuitive way of handling cooldowns/countdowns in the future,
    4. # But for now please use something like this.
    5. # Make sure that you do not use delays for cooldowns as they stop when the server stops.
    6. #
    7.  
    8. # This command allows each player to get infinite cakes
    9. # but the command has a cooldown of one minute (per player)
    10. command /cake:
    11.     description: Recieve a cake, but you can only do this once per minute!
    12.     permission: cake.is_a_lie
    13.     executable by: players
    14.     trigger:
    15.         # stores how long it's been since the player last used this command
    16.         set {_waited} to difference between {cake.%player%.lastused} and now
    17.         # checks whether the player has used the command within the last minute
    18.         if {_waited} is less than a minute:
    19.             message "You have to wait %difference between a minute and {_waited}% before you can use this command again!"
    20.             stop
    21.        
    22.         # some condition which sould not start the cooldown
    23.         # (if the player doesn't get the cake he should be able to use the command again immediately)
    24.         player doesn't have space for a cake:
    25.             message "You do not have enough space in your inventory to hold the cake!"
    26.             stop
    27.            
    28.         # do the action of the command
    29.         give a cake to the player
    30.        
    31.         # and finally start the cooldown
    32.         set {cake.%player%.lastused} to now
     
  3. Zoya

    Zoya Member

    Joined:
    Jun 5, 2017
    Messages:
    10
    Likes Received:
    0
    Returns <none>
    send "%difference between {kits::%arg-1%::delay} and {kits::%arg-1%::usage::%player%}%"
     
  4. ChisleLP

    ChisleLP Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    789
    Likes Received:
    60
    Its delay parsed as timespan? (im not sure if timespan right or not)
     
  5. Zoya

    Zoya Member

    Joined:
    Jun 5, 2017
    Messages:
    10
    Likes Received:
    0
    set {kits::%arg-1%::usage::%player%} to now
    set {_delay} to arg 3 parsed as timespan
    set {kits::%arg-2%::delay} to {_delay}
    --- Double Post Merged, Jan 19, 2018, Original Post Date: Jan 19, 2018 ---
    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
     
  6. ChisleLP

    ChisleLP Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    789
    Likes Received:
    60
    My eyes burning... There its a Code tags. Just click the "+" and then click on code.
     
  7. Zoya

    Zoya Member

    Joined:
    Jun 5, 2017
    Messages:
    10
    Likes Received:
    0
    Code (Skript):
    1. set {kits::%arg-1%::usage::%player%} to now
    2. set {_delay} to arg 3 parsed as timespan
    3. set {kits::%arg-2%::delay} to {_delay}
    Okie, I made like this:
    Code (Skript):
    1. set {_waited} to difference between {kits::%arg-1%::usage::%player%} and now
    2.             if {_waited} was less than {kits::%arg-1%::delay}:
    And now there is no cooldown
     
  8. ChisleLP

    ChisleLP Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    789
    Likes Received:
    60
    Cuz you did "was"

    btw here, Tested, Worked.

    Code (Skript):
    1. command /kit [<text>] [<text>]:
    2.     trigger:
    3.         set {kits::%arg-1%::usage::%player%} to now
    4.         set {_delay} to arg 2 parsed as timespan
    5.         set {kits::%arg-1%::delay} to {_delay}
    6.  
    7. command /check [<text>]:
    8.     trigger:
    9.         set {_waited} to difference between {kits::%arg-1%::usage::%player%} and now
    10.         broadcast "%{_waited}%"
    11.         broadcast "%{kits::%arg-1%::delay}%"
    12.         if {_waited} is less than {kits::%arg-1%::delay}:
    13.             send "You have wait!"
    14.             set {_wait} to difference between {Kits::%arg-1%::delay} and {_waited}
    15.             send "%{_wait}%"
    upload_2018-1-19_17-7-46.png
     
  9. Zoya

    Zoya Member

    Joined:
    Jun 5, 2017
    Messages:
    10
    Likes Received:
    0
    Now I get <none>
     
  10. ChisleLP

    ChisleLP Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    789
    Likes Received:
    60
    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
     
  11. Harvey

    Harvey Member

    Joined:
    Jan 16, 2018
    Messages:
    18
    Likes Received:
    0
    Hey, give this try.

    Code (Skript):
    1. set  {_waited} to difference between {kits::%arg-1%::usage::%player%} and now
    2. if  {_waited} is less than 30 minutes:
    3.   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
    4.   stop
    5. else:
    6.   set {kits::%arg-1%::usage::%player%} to now
    7.   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.
     
  12. Zoya

    Zoya Member

    Joined:
    Jun 5, 2017
    Messages:
    10
    Likes Received:
    0
    Kit delay = 3 days
    Code (Skript):
    1.             set {_waited} to difference between {kits::%arg-1%::usage::%player%} and now
    2.             if {_waited} is less than {kits::%arg-1%::delay}:
    3.                 set {_wait} to difference between {Kits::%arg-1%::delay} and {_waited}
    4.                 send "%{_wait}%"
    5.                 stop
     
  13. ChisleLP

    ChisleLP Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    789
    Likes Received:
    60
    No clue what the problem its.

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

    (Debugs the all varaibles)
     
  14. Zoya

    Zoya Member

    Joined:
    Jun 5, 2017
    Messages:
    10
    Likes Received:
    0
    Code (Skript):
    1.             broadcast "%{kits::%arg-1%::usage::%player%}%"
    2.             broadcast "%{kits::%arg-1%::delay}%"
    https://imgur.com/gallery/s9Jlz
     
  15. ChisleLP

    ChisleLP Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    789
    Likes Received:
    60
    Maybe your Delay variables wasn't setting to Timespan

    This should be fine...

    Try to create a new other kits
     
  16. Zoya

    Zoya Member

    Joined:
    Jun 5, 2017
    Messages:
    10
    Likes Received:
    0
    Same
     

    Attached Files:

  17. ChisleLP

    ChisleLP Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    789
    Likes Received:
    60
    could you give me the whole skript?`._.
     
  18. Zoya

    Zoya Member

    Joined:
    Jun 5, 2017
    Messages:
    10
    Likes Received:
    0
    Code (Skript):
    1.  
    2. function KitDonorMenu(p: player):
    3.         wait 1 tick
    4.         open virtual chest inventory with size 3 named "&b&nKITS &8- &5&nDONOR" to {_p}
    5.  
    6.  
    7. command /kit [<text>]:
    8.     trigger:
    9.         if arg 1 is not set:
    10.             open virtual chest inventory with size 3 named "&b&nKITS" to player
    11.             set {_slot} to 0
    12.             loop 46 times:
    13.                 make a gui slot {_slot} of player with MAGENTA STAINED GLASS PANE to do nothing
    14.                 add 1 to {_slot}
    15.             make a gui slot 15 of player with enchanted book named "&a&nDEFAULT KITS" to do nothing
    16.             if player does not have permission "core.kits.donor":
    17.                 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"
    18.             if player have permission "core.kits.donor":
    19.                 make a gui slot 11 of player with MAGENTA STAINED GLASS PANE named "&5&nDONOR KITS" to close then run function KitDonorMenu(player)
    20.             wait 2 ticks
    21.             set {_slot} to 0
    22.             while inventory name of player's current inventory = "&b&nKITS":
    23.                 set {_slot} to 0
    24.                 if slot 1 of player's current inventory is MAGENTA STAINED GLASS PANE:
    25.                     loop 46 times:
    26.                         if inventory name of player's current inventory = "&b&nKITS":
    27.                             make a gui slot 15 of player with enchanted book named "&a&nDEFAULT KITS" to do nothing
    28.                             if player does not have permission "core.kits.donor":
    29.                                 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"
    30.                             else if player have permission "core.kits.donor":
    31.                                 make a gui slot 11 of player with diamond sword named "&5&nDONOR KITS" to close then run function KitDonorMenu(player)
    32.                             wait 1 ticks
    33.                             make a gui slot {_slot} of player with PURPLE STAINED GLASS PANE to do nothing
    34.                             add 1 to {_slot}
    35.                 if slot 1 of player's current inventory is PURPLE STAINED GLASS PANE:
    36.                     set {_slot} to 0
    37.                     loop 46 times:
    38.                         if inventory name of player's current inventory = "&b&nKITS":
    39.  
    40.                             make a gui slot 15 of player with enchanted book named "&a&nDEFAULT KITS" to do nothing
    41.                             if player does not have permission "core.kits.donor":
    42.                                 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"
    43.                             else if player have permission "core.kits.donor":
    44.                                 make a gui slot 11 of player with diamond sword named "&5&nDONOR KITS" to close then run function KitDonorMenu(player)
    45.                             wait 3 ticks
    46.                             make a gui slot {_slot} of player with MAGENTA STAINED GLASS PANE to do nothing
    47.                             add 1 to {_slot}
    48.                     wait 1 tick
    49.         if arg 1 is set:
    50.             broadcast "%{kits::%arg-1%::usage::%player%}%"
    51.             broadcast "%{kits::%arg-1%::delay}%"
    52.             set {_waited} to difference between {kits::%arg-1%::usage::%player%} and now
    53.             if {_waited} is less than {kits::%arg-1%::delay}:
    54.                 set {_wait} to difference between {Kits::%arg-1%::delay} and {_waited}
    55.                 send "%{_wait}%"
    56.                 stop
    57.             set {_Car} to uncoloured arg-1
    58.             set {_perm} to convert {_Car} to all lowercase
    59.             if player have permission "core.kits.%{_perm}%":
    60.                 if {kits::%arg-1%::set} is true:
    61.                     set {_m} to 0
    62.                     loop {kits::%arg-1%::items::*}:
    63.                         add 1 to {_m}
    64.                     set {_slot} to 0
    65.                     loop {_m} times:
    66.                         if player can hold {_m} of {kits::%arg-1%::items::%{_slot}%}:
    67.                             give player {kits::%arg-1%::items::%{_slot}%}
    68.                         else if player can't hold {_m} of {kits::%arg-1%::items::%{_slot}%}:
    69.                             set {_loc} to location of player
    70.                             set {_loc::y} to y coord of player's location + 1
    71.                             set y-coordinate of {_loc} to {_loc::y}
    72.                             drop {kits::%arg-1%::items::%{_slot}%} at {_loc}
    73.                         add 1 to {_slot}
    74.                     set {kits::%arg-1%::usage::%player%} to now
    75. command /admin$kits [<text>] [<text>] [<text>]:
    76.     trigger:
    77.         if player don't have permission "core.editkits":
    78.             send "&7Unknown command, type ""/help"" for help!"
    79.             stop
    80.         else:
    81.             if arg 1 is not set:
    82.                 send "&8&l&m--+=+---------------------+=+--"
    83.                 send ""
    84.                 send "&5&l*&7 /admin$kits create <name> <delay>"
    85.                 send "&5&l*&7 /admin$kits setDisplayName <name of kit> <display name>"
    86.                 send "&5&l*&7 /admin$kits create <name> <delay>"
    87.                 send "&5&l*&7 /admin$kits SetDir <name of kit> <category>"
    88.                 send "&5&l*&7 /admin$kits SetDelay <name of kit> <delay>"
    89.                 send ""
    90.                 send "&7^^^^^^^ Delay format is: 4 months, 3 weeks, 1 hour, 1 second"
    91.                 send ""
    92.                 send "&aThere are few caterogies, DONOR, DEFAULT"
    93.                 send "&bMade by The best Siilk"
    94.                 send ""
    95.                 send "&8&l&m--+=+---------------------+=+--"
    96.             if arg 1 is "create":
    97.                 if arg 2 is set:
    98.                     if arg 3 is set:
    99.                         if {kits::%arg-2%::set} is not set:
    100.                             set {kits::%arg-2%::set} to true
    101.                             set {_delay} to arg 3 parsed as timespan
    102.                             set {_slot} to 0
    103.                             set {_n} to 0
    104.                             loop all items in player's inventory:
    105.                                 add 1 to {_n}
    106.                             loop {_n} times:
    107.                                 set {kits::%arg-2%::items::%{_slot}%} to slot {_slot} of player's inventory
    108.                                 add 1 to {_slot}
    109.                             set {kits::%arg-2%::delay} to {_delay}
    110.                             set {kits::%arg-2%::dsplayname} to arg-2
    111.                             send "&8(&a!&8)&7 Kit: &a&n%arg-2%&7 have been created!"
    112.                         else:
    113.                             send "&cThis kit already exists!"
    114.             if arg 1 is "delete":
    115.                 if arg 2 is set:
    116.                     if arg 3 is not set:
    117.                         if {kits::%arg-2%::set} is true:
    118.                             set {kits::%arg-2%::set} to false
    119.                             delete {kits::%arg-2%::*}
    120.                             send "&8(&a!&8)&7 Kit: &a&n%arg-2%&7 have been deleted!"
    121.                         else:
    122.                             send "&cThis kit does not exists!"
    123.             if arg 1 is "sdn":
    124.                 if arg 2 is set:
    125.                     if arg 3 is set:
    126.                         if {kits::%arg-2%::set} is true:
    127.                             send "&7New name for kit: &a&n%arg-2%&7 is: %coloured arg-3%"
    128.                         else:
    129.                             send "&cThis kit does not exists!"
    130.             if arg 1 is "setdelay":
    131.                 if arg 2 is set:
    132.                     if arg 3 is set:
    133.                         if {kits::%arg-2%::set} is true:
    134.                             set {_var} to arg-3 parsed as timespan
    135.                             set {kits::%arg-2%::delay} to {_var}
    136.                             send "&7Cooldown for kit: &a&n%arg-2% &7is now: &a&n%{_var}%"
    137. command /kitgetrid <text>:
    138.     trigger:
    139.         set {kits::%arg-1%::set} to false
    140.  
     
  19. ChisleLP

    ChisleLP Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    789
    Likes Received:
    60
    What its your server version and skript version? (/ver skript) upload_2018-1-19_17-44-19.png
     
  20. Zoya

    Zoya Member

    Joined:
    Jun 5, 2017
    Messages:
    10
    Likes Received:
    0
    22-dev25,1 8.8.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...