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.

How to make this script more efficient

Discussion in 'Skript' started by xultraalphax, Jul 5, 2020.

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

    xultraalphax New Member

    Joined:
    Jul 3, 2020
    Messages:
    6
    Likes Received:
    0
    Hello! I want to make this skript more optimized because it laggs my server so much.
    Code (Text):
    1. command /grass [<text>]:
    2.   aliases: /fű, /fu, /weed
    3.   trigger:
    4.     if arg-1 is not set:
    5.       if {grass.%player%} is false:
    6.         set {grass.%player%} to true
    7.         send "&6MN &8»&7 Sikeresen &ebekapcsoltad&7 a növények eltűntetését!"
    8.       else:
    9.         set {grass.%player%} to false
    10.         send "&6MN &8»&7 Sikeresen &ekikapcsoltad&7 növények eltűntetését!"
    11.         if {%player%.list::*} is set:
    12.           loop {%player%.list::*}:
    13.             make player see block at loop-value as block at loop-value
    14.             remove loop-value from {%player%.list::*}
    15.     else if arg-1 is set:
    16.       if arg-1 is "reload" or "rl":
    17.         execute player command "sk reload MoszkvaGrass"
    18.         send "&6MN &8»&7 Plugin sikeresen újratöltve!"
    19.       else if arg-1 is "size":
    20.         send "%size of {%player%.list::*}%"
    21.       else:
    22.         send "&6MN &8»&7 Helyes használat: &c/grass"
    23.  
    24. on click:
    25.   send "%player's targeted block%" to player
    26.  
    27. on quit:
    28.   if {grass.%player%} is true:
    29.     set {grass.%player%} to false
    30.  
    31. on any movement:
    32.   if {grass.%player%} is true:
    33.     if {at.%player%} is not set:
    34.       set {at.%player%} to location of block at player
    35.     else if distance between block at player and {at.%player%} is higher than 1:
    36.       set {at.%player%} to location of block at player
    37.       loop all blocks in radius 6 around {at.%player%}:
    38.         if {%player%.list::*} does not contain location of loop-block:
    39.           if loop-block is double tall grass or long fern or sunflower or lilac or rose bush or peony:
    40.             make player see loop-block as air
    41.             add location of loop-block to {%player%.list::*}
    42.  
    43. on command "/grass":
    44.   wait 1 tick
    45.   while {grass.%player%} is true:
    46.     if {%player%.list::*} is set:
    47.       loop {%player%.list::*}:
    48.         if distance between {at.%player%} and block at loop-value is higher than 6:
    49.           remove loop-value from {%player%.list::*}
    50.           make player see block at loop-value as block at loop-value
    51.       wait 5 tick
    52.     wait 5 tick
    53.  
     
  2. Dave

    Dave Active Member

    Joined:
    Jul 20, 2018
    Messages:
    228
    Likes Received:
    9
    You're using ''on any movement'' event, no one would recommend u to use that, it decrease ur server performance

    use while instead of on any movement

    Code (Text):
    1. on join:
    2.     wait 1 second
    3.     while {grass.%player%} is true:
    4.         if {at.%player%} is not set:
    5.             set {at.%player%} to location of block at player
    6.         else if distance between block at player and {at.%player%} is higher than 1:
    7.             set {at.%player%} to location of block at player
    8.             loop all blocks in radius 6 around {at.%player%}:
    9.                 if {%player%.list::*} does not contain location of loop-block:
    10.                     if loop-block is double tall grass or long fern or sunflower or lilac or rose bush or peony:
    11.                         make player see loop-block as air
    12.                         add location of loop-block to {%player%.list::*}
    13.         wait 1 second
     
    #2 Dave, Jul 5, 2020
    Last edited: Jul 5, 2020
  3. xultraalphax

    xultraalphax New Member

    Joined:
    Jul 3, 2020
    Messages:
    6
    Likes Received:
    0
    This is the code currently, any suggestions to make it more efficient?

    Code (Text):
    1. command /grass [<text>]:
    2.   aliases: /fű, /fu, /weed
    3.   trigger:
    4.     if arg-1 is not set:
    5.       if {grass.%player%} is false:
    6.         set {grass.%player%} to true
    7.         send "&6MN &8»&7 Sikeresen &ebekapcsoltad&7 a növények eltűntetését!"
    8.       else:
    9.         set {grass.%player%} to false
    10.         send "&6MN &8»&7 Sikeresen &ekikapcsoltad&7 növények eltűntetését!"
    11.         if {%player%.list::*} is set:
    12.           loop {%player%.list::*}:
    13.             make player see block at loop-value as block at loop-value
    14.             remove loop-value from {%player%.list::*}
    15.     else if arg-1 is set:
    16.       if arg-1 is "reload" or "rl":
    17.         execute player command "sk reload MoszkvaGrass"
    18.         send "&6MN &8»&7 Plugin sikeresen újratöltve!"
    19.       else if arg-1 is "size":
    20.         send "%size of {%player%.list::*}%"
    21.       else:
    22.         send "&6MN &8»&7 Helyes használat: &c/grass"
    23.  
    24. on quit:
    25.   if {grass.%player%} is true:
    26.     set {grass.%player%} to false
    27.  
    28. on command "/grass":
    29.   wait 1 second
    30.   while {grass.%player%} is true:
    31.     if {at.%player%} is not set:
    32.       set {at.%player%} to location of block at player
    33.     else if distance between block at player and {at.%player%} is higher than 1:
    34.       set {at.%player%} to location of block at player
    35.       loop all blocks in radius 6 around {at.%player%}:
    36.         if {%player%.list::*} does not contain location of loop-block:
    37.           if loop-block is double tall grass or long fern or sunflower or lilac or rose bush or peony:
    38.             make player see loop-block as air
    39.             add location of loop-block to {%player%.list::*}
    40.     wait 5 tick
    41.  
    42. on command "/grass":
    43.   wait 1 tick
    44.   while {grass.%player%} is true:
    45.     if {%player%.list::*} is set:
    46.       loop {%player%.list::*}:
    47.         if distance between {at.%player%} and block at loop-value is higher than 6:
    48.           remove loop-value from {%player%.list::*}
    49.           make player see block at loop-value as block at loop-value
    50.       wait 5 tick
    51.     wait 5 tick
    52.  
     
Thread Status:
Not open for further replies.

Share This Page

Loading...