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!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to optimize this skript?

Discussion in 'Requests' started by KroterPvP, Jul 15, 2017.

  1. KroterPvP

    KroterPvP Active Member

    Joined:
    Apr 10, 2017
    Messages:
    178
    Likes Received:
    7
    Hello, I've created a new skript, but there are lots of sounds and the skript reloads within 2 minutes. I'm using SkQuerry, skript 2.2 benskus's edit 27-dev and Skellett.

    The problem is that I'm using this sentence, and it doesn't allow me to set a variable to a number, and then set this variable in the item quantity (number 9 in this small code)
    Code (Skript):
    1. set slot 1 of player to 9 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    How can I make the skript smaller, using loops and those things? Couse I can't because of the the sentence error :emoji_frowning:
    code:
    Code (Skript):
    1. command /pistol:
    2.     trigger:
    3.         set {pistol.ammo.%player%} to 10
    4.         set slot 1 of player to 10 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    5. on rightclick:
    6.     name of player's tool contains "&6Pistol &8»":
    7.         cancel event
    8.         if {pistol.ammo.%player%} is 0:
    9.             send "&cOUT OF AMMO! &eRecharge!"
    10.             play sound "BLAZE_HIT" to player with volume 1 and pitch 1
    11.         else:
    12.             if {pistol.recharging.%player%} is true:
    13.                 send "&cWait, your pistol is recharging"
    14.             else:
    15.                 remove 1 from {pistol.ammo.%player%}
    16.                 shoot an arrow at speed 8
    17.                 if {pistol.ammo.%player%} is 9:
    18.                     set slot 1 of player to 9 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    19.                 if {pistol.ammo.%player%} is 8:
    20.                     set slot 1 of player to 8 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    21.                 if {pistol.ammo.%player%} is 7:
    22.                     set slot 1 of player to 7 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    23.                 if {pistol.ammo.%player%} is 6:
    24.                     set slot 1 of player to 6 iron hoe named "&6Pistol &8» &6%{pistol.ammo.%player%}%"
    25.                 if {pistol.ammo.%player%} is 5:
    26.                     set slot 1 of player to 5 iron hoe named "&6Pistol &8» &6%{pistol.ammo.%player%}%"
    27.                 if {pistol.ammo.%player%} is 4:
    28.                     set slot 1 of player to 4 iron hoe named "&6Pistol &8» &c%{pistol.ammo.%player%}%"
    29.                 if {pistol.ammo.%player%} is 3:
    30.                     set slot 1 of player to 3 iron hoe named "&6Pistol &8» &c%{pistol.ammo.%player%}%"
    31.                 if {pistol.ammo.%player%} is 2:
    32.                     set slot 1 of player to 2 iron hoe named "&6Pistol &8» &4%{pistol.ammo.%player%}%"
    33.                 if {pistol.ammo.%player%} is 1:
    34.                     set slot 1 of player to 1 iron hoe named "&6Pistol &8» &4%{pistol.ammo.%player%}%"
    35.                 if {pistol.ammo.%player%} is 0:
    36.                     set slot 1 of player to 1 iron hoe named "&6Pistol &8» &4%{pistol.ammo.%player%}%"
    37.                     play sound "BLAZE_HIT" to player with volume 1 and pitch 1
    38. on leftclick:
    39.     name of player's tool contains "&6Pistol &8»":
    40.         cancel event
    41.         if {pistol.ammo.%player%} is more than 10:
    42.             set {pistol.ammo.%player%} to 10
    43.             set slot 1 of player to 10 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    44.         if {pistol.ammo.%player%} = 10:
    45.             send "&aYour pistol is full charged! Kill them!"
    46.         if {pistol.ammo.%player%} is 9:
    47.             set {pistol.recharging.%player%} to true
    48.             wait 0.5 seconds
    49.             add 1 to {pistol.ammo.%player%}
    50.             set slot 1 of player to 10 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    51.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    52.             set {pistol.recharging.%player%} to false
    53.         if {pistol.ammo.%player%} is 8:
    54.             set {pistol.recharging.%player%} to true
    55.             wait 0.5 seconds
    56.             add 1 to {pistol.ammo.%player%}
    57.             set slot 1 of player to 9 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    58.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    59.             wait 0.5 seconds
    60.             add 1 to {pistol.ammo.%player%}
    61.             set slot 1 of player to 10 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    62.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    63.             set {pistol.recharging.%player%} to false
    64.         if {pistol.ammo.%player%} is 7:
    65.             set {pistol.recharging.%player%} to true
    66.             wait 0.5 seconds
    67.             add 1 to {pistol.ammo.%player%}
    68.             set slot 1 of player to 8 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    69.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    70.             wait 0.5 seconds
    71.             add 1 to {pistol.ammo.%player%}
    72.             set slot 1 of player to 9 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    73.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    74.             wait 0.5 seconds
    75.             add 1 to {pistol.ammo.%player%}
    76.             set slot 1 of player to 10 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    77.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    78.             set {pistol.recharging.%player%} to false
    79.         if {pistol.ammo.%player%} is 6:
    80.             set {pistol.recharging.%player%} to true
    81.             wait 0.5 seconds
    82.             add 1 to {pistol.ammo.%player%}
    83.             set slot 1 of player to 7 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    84.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    85.             wait 0.5 seconds
    86.             add 1 to {pistol.ammo.%player%}
    87.             set slot 1 of player to 8 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    88.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    89.             wait 0.5 seconds
    90.             add 1 to {pistol.ammo.%player%}
    91.             set slot 1 of player to 9 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    92.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    93.             wait 0.5 seconds
    94.             add 1 to {pistol.ammo.%player%}
    95.             set slot 1 of player to 10 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    96.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    97.             set {pistol.recharging.%player%} to false
    98.         if {pistol.ammo.%player%} is 5:
    99.             set {pistol.recharging.%player%} to true
    100.             wait 0.5 seconds
    101.             add 1 to {pistol.ammo.%player%}
    102.             set slot 1 of player to 6 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    103.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    104.             wait 0.5 seconds
    105.             add 1 to {pistol.ammo.%player%}
    106.             set slot 1 of player to 7 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    107.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    108.             wait 0.5 seconds
    109.             add 1 to {pistol.ammo.%player%}
    110.             set slot 1 of player to 8 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    111.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    112.             wait 0.5 seconds
    113.             add 1 to {pistol.ammo.%player%}
    114.             set slot 1 of player to 9 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    115.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    116.             wait 0.5 seconds
    117.             add 1 to {pistol.ammo.%player%}
    118.             set slot 1 of player to 10 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    119.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    120.             set {pistol.recharging.%player%} to false
    121.         if {pistol.ammo.%player%} is 4:
    122.             set {pistol.recharging.%player%} to true
    123.             wait 0.5 seconds
    124.             add 1 to {pistol.ammo.%player%}
    125.             set slot 1 of player to 5 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    126.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    127.             wait 0.5 seconds
    128.             add 1 to {pistol.ammo.%player%}
    129.             set slot 1 of player to 6 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    130.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    131.             wait 0.5 seconds
    132.             add 1 to {pistol.ammo.%player%}
    133.             set slot 1 of player to 7 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    134.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    135.             wait 0.5 seconds
    136.             add 1 to {pistol.ammo.%player%}
    137.             set slot 1 of player to 8 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    138.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    139.             wait 0.5 seconds
    140.             add 1 to {pistol.ammo.%player%}
    141.             set slot 1 of player to 9 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    142.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    143.             wait 0.5 seconds
    144.             add 1 to {pistol.ammo.%player%}
    145.             set slot 1 of player to 10 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    146.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    147.             set {pistol.recharging.%player%} to false
    148.         if {pistol.ammo.%player%} is 3:
    149.             set {pistol.recharging.%player%} to true
    150.             wait 0.5 seconds
    151.             add 1 to {pistol.ammo.%player%}
    152.             set slot 1 of player to 4 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    153.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    154.             wait 0.5 seconds
    155.             add 1 to {pistol.ammo.%player%}
    156.             set slot 1 of player to 5 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    157.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    158.             wait 0.5 seconds
    159.             add 1 to {pistol.ammo.%player%}
    160.             set slot 1 of player to 6 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    161.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    162.             wait 0.5 seconds
    163.             add 1 to {pistol.ammo.%player%}
    164.             set slot 1 of player to 7 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    165.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    166.             wait 0.5 seconds
    167.             add 1 to {pistol.ammo.%player%}
    168.             set slot 1 of player to 8 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    169.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    170.             wait 0.5 seconds
    171.             add 1 to {pistol.ammo.%player%}
    172.             set slot 1 of player to 9 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    173.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    174.             wait 0.5 seconds
    175.             add 1 to {pistol.ammo.%player%}
    176.             set slot 1 of player to 10 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    177.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    178.             set {pistol.recharging.%player%} to false
    179.         if {pistol.ammo.%player%} is 2:
    180.             set {pistol.recharging.%player%} to true
    181.             wait 0.5 seconds
    182.             add 1 to {pistol.ammo.%player%}
    183.             set slot 1 of player to 3 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    184.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    185.             wait 0.5 seconds
    186.             add 1 to {pistol.ammo.%player%}
    187.             set slot 1 of player to 4 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    188.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    189.             wait 0.5 seconds
    190.             add 1 to {pistol.ammo.%player%}
    191.             set slot 1 of player to 5 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    192.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    193.             wait 0.5 seconds
    194.             add 1 to {pistol.ammo.%player%}
    195.             set slot 1 of player to 6 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    196.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    197.             wait 0.5 seconds
    198.             add 1 to {pistol.ammo.%player%}
    199.             set slot 1 of player to 7 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    200.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    201.             wait 0.5 seconds
    202.             add 1 to {pistol.ammo.%player%}
    203.             set slot 1 of player to 8 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    204.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    205.             wait 0.5 seconds
    206.             add 1 to {pistol.ammo.%player%}
    207.             set slot 1 of player to 9 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    208.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    209.             wait 0.5 seconds
    210.             add 1 to {pistol.ammo.%player%}
    211.             set slot 1 of player to 10 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    212.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    213.             set {pistol.recharging.%player%} to false
    214.         if {pistol.ammo.%player%} is 1:
    215.             set {pistol.recharging.%player%} to true
    216.             wait 0.5 seconds
    217.             add 1 to {pistol.ammo.%player%}
    218.             set slot 1 of player to 2 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    219.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    220.             wait 0.5 seconds
    221.             add 1 to {pistol.ammo.%player%}
    222.             set slot 1 of player to 3 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    223.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    224.             wait 0.5 seconds
    225.             add 1 to {pistol.ammo.%player%}
    226.             set slot 1 of player to 4 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    227.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    228.             wait 0.5 seconds
    229.             add 1 to {pistol.ammo.%player%}
    230.             set slot 1 of player to 5 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    231.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    232.             wait 0.5 seconds
    233.             add 1 to {pistol.ammo.%player%}
    234.             set slot 1 of player to 6 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    235.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    236.             wait 0.5 seconds
    237.             add 1 to {pistol.ammo.%player%}
    238.             set slot 1 of player to 7 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    239.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    240.             wait 0.5 seconds
    241.             add 1 to {pistol.ammo.%player%}
    242.             set slot 1 of player to 8 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    243.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    244.             wait 0.5 seconds
    245.             add 1 to {pistol.ammo.%player%}
    246.             set slot 1 of player to 9 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    247.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    248.             wait 0.5 seconds
    249.             add 1 to {pistol.ammo.%player%}
    250.             set slot 1 of player to 10 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    251.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    252.             set {pistol.recharging.%player%} to false
    253.         if {pistol.ammo.%player%} is 0:
    254.             set {pistol.recharging.%player%} to true
    255.             wait 0.5 seconds
    256.             add 1 to {pistol.ammo.%player%}
    257.             set slot 1 of player to 1 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    258.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    259.             wait 0.5 seconds
    260.             add 1 to {pistol.ammo.%player%}
    261.             set slot 1 of player to 2 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    262.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    263.             wait 0.5 seconds
    264.             add 1 to {pistol.ammo.%player%}
    265.             set slot 1 of player to 3 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    266.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    267.             wait 0.5 seconds
    268.             add 1 to {pistol.ammo.%player%}
    269.             set slot 1 of player to 4 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    270.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    271.             wait 0.5 seconds
    272.             add 1 to {pistol.ammo.%player%}
    273.             set slot 1 of player to 5 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    274.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    275.             wait 0.5 seconds
    276.             add 1 to {pistol.ammo.%player%}
    277.             set slot 1 of player to 6 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    278.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    279.             wait 0.5 seconds
    280.             add 1 to {pistol.ammo.%player%}
    281.             set slot 1 of player to 7 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    282.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    283.             wait 0.5 seconds
    284.             add 1 to {pistol.ammo.%player%}
    285.             set slot 1 of player to 8 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    286.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    287.             wait 0.5 seconds
    288.             add 1 to {pistol.ammo.%player%}
    289.             set slot 1 of player to 9 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    290.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    291.             wait 0.5 seconds
    292.             add 1 to {pistol.ammo.%player%}
    293.             set slot 1 of player to 10 iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    294.             play sound "ITEM_PICKUP" to player with volume 1 and pitch 1
    295.             set {pistol.recharging.%player%} to false
     
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    For the first part in the skript you could do this to make it a lot smaller:
    Code (Skript):
    1.                 remove 1 from {pistol.ammo.%player%}
    2.                 shoot an arrow at speed 8
    3.                 If {pistol.ammo.%player%} is between 0 and 10:
    4.                     set slot 1 of player to {pistol.ammo.%player%} iron hoe named "&6Pistol &8» &a%{pistol.ammo.%player%}%"
    5.                 If {pistol.ammo.%player%} = 0
    6.                     play sound "BLAZE_HIT" to player with volume 1 and pitch 1
    7.  
    Otherwhise if you wanna use loops or need to you can do it like this:
    Code (Skript):
    1.                 remove 1 from {pistol.ammo.%player%}
    2.                 shoot an arrow at speed 8
    3.                 Set {_timer} to 9
    4.                 Loop 9 times:
    5.                     if {pistol.ammo.%player%} is {_timer}:
    6.                         set slot 1 of player to {_timer} iron hoe named "&6Pistol &8» &a% {pistol.ammo.%player%}%"
    7.                     Remove 1 from {_timer}
    I hope you can make the other parts of the skript smaller yourself with this information :emoji_slight_smile: .
     
    #2 ShaneBee, Jul 17, 2017
    Last edited by a moderator: Jul 17, 2017

Share This Page

Loading...