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 variable as minute

Discussion in 'Skript' started by loadka95, Aug 17, 2017.

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

    loadka95 Active Member

    Joined:
    Feb 24, 2017
    Messages:
    78
    Likes Received:
    6
    Code (Skript):
    1. on join:
    2.     set {_tempbanwaited} to difference between {tempbannedtimer.%player%} and now
    3.     if {_tempbanwaited} is less than {tempban.%player%} minute: #This line is not working for me **
    4.         wait 26 tick
    5.         kick player due to "%{_tempbanwaited}%"
    {tempban.%player%} is a number
    ** I tried to put the variable {tempban.%player%} to %% and "" , those time no error popped up, but still don't worked!
    The error message: Névtelen.png

     
  2. Best Answer:
    Post #6 by ShaneBee, Aug 17, 2017
  3. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    What is the value of {tempban.%player%}? Can you put in a troubleshooting message like this?
    Code (Skript):
    1. on join:
    2.    broadcast "%{tempban.%player%}%"
    3.     set {_tempbanwaited} to difference between {tempbannedtimer.%player%} and now
    depending on how your command that uses that variable sets the timer, it may have extra characters in it making it not work. For example with essentials the commands could be done /tempban <player> 5m, potentially adding an "m" to your variable that would make the number not work in this section here [​IMG]
     
  4. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    Its just a number, nothing else.
     
  5. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    are you setting the variable {tempbannedtimer.%player%} to now in that code as well?
    It helps to post all relevant code so we dont have to ask as many questions or take guesses
     
  6. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    Yes, but here is the full code:
    Code (Skript):
    1. variables:
    2.     {_ponline} = 0
    3.  
    4. command /agui:
    5.     trigger:
    6.         set {_ponline} to 0
    7.         open chest with 6 row named "asd" to player
    8.         loop all players:
    9.             add 1 to {_ponline}
    10.             broadcast "%name of loop-value%"
    11.             wait 1 tick
    12.             set slot {_ponline}-1 of player's current inventory to ("%name of loop-value%" parsed as offline player)'s skull named "%name of loop-value%"
    13.        
    14. on inventory click:
    15.     if name of player's current inventory is "asd":
    16.         if clicked slot is between 0 and 53:
    17.             if clicked inventory is not player's inventory:
    18.                 if clicked item is not air:
    19.                     set {clickedslot.%player%} to name of clicked item
    20.                     cancel event
    21.                     close player's inventory
    22.                     wait 2 tick
    23.                     open chest with 5 row named "%{clickedslot.%player%}%" to player
    24.                     set slot 4 of player's current inventory to ("%{clickedslot.%player%}%" parsed as offline player)'s skull named "%{clickedslot.%player%}%"
    25.                     set slot 19 of player's current inventory to red wool block named "&aKick Player"
    26.                     set slot 21 of player's current inventory to barrier named "&aBan Player"
    27.  
    28.     if name of player's current inventory is "%{clickedslot.%player%}%":
    29.         loop all players:
    30.             if loop-player is equal to {clickedslot.%player%}:
    31.                 set {punishguy} to loop-player
    32.         if name of clicked item is "%{punishguy}%":
    33.             cancel event
    34.         else if name of clicked item is "&aKick Player":
    35.             cancel event
    36.             kick {punishguy} due to "You may not place %{punishguy}%!"
    37.         else if name of clicked item is "&aBan Player":
    38.             cancel event
    39.             close player's inventory
    40.             wait 2 tick
    41.             open chest with 5 row named "%{clickedslot.%player%}% BAN" to player
    42.             set slot 19 of player's current inventory to light green glass named "+1 minute"
    43.             set slot 20 of player's current inventory to light green glass named "+1 hour"
    44.             set slot 21 of player's current inventory to light green glass named "+1 day"
    45.             set slot 22 of player's current inventory to barrier named "&4BAN PLAYER" with lore "&a--- &bBan time &a---||     &e%{bantimeday.%player%}%d %{bantimehour.%player%}%h %{bantimeminute.%player%}%m"
    46.             set slot 23 of player's current inventory to red glass named "-1 day"
    47.             set slot 24 of player's current inventory to red glass named "-1 hour"
    48.             set slot 25 of player's current inventory to red glass named "-1 minute"
    49.  
    50.     if name of player's current inventory is "%{clickedslot.%player%}% BAN":
    51.         if name of clicked item is "&4BAN PLAYER":
    52.             clear {tempban.%{clickedslot.%player%}%}
    53.             set {tempban.%{clickedslot.%player%}%} to {tempban.%{clickedslot.%player%}%}+{bantimeminute.%player%}+({bantimehour.%player%}*60)+({bantimeday.%player%}*1440)
    54.             loop all players:
    55.                 if loop-player is equal to {clickedslot.%player%}:
    56.                     set {punishguy} to loop-player
    57.                     set {tempbannedtimer.%{punishguy}%} to now     #<---
    58.                     kick {punishguy} due to "Banned for %{tempban.%{clickedslot.%player%}%}% min"
    59.             cancel event
    60.         else if name of clicked item is "+1 minute":
    61.             add 1 to {bantimeminute.%player%}
    62.             if {bantimeminute.%player%} is 60:
    63.                 add 1 to {bantimehour.%player%}
    64.                 remove 60 from {bantimeminute.%player%}
    65.             cancel event
    66.         else if name of clicked item is "+1 hour":
    67.             add 1 to {bantimehour.%player%}
    68.             if {bantimehour.%player%} is 24:
    69.                 add 1 to {bantimeday.%player%}
    70.                 remove 24 from {bantimehour.%player%}
    71.             cancel event
    72.         else if name of clicked item is "+1 day":
    73.             add 1 to {bantimeday.%player%}
    74.             cancel event
    75.         else if name of clicked item is "-1 minute":
    76.             if {bantimeminute.%player%} is more than 0:
    77.                 remove 1 from {bantimeminute.%player%}
    78.             cancel event
    79.         else if name of clicked item is "-1 hour":
    80.             if {bantimehour.%player%} is more than 0:
    81.                 remove 1 from {bantimehour.%player%}
    82.             cancel event
    83.         else if name of clicked item is "-1 day":
    84.             if {bantimeday.%player%} is more than 0:
    85.                 remove 1 from {bantimeday.%player%}
    86.             cancel event
    87.         set slot 22 of player's current inventory to barrier named "&4BAN PLAYER" with lore "&a--- &bBan time &a---||     &e%{bantimeday.%player%}%d %{bantimehour.%player%}%h %{bantimeminute.%player%}%m"
    88.        
    89. on join:
    90.     broadcast "%{tempban.%player%}%"
    91.     set {_tempbanwaited} to difference between {tempbannedtimer.%player%} and now
    92.     if {_tempbanwaited} is less than {tempban.%player%} minute:
    93.         wait 26 tick
    94.         kick player due to "%{_tempbanwaited}%"
     
  7. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    it may not be the best outcome, but in a bit of testing I found for me that removing the "minute" after the variable in that line makes it load properly, so it's not the variable itself I think it's the syntax not accepting text after the variable. You could incorporate that into your code elsewhere instead. this was my simplified test code
    Code (Skript):
    1. on join:
    2.     set {_tempbanwaited} to difference between {tempbannedtimer.%player%} and now
    3.     if {_tempbanwaited} is less than {tempban.%player%}:
    4.         wait 26 tick
    5.         kick player due to "%{_tempbanwaited}%"
    6.  
    7.        
    8. command /numberset:
    9.     trigger:
    10.         set {tempban.%player%} to "5 minute"
    11.         set {tempbannedtimer.%player%} to now
     
  8. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    Thank You! :emoji_slight_smile:
     
  9. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    @loadka95 while this doesn't error, it won't work. Depending on your skript version the tempban will either be permanent or instantly expire. What you need to do is use parsing to parse as a timespan when using a variable number of units. Also, especially when dealing with bans it's a big deal to use UUIDs so I would switch to those if I were you (and to list variables, while your at it)
     
Thread Status:
Not open for further replies.

Share This Page

Loading...