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.

Skript autocompact not working

Discussion in 'Skript' started by Yoxie, May 8, 2022.

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

    Yoxie New Member

    Joined:
    May 8, 2022
    Messages:
    5
    Likes Received:
    0
    Hey, first post here, I use a 1.18.2 revivenode server with 4gb ram and every time I run this command nothing happens?

    Code (Text):
    1. options:
    2.  {autocompact::%player%} = 0
    3.  
    4. command /autocompact:
    5.  trigger:
    6.   if {ACaccess::%player%} = true:
    7.    if {autocompact::%player%} = 0:
    8.     set {autocompact::%player%} to 1
    9.     send "&bAutocompact enabled" to player
    10.     send "Rip server" to player
    11.     set {loop} to 1
    12.     while {loop} = 1:
    13.      if player has 9 lapis:
    14.       remove 9 lapis from the player
    15.       give the player 1 lapis block
    16.      if player has 9 raw iron:
    17.       remove 9 raw iron from the player
    18.       give the player 1 raw iron block
    19.      if player has 9 redstone:
    20.       remove 9 redstone from the player
    21.       give the player 1 redstone block
    22.      else:
    23.       if {autocompact::%player%} = 1:
    24.        set {autocompact::%player%} to 0
    25.        send "&bAutocompact disabled" to player
    26.      wait 1 second
    27.  
    28.   else:
    29.    send "&4You don't have access to that command" to player
    30.  
    31. command /repairall:
    32.  trigger:
    33.   send "&bRepairing your items..." to player
    34.   loop all items in player's inventory:
    35.    if loop-item's durability < loop-item's max durability:
    36.     repair loop-item
    I've checked my plugins and none of them are interfering, all my other skripts are working fine. Could I get any help?
     
    #1 Yoxie, May 8, 2022
    Last edited: May 8, 2022
  2. BanditEagle

    BanditEagle Active Member

    Joined:
    May 3, 2021
    Messages:
    55
    Likes Received:
    0
    Code (Text):
    1. options:
    2.  {autocompact::%player%} = 0
    This is the error. You are setting it in the options where no players are defined. If you want it to be disabled when a player joins, you need to set that variable to 0 using the "on join" event.
    Also, there is indentation issues on your skript starting from line 22 to 29. You need to make that section at the same place as the "if {autocompact::%player%} = 0" statement.
     
  3. Yoxie

    Yoxie New Member

    Joined:
    May 8, 2022
    Messages:
    5
    Likes Received:
    0
    I've applied all these, hopefully it works now, thank you!
    --- Double Post Merged, May 8, 2022, Original Post Date: May 8, 2022 ---

    Hey, after changing all of these it still doesn't work, do you know what could be going on?
    Code (Text):
    1. on first join:
    2.  set {autocompact::%player%} to 0
    3. command /autocompact:
    4.  trigger:
    5.   if {ACaccess::%player%} = true:
    6.    if {autocompact::%player%} = 0:
    7.     set {autocompact::%player%} to 1
    8.     send "&bAutocompact enabled" to player
    9.     send "Rip server" to player
    10.     set {loop} to 1
    11.     while {loop} = 1:
    12.      if player has 9 lapis:
    13.       remove 9 lapis from the player
    14.       give the player 1 lapis block
    15.      if player has 9 raw iron:
    16.       remove 9 raw iron from the player
    17.       give the player 1 raw iron block
    18.      if player has 9 redstone:
    19.       remove 9 redstone from the player
    20.       give the player 1 redstone block
    21.    else:
    22.     if {autocompact::%player%} = 1:
    23.      set {autocompact::%player%} to 0
    24.      send "&bAutocompact disabled" to player
    25.      wait 1 second
    26.   else:
    27.    send "&4You don't have access to that command" to player
    28.  
    --- Double Post Merged, May 8, 2022 ---
    I got it now thank you, you really helped actually and I'm surprised at how quickly you responded! However, it does now crash after a few seconds, do you know why?
     
  4. Yoxie

    Yoxie New Member

    Joined:
    May 8, 2022
    Messages:
    5
    Likes Received:
    0
    Here's the console logs if that helps:
     
  5. BanditEagle

    BanditEagle Active Member

    Joined:
    May 3, 2021
    Messages:
    55
    Likes Received:
    0
    It's because you have a while statement that is always true, so it is making an infinite loop, which crashes your server. You have set the variable {loop} to 1 just before the while loop, and inside the loop you never change the value. You need to include a line somewhere inside of the loop so that it isn't always true.
     
  6. Yoxie

    Yoxie New Member

    Joined:
    May 8, 2022
    Messages:
    5
    Likes Received:
    0
    Would it work if i set it to false, waited 1 second then set it to true again?
     
  7. BanditEagle

    BanditEagle Active Member

    Joined:
    May 3, 2021
    Messages:
    55
    Likes Received:
    0
    yes that would work as well, but I suggest putting that line at the very end of the while loop so that all of the lines inside of the loop run first, and then you disable it
     
  8. Yoxie

    Yoxie New Member

    Joined:
    May 8, 2022
    Messages:
    5
    Likes Received:
    0
    Can I see what this would look like?
     
  9. BanditEagle

    BanditEagle Active Member

    Joined:
    May 3, 2021
    Messages:
    55
    Likes Received:
    0
    Honestly speaking, you could remove the loop completely since you are only looking to run that once. It would make the code simpler and have less lag
     
Thread Status:
Not open for further replies.

Share This Page

Loading...