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 Does not give me the item.

Discussion in 'Skript' started by couger44, Apr 18, 2019.

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

    Supporter

    Joined:
    Feb 19, 2017
    Messages:
    714
    Likes Received:
    31
    Hello,
    A few hours ago I started creating a script about crates. All right until I decide to try it, and well ... the problem is that there are times when he does not give me the items that he should give me.

    Here been give me the item:
    upload_2019-4-17_20-4-55.png

    Here does not been give me the item:
    upload_2019-4-17_20-5-34.png
    Code (Skript):
    1.  
    2. on click:
    3.     if "%region at player%" contains "crates":
    4.         if targeted block is diamond block:
    5.             cancel event
    6.             set {_vip.sorteo.name} to "&a&lCaja &a[VIP]"
    7.             set {_vip.sorteo.nombre} to tripwire hook named "%{_vip.sorteo.name}%"
    8.             set line 2 of lore of {_vip.sorteo.nombre} to "&eDescubre lo que ganaras con"
    9.             set line 3 of lore of {_vip.sorteo.nombre} to "&eesta llave en &n/warp crates"
    10.             enchant {_vip.sorteo.nombre} with unbreaking 9999
    11.             if player's tool is {_vip.sorteo.nombre}:
    12.                 send "&cNo te salgas de este inventario o no se te dará nada!" to player
    13.                 open virtual chest inventory with size 1 named "%{_vip.sorteo.name}%" to player
    14.                 remove 1 of {_vip.sorteo.nombre} from player's inventory
    15.                
    16.                 set {_vip.sorteo.1} to diamond helmet named "%{_vip.sorteo.name}%"
    17.                 set line 2 of lore of {_vip.sorteo.1} to "&eSi eres &a[VIP]&e,"
    18.                 set line 3 of lore of {_vip.sorteo.1} to "&econsigue este item en &n/warp crates"
    19.                 enchant {_vip.sorteo.1} with protection 100
    20.                 enchant {_vip.sorteo.1} with unbreaking 100
    21.                 format a gui slot 4 of player with {_vip.sorteo.1} to do nothing
    22.                 play "CLICK" to player at volume 1
    23.                
    24.                 wait 4 ticks
    25.                
    26.                 set {_vip.sorteo.2} to diamond chestplate named "%{_vip.sorteo.name}%"
    27.                 set line 2 of lore of {_vip.sorteo.2} to "&eSi eres &a[VIP]&e,"
    28.                 set line 3 of lore of {_vip.sorteo.2} to "&econsigue este item en &n/warp crates"
    29.                 enchant {_vip.sorteo.2} with protection 100
    30.                 enchant {_vip.sorteo.2} with unbreaking 100
    31.                 enchant {_vip.sorteo.2} with thorns 1
    32.                 format a gui slot 4 of player with {_vip.sorteo.2} to do nothing
    33.                 play "CLICK" to player at volume 1
    34.                
    35.                 wait 4 ticks
    36.                
    37.                 set {_vip.sorteo.3} to diamond leggings named "%{_vip.sorteo.name}%"
    38.                 set line 2 of lore of {_vip.sorteo.3} to "&eSi eres &a[VIP]&e,"
    39.                 set line 3 of lore of {_vip.sorteo.3} to "&econsigue este item en &n/warp crates"
    40.                 enchant {_vip.sorteo.3} with protection 100
    41.                 enchant {_vip.sorteo.3} with unbreaking 100
    42.                 enchant {_vip.sorteo.3} with thorns 1
    43.                 format a gui slot 4 of player with {_vip.sorteo.3} to do nothing
    44.                 play "CLICK" to player at volume 1
    45.                
    46.                 wait 4 ticks
    47.                
    48.                 set {_vip.sorteo.4} to diamond boots named "%{_vip.sorteo.name}%"
    49.                 set line 2 of lore of {_vip.sorteo.4} to "&eSi eres &a[VIP]&e,"
    50.                 set line 3 of lore of {_vip.sorteo.4} to "&econsigue este item en &n/warp crates"
    51.                 enchant {_vip.sorteo.4} with protection 100
    52.                 enchant {_vip.sorteo.4} with unbreaking 100
    53.                 enchant {_vip.sorteo.4} with thorns 1
    54.                 format a gui slot 4 of player with {_vip.sorteo.4} to do nothing
    55.                 play "CLICK" to player at volume 1
    56.                
    57.                 wait 4 ticks
    58.                
    59.                 set {_vip.sorteo.5} to diamond sword named "%{_vip.sorteo.name}%"
    60.                 set line 2 of lore of {_vip.sorteo.5} to "&eSi eres &a[VIP]&e,"
    61.                 set line 3 of lore of {_vip.sorteo.5} to "&econsigue este item en &n/warp crates"
    62.                 enchant {_vip.sorteo.5} with sharpness 15
    63.                 enchant {_vip.sorteo.5} with unbreaking 50
    64.                 enchant {_vip.sorteo.5} with fire aspect 1
    65.                 format a gui slot 4 of player with {_vip.sorteo.5} to do nothing
    66.                 play "CLICK" to player at volume 1
    67.                
    68.                 wait 4 ticks
    69.                
    70.                 set {_vip.sorteo.6} to diamond pickaxe named "%{_vip.sorteo.name}%"
    71.                 set line 2 of lore of {_vip.sorteo.6} to "&eSi eres &a[VIP]&e,"
    72.                 set line 3 of lore of {_vip.sorteo.6} to "&econsigue este item en &n/warp crates"
    73.                 enchant {_vip.sorteo.6} with efficiency 50
    74.                 enchant {_vip.sorteo.6} with unbreaking 100
    75.                 enchant {_vip.sorteo.6} with fortune 15
    76.                 format a gui slot 4 of player with {_vip.sorteo.6} to do nothing
    77.                 play "CLICK" to player at volume 1
    78.                
    79.                 wait 4 ticks
    80.                
    81.                 set {_vip.sorteo.7} to bow named "%{_vip.sorteo.name}%"
    82.                 set line 2 of lore of {_vip.sorteo.7} to "&eSi eres &a[VIP]&e,"
    83.                 set line 3 of lore of {_vip.sorteo.7} to "&econsigue este item en &n/warp crates"
    84.                 enchant {_vip.sorteo.7} with punch 1
    85.                 enchant {_vip.sorteo.7} with power 10
    86.                 enchant {_vip.sorteo.7} with unbreaking 10
    87.                 enchant {_vip.sorteo.7} with flame 1
    88.                 format a gui slot 4 of player with {_vip.sorteo.7} to do nothing
    89.                 play "CLICK" to player at volume 1
    90.                
    91.                 wait 4 ticks
    92.                
    93.                 set {_vip.sorteo.8} to paper named "&2&l$1.000.000"
    94.                 set line 2 of lore of {_vip.sorteo.8} to "&eDale &nclick derecho&e a este item"
    95.                 set line 3 of lore of {_vip.sorteo.8} to "&epara que se te añada el dinero."
    96.                 enchant {_vip.sorteo.8} with unbreaking 9999
    97.                 format a gui slot 4 of player with {_vip.sorteo.8} to do nothing
    98.                 play "CLICK" to player at volume 1
    99.                
    100.                 wait 4 ticks
    101.                
    102.                 set {_vip.sorteo.9} to paper named "&2&l$500.000"
    103.                 set line 2 of lore of {_vip.sorteo.9} to "&eDale &nclick derecho&e a este item"
    104.                 set line 3 of lore of {_vip.sorteo.9} to "&epara que se te añada el dinero."
    105.                 enchant {_vip.sorteo.9} with unbreaking 9999
    106.                 format a gui slot 4 of player with {_vip.sorteo.9} to do nothing
    107.                 play "CLICK" to player at volume 1
    108.                
    109.                 wait 4 ticks
    110.                
    111.                 set {_vip.sorteo.10} to paper named "&2&l$700.000"
    112.                 set line 2 of lore of {_vip.sorteo.10} to "&eDale &nclick derecho&e a este item"
    113.                 set line 3 of lore of {_vip.sorteo.10} to "&epara que se te añada el dinero."
    114.                 enchant {_vip.sorteo.10} with unbreaking 9999
    115.                 format a gui slot 4 of player with {_vip.sorteo.10} to do nothing
    116.                 play "CLICK" to player at volume 1
    117.                
    118.                 wait 4 ticks
    119.                 #chance of 100%:
    120.                 chance of 10%:
    121.                     format a gui slot 5 of player with torch named "&e&lFelicidades!" to do nothing
    122.                     format a gui slot 3 of player with torch named "&e&lFelicidades!" to do nothing
    123.                     format a gui slot 4 of player with {_vip.sorteo.10} to do nothing
    124.                     add 1 of {_vip.sorteo.10} to player's inventory
    125.                 chance of 10%:
    126.                     format a gui slot 5 of player with torch named "&e&lFelicidades!" to do nothing
    127.                     format a gui slot 3 of player with torch named "&e&lFelicidades!" to do nothing
    128.                     format a gui slot 4 of player with {_vip.sorteo.9} to do nothing
    129.                     add 1 of {_vip.sorteo.9} to player's inventory
    130.                 chance of 10%:
    131.                     format a gui slot 5 of player with torch named "&e&lFelicidades!" to do nothing
    132.                     format a gui slot 3 of player with torch named "&e&lFelicidades!" to do nothing
    133.                     format a gui slot 4 of player with {_vip.sorteo.8} to do nothing
    134.                     add 1 of {_vip.sorteo.8} to player's inventory
    135.                 chance of 10%:
    136.                     format a gui slot 5 of player with torch named "&e&lFelicidades!" to do nothing
    137.                     format a gui slot 3 of player with torch named "&e&lFelicidades!" to do nothing
    138.                     format a gui slot 4 of player with {_vip.sorteo.7} to do nothing
    139.                     add 1 of {_vip.sorteo.7} to player's inventory
    140.                 chance of 10%:
    141.                     format a gui slot 5 of player with torch named "&e&lFelicidades!" to do nothing
    142.                     format a gui slot 3 of player with torch named "&e&lFelicidades!" to do nothing
    143.                     format a gui slot 4 of player with {_vip.sorteo.6} to do nothing
    144.                     add 1 of {_vip.sorteo.6} to player's inventory
    145.                 chance of 10%:
    146.                     format a gui slot 5 of player with torch named "&e&lFelicidades!" to do nothing
    147.                     format a gui slot 3 of player with torch named "&e&lFelicidades!" to do nothing
    148.                     format a gui slot 4 of player with {_vip.sorteo.5} to do nothing
    149.                     add 1 of {_vip.sorteo.5} to player's inventory
    150.                 chance of 10%:
    151.                     format a gui slot 5 of player with torch named "&e&lFelicidades!" to do nothing
    152.                     format a gui slot 3 of player with torch named "&e&lFelicidades!" to do nothing
    153.                     format a gui slot 4 of player with {_vip.sorteo.4} to do nothing
    154.                     add 1 of {_vip.sorteo.4} to player's inventory
    155.                 chance of 10%:
    156.                     format a gui slot 5 of player with torch named "&e&lFelicidades!" to do nothing
    157.                     format a gui slot 3 of player with torch named "&e&lFelicidades!" to do nothing
    158.                     format a gui slot 4 of player with {_vip.sorteo.3} to do nothing
    159.                     add 1 of {_vip.sorteo.3} to player's inventory
    160.                 chance of 10%:
    161.                     format a gui slot 5 of player with torch named "&e&lFelicidades!" to do nothing
    162.                     format a gui slot 3 of player with torch named "&e&lFelicidades!" to do nothing
    163.                     format a gui slot 4 of player with {_vip.sorteo.2} to do nothing
    164.                     add 1 of {_vip.sorteo.2} to player's inventory
    165.                 chance of 10%:
    166.                     format a gui slot 5 of player with torch named "&e&lFelicidades!" to do nothing
    167.                     format a gui slot 3 of player with torch named "&e&lFelicidades!" to do nothing
    168.                     format a gui slot 4 of player with {_vip.sorteo.1} to do nothing
    169.                     add 1 of {_vip.sorteo.1} to player's inventory
    170.             else:
    171.                 send "&cNo tienes la llave para abrir esta caja!"
    172.  
    173.  


     
  2. Best Answer:
    Post #3 by ShaneBee, Apr 20, 2019
  3. TPGamesNL

    Supporter Addon Developer Dev Programme

    Joined:
    Jan 20, 2018
    Messages:
    1,500
    Likes Received:
    102
    Medals:
    Add debug messages to every chance section. Also check console
     
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,181
    Likes Received:
    220
    Thats not how chance works.
    You can basically only use 1 chance in a section.
    Example:
    Code (Skript):
    1. Chance 25%:
    2.     do this
    3. Chance 25%:
    4.     do this
    5. Chance 25%:
    6.     do this
    7. Chance 25%:
    8.     do this
    This will NOT give you a 1/4 chance of each item.... how this works is, you have a 25% chance of the first item AND a 25% chance of the next item AND a 25% chance of the 3rd item AND a 25% chance of the last item. So, you do have a chance of all 4. When using to set something, kind of the same thing, your chances will be off.

    Your best solution in a case like this is to use a random system, ex:
    Code (Skript):
    1. set {_r} to random integer between 1 and 4
    2. if {_r} = 1:
    3.     do this
    4. else if {_r} = 2:
    5.     do this
    6. else if {_r} = 3:
    7.     do this
    8. else:
    9.     do this
     
  5. couger44

    Supporter

    Joined:
    Feb 19, 2017
    Messages:
    714
    Likes Received:
    31
    Im gonna test this.
    --- Double Post Merged, May 2, 2019, Original Post Date: Apr 25, 2019 ---
    This works, thanks.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...