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.

make this more efficient?

Discussion in 'Skript' started by FallingCatus, Mar 7, 2019.

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

    FallingCatus Member

    Joined:
    Jun 29, 2017
    Messages:
    38
    Likes Received:
    0
    Hey all so i wrote this skript to handle effects on a server i am building but i have noticed over time the server is lagging a little and when this skript is enabled some players timeout when joining but when disabled it is fine.

    I have no where mastered skirpt yet and will still class myself as basic. sorry.
    anyone know how i can make this more efficient?


    Code (Text):
    1.  
    2. on left click:
    3.     player is holding glass or white stained glass or orange stained glass or magenta stained glass or light blue stained glass or yellow stained glass or lime stained glass or pink stained glass or gray stained glass or light gray stained glass or cyan stained glass or purple stained glass or blue stained glass or brown stained glass or green stained glass or red stained glass or black stained glass:
    4.         player is sneaking
    5.         if player is wearing a helmet or glass or white stained glass or orange stained glass or magenta stained glass or light blue stained glass or yellow stained glass or lime stained glass or pink stained glass or gray stained glass or light gray stained glass or cyan stained glass or purple stained glass or blue stained glass or brown stained glass or green stained glass or red stained glass or black stained glass:
    6.             send "&dCosmic &8» &7please remove your current helmet and try again."
    7.         if player is not wearing a helmet or glass or white stained glass or orange stained glass or magenta stained glass or light blue stained glass or yellow stained glass or lime stained glass or pink stained glass or gray stained glass or light gray stained glass or cyan stained glass or purple stained glass or blue stained glass or brown stained glass or green stained glass or red stained glass or black stained glass:
    8.             equip player with tool
    9.             remove 1 of tool from tool
    10.  
    11.  
    12. #--- Main world ---#
    13.  
    14. on player world change:
    15.     wait 2 seconds
    16.     player is in "world":
    17.         remove slow falling from player
    18.         remove jump boost from player
    19.         remove wither effect from player
    20.         wait 1 seconds
    21.         apply potion of slow falling of tier 1 without any particles to the player for 1 day
    22.         apply potion of jump boost of tier 2 without any particles to the player for 1 day
    23.  
    24. every 5 seconds in world "world":
    25.     loop all players in world "world":
    26.         if loop-player doesn't have slow falling:
    27.             apply potion of slow falling of tier 1 without any particles to the loop-player for 1 day
    28.         if loop-player doesn't have jump boost:
    29.             apply potion of jump boost of tier 2 without any particles to the loop-player for 1 day
    30.  
    31. #----------------------#
    32.  
    33. #--- The Moon ---#
    34.  
    35. on player world change:
    36.     wait 2 seconds
    37.     player is in "Moon":
    38.         remove slow falling from player
    39.         remove jump boost from player
    40.         remove wither effect from player
    41.         wait 1 seconds
    42.         apply potion of slow falling of tier 4 without any particles to the player for 1 day
    43.         apply potion of jump boost of tier 4 without any particles to the player for 1 day
    44.  
    45. every 5 seconds in world "Moon":
    46.     loop all players in world "Moon":
    47.         if loop-player doesn't have slow falling:
    48.             apply potion of slow falling of tier 4 without any particles to the loop-player for 1 day
    49.         if loop-player doesn't have jump boost:
    50.             apply potion of jump boost of tier 4 without any particles to the loop-player for 1 day
    51.         if loop-player is not wearing glass or white stained glass or orange stained glass or magenta stained glass or light blue stained glass or yellow stained glass or lime stained glass or pink stained glass or gray stained glass or light gray stained glass or cyan stained glass or purple stained glass or blue stained glass or brown stained glass or green stained glass or red stained glass or black stained glass:
    52.             execute console command "/tm msg %loop-player% &d&lSuit Up!\n&7&lGlass Helmet, Chest, Legs and Boots!"
    53.             apply potion of wither of tier 1 without any particles to the loop-player for 5 seconds
    54.         if loop-player is not wearing a chestplate:
    55.             execute console command "/tm msg %loop-player% &d&lSuit Up!\n&7&lGlass Helmet, Chest, Legs and Boots!"
    56.             apply potion of wither of tier 1 without any particles to the loop-player for 5 seconds
    57.         if loop-player is not wearing a leggings:
    58.             execute console command "/tm msg %loop-player% &d&lSuit Up!\n&7&lGlass Helmet, Chest, Legs and Boots!"
    59.             apply potion of wither of tier 1 without any particles to the loop-player for 5 seconds
    60.         if loop-player is not wearing a boots:
    61.             execute console command "/tm msg %loop-player% &d&lSuit Up!\n&7&lGlass Helmet, Chest, Legs and Boots!"
    62.             apply potion of wither of tier 1 without any particles to the loop-player for 5 seconds
    63.  
    64.  
    65.  
    66. #---------------------#
    67.  
    68. #--- The Core ---#
    69.  
    70. on player world change:
    71.     wait 2 seconds
    72.     player is in "world_nether":
    73.         remove slow falling from player
    74.         remove jump boost from player
    75.         remove wither effect from player
    76.         wait 1 seconds
    77.         apply potion of slow falling of tier 1 without any particles to the player for 1 day
    78.         apply potion of jump boost of tier 2 without any particles to the player for 1 day
    79.  
    80. every 5 seconds in world "world_nether":
    81.     loop all players in world "world_nether":
    82.         if loop-player doesn't have slow falling:
    83.             apply potion of slow falling of tier 1 without any particles to the loop-player for 1 day
    84.         if loop-player doesn't have jump boost:
    85.             apply potion of jump boost of tier 2 without any particles to the loop-player for 1 day
    86.         if loop-player is not wearing glass or white stained glass or orange stained glass or magenta stained glass or light blue stained glass or yellow stained glass or lime stained glass or pink stained glass or gray stained glass or light gray stained glass or cyan stained glass or purple stained glass or blue stained glass or brown stained glass or green stained glass or red stained glass or black stained glass:
    87.             execute console command "/tm msg %loop-player% &c&lSuit Up!\n&7&lGlass Helmet, Chest, Legs and Boots!"
    88.             set loop-player on fire
    89.         if loop-player is not wearing a chestplate:
    90.             execute console command "/tm msg %loop-player% &c&lSuit Up!\n&7&lGlass Helmet, Chest, Legs and Boots!"
    91.             set loop-player on fire
    92.         if loop-player is not wearing a leggings:
    93.             execute console command "/tm msg %loop-player% &c&lSuit Up!\n&7&lGlass Helmet, Chest, Legs and Boots!"
    94.             set loop-player on fire
    95.         if loop-player is not wearing a boots:
    96.             execute console command "/tm msg %loop-player% &c&lSuit Up!\n&7&lGlass Helmet, Chest, Legs and Boots!"
    97.             set loop-player on fire
    98.  
    99.  
    100. #---------------------#
    101.  
    102. #--- k2 ---#
    103.  
    104. on player world change:
    105.     wait 2 seconds
    106.     player is in "k2":
    107.         remove slow falling from player
    108.         remove jump boost from player
    109.         remove wither effect from player
    110.         wait 1 seconds
    111.         apply potion of slow falling of tier 1 without any particles to the player for 1 day
    112.         apply potion of jump boost of tier 1 without any particles to the player for 1 day
    113.  
    114. every 5 seconds in world "k2":
    115.     loop all players in world "k2":
    116.         if loop-player doesn't have slow falling:
    117.             apply potion of slow falling of tier 1 without any particles to the loop-player for 1 day
    118.         if loop-player doesn't have jump boost:
    119.             apply potion of jump boost of tier 2 without any particles to the loop-player for 1 day
    120.  
    121. #----------------------#
     
  2. Yodaylay22

    Yodaylay22 Member

    Joined:
    Jul 24, 2018
    Messages:
    15
    Likes Received:
    1
    The problem with your code

    you use many loop unnecessarily (Every X seconds, loop all player, While ETC)

    you should avoid using it unnecessarily! use only when it is extremely necessary
     
Thread Status:
Not open for further replies.

Share This Page

Loading...