Solved Does not give me the item.

  • 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!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

couger44

Supporter
Feb 19, 2017
713
31
28
Chile
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_language.skript:
on click:
    if "%region at player%" contains "crates":
        if targeted block is diamond block:
            cancel event
            set {_vip.sorteo.name} to "&a&lCaja &a[VIP]"
            set {_vip.sorteo.nombre} to tripwire hook named "%{_vip.sorteo.name}%"
            set line 2 of lore of {_vip.sorteo.nombre} to "&eDescubre lo que ganaras con"
            set line 3 of lore of {_vip.sorteo.nombre} to "&eesta llave en &n/warp crates"
            enchant {_vip.sorteo.nombre} with unbreaking 9999
            if player's tool is {_vip.sorteo.nombre}:
                send "&cNo te salgas de este inventario o no se te dará nada!" to player
                open virtual chest inventory with size 1 named "%{_vip.sorteo.name}%" to player
                remove 1 of {_vip.sorteo.nombre} from player's inventory
               
                set {_vip.sorteo.1} to diamond helmet named "%{_vip.sorteo.name}%"
                set line 2 of lore of {_vip.sorteo.1} to "&eSi eres &a[VIP]&e,"
                set line 3 of lore of {_vip.sorteo.1} to "&econsigue este item en &n/warp crates"
                enchant {_vip.sorteo.1} with protection 100
                enchant {_vip.sorteo.1} with unbreaking 100
                format a gui slot 4 of player with {_vip.sorteo.1} to do nothing
                play "CLICK" to player at volume 1
               
                wait 4 ticks
               
                set {_vip.sorteo.2} to diamond chestplate named "%{_vip.sorteo.name}%"
                set line 2 of lore of {_vip.sorteo.2} to "&eSi eres &a[VIP]&e,"
                set line 3 of lore of {_vip.sorteo.2} to "&econsigue este item en &n/warp crates"
                enchant {_vip.sorteo.2} with protection 100
                enchant {_vip.sorteo.2} with unbreaking 100
                enchant {_vip.sorteo.2} with thorns 1
                format a gui slot 4 of player with {_vip.sorteo.2} to do nothing
                play "CLICK" to player at volume 1
               
                wait 4 ticks
               
                set {_vip.sorteo.3} to diamond leggings named "%{_vip.sorteo.name}%"
                set line 2 of lore of {_vip.sorteo.3} to "&eSi eres &a[VIP]&e,"
                set line 3 of lore of {_vip.sorteo.3} to "&econsigue este item en &n/warp crates"
                enchant {_vip.sorteo.3} with protection 100
                enchant {_vip.sorteo.3} with unbreaking 100
                enchant {_vip.sorteo.3} with thorns 1
                format a gui slot 4 of player with {_vip.sorteo.3} to do nothing
                play "CLICK" to player at volume 1
               
                wait 4 ticks
               
                set {_vip.sorteo.4} to diamond boots named "%{_vip.sorteo.name}%"
                set line 2 of lore of {_vip.sorteo.4} to "&eSi eres &a[VIP]&e,"
                set line 3 of lore of {_vip.sorteo.4} to "&econsigue este item en &n/warp crates"
                enchant {_vip.sorteo.4} with protection 100
                enchant {_vip.sorteo.4} with unbreaking 100
                enchant {_vip.sorteo.4} with thorns 1
                format a gui slot 4 of player with {_vip.sorteo.4} to do nothing
                play "CLICK" to player at volume 1
               
                wait 4 ticks
               
                set {_vip.sorteo.5} to diamond sword named "%{_vip.sorteo.name}%"
                set line 2 of lore of {_vip.sorteo.5} to "&eSi eres &a[VIP]&e,"
                set line 3 of lore of {_vip.sorteo.5} to "&econsigue este item en &n/warp crates"
                enchant {_vip.sorteo.5} with sharpness 15
                enchant {_vip.sorteo.5} with unbreaking 50
                enchant {_vip.sorteo.5} with fire aspect 1
                format a gui slot 4 of player with {_vip.sorteo.5} to do nothing
                play "CLICK" to player at volume 1
               
                wait 4 ticks
               
                set {_vip.sorteo.6} to diamond pickaxe named "%{_vip.sorteo.name}%"
                set line 2 of lore of {_vip.sorteo.6} to "&eSi eres &a[VIP]&e,"
                set line 3 of lore of {_vip.sorteo.6} to "&econsigue este item en &n/warp crates"
                enchant {_vip.sorteo.6} with efficiency 50
                enchant {_vip.sorteo.6} with unbreaking 100
                enchant {_vip.sorteo.6} with fortune 15
                format a gui slot 4 of player with {_vip.sorteo.6} to do nothing
                play "CLICK" to player at volume 1
               
                wait 4 ticks
               
                set {_vip.sorteo.7} to bow named "%{_vip.sorteo.name}%"
                set line 2 of lore of {_vip.sorteo.7} to "&eSi eres &a[VIP]&e,"
                set line 3 of lore of {_vip.sorteo.7} to "&econsigue este item en &n/warp crates"
                enchant {_vip.sorteo.7} with punch 1
                enchant {_vip.sorteo.7} with power 10
                enchant {_vip.sorteo.7} with unbreaking 10
                enchant {_vip.sorteo.7} with flame 1
                format a gui slot 4 of player with {_vip.sorteo.7} to do nothing
                play "CLICK" to player at volume 1
               
                wait 4 ticks
               
                set {_vip.sorteo.8} to paper named "&2&l$1.000.000"
                set line 2 of lore of {_vip.sorteo.8} to "&eDale &nclick derecho&e a este item"
                set line 3 of lore of {_vip.sorteo.8} to "&epara que se te añada el dinero."
                enchant {_vip.sorteo.8} with unbreaking 9999
                format a gui slot 4 of player with {_vip.sorteo.8} to do nothing
                play "CLICK" to player at volume 1
               
                wait 4 ticks
               
                set {_vip.sorteo.9} to paper named "&2&l$500.000"
                set line 2 of lore of {_vip.sorteo.9} to "&eDale &nclick derecho&e a este item"
                set line 3 of lore of {_vip.sorteo.9} to "&epara que se te añada el dinero."
                enchant {_vip.sorteo.9} with unbreaking 9999
                format a gui slot 4 of player with {_vip.sorteo.9} to do nothing
                play "CLICK" to player at volume 1
               
                wait 4 ticks
               
                set {_vip.sorteo.10} to paper named "&2&l$700.000"
                set line 2 of lore of {_vip.sorteo.10} to "&eDale &nclick derecho&e a este item"
                set line 3 of lore of {_vip.sorteo.10} to "&epara que se te añada el dinero."
                enchant {_vip.sorteo.10} with unbreaking 9999
                format a gui slot 4 of player with {_vip.sorteo.10} to do nothing
                play "CLICK" to player at volume 1
               
                wait 4 ticks
                #chance of 100%:
                chance of 10%:
                    format a gui slot 5 of player with torch named "&e&lFelicidades!" to do nothing
                    format a gui slot 3 of player with torch named "&e&lFelicidades!" to do nothing
                    format a gui slot 4 of player with {_vip.sorteo.10} to do nothing
                    add 1 of {_vip.sorteo.10} to player's inventory
                chance of 10%:
                    format a gui slot 5 of player with torch named "&e&lFelicidades!" to do nothing
                    format a gui slot 3 of player with torch named "&e&lFelicidades!" to do nothing
                    format a gui slot 4 of player with {_vip.sorteo.9} to do nothing
                    add 1 of {_vip.sorteo.9} to player's inventory
                chance of 10%:
                    format a gui slot 5 of player with torch named "&e&lFelicidades!" to do nothing
                    format a gui slot 3 of player with torch named "&e&lFelicidades!" to do nothing
                    format a gui slot 4 of player with {_vip.sorteo.8} to do nothing
                    add 1 of {_vip.sorteo.8} to player's inventory
                chance of 10%:
                    format a gui slot 5 of player with torch named "&e&lFelicidades!" to do nothing
                    format a gui slot 3 of player with torch named "&e&lFelicidades!" to do nothing
                    format a gui slot 4 of player with {_vip.sorteo.7} to do nothing
                    add 1 of {_vip.sorteo.7} to player's inventory
                chance of 10%:
                    format a gui slot 5 of player with torch named "&e&lFelicidades!" to do nothing
                    format a gui slot 3 of player with torch named "&e&lFelicidades!" to do nothing
                    format a gui slot 4 of player with {_vip.sorteo.6} to do nothing
                    add 1 of {_vip.sorteo.6} to player's inventory
                chance of 10%:
                    format a gui slot 5 of player with torch named "&e&lFelicidades!" to do nothing
                    format a gui slot 3 of player with torch named "&e&lFelicidades!" to do nothing
                    format a gui slot 4 of player with {_vip.sorteo.5} to do nothing
                    add 1 of {_vip.sorteo.5} to player's inventory
                chance of 10%:
                    format a gui slot 5 of player with torch named "&e&lFelicidades!" to do nothing
                    format a gui slot 3 of player with torch named "&e&lFelicidades!" to do nothing
                    format a gui slot 4 of player with {_vip.sorteo.4} to do nothing
                    add 1 of {_vip.sorteo.4} to player's inventory
                chance of 10%:
                    format a gui slot 5 of player with torch named "&e&lFelicidades!" to do nothing
                    format a gui slot 3 of player with torch named "&e&lFelicidades!" to do nothing
                    format a gui slot 4 of player with {_vip.sorteo.3} to do nothing
                    add 1 of {_vip.sorteo.3} to player's inventory
                chance of 10%:
                    format a gui slot 5 of player with torch named "&e&lFelicidades!" to do nothing
                    format a gui slot 3 of player with torch named "&e&lFelicidades!" to do nothing
                    format a gui slot 4 of player with {_vip.sorteo.2} to do nothing
                    add 1 of {_vip.sorteo.2} to player's inventory
                chance of 10%:
                    format a gui slot 5 of player with torch named "&e&lFelicidades!" to do nothing
                    format a gui slot 3 of player with torch named "&e&lFelicidades!" to do nothing
                    format a gui slot 4 of player with {_vip.sorteo.1} to do nothing
                    add 1 of {_vip.sorteo.1} to player's inventory
            else:
                send "&cNo tienes la llave para abrir esta caja!"
 
Add debug messages to every chance section. Also check console
 
Thats not how chance works.
You can basically only use 1 chance in a section.
Example:
code_language.skript:
Chance 25%:
    do this
Chance 25%:
    do this
Chance 25%:
    do this
Chance 25%:
    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_language.skript:
set {_r} to random integer between 1 and 4
if {_r} = 1:
    do this
else if {_r} = 2:
    do this
else if {_r} = 3:
    do this
else:
    do this
 
Thats not how chance works.
You can basically only use 1 chance in a section.
Example:
code_language.skript:
Chance 25%:
    do this
Chance 25%:
    do this
Chance 25%:
    do this
Chance 25%:
    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_language.skript:
set {_r} to random integer between 1 and 4
if {_r} = 1:
    do this
else if {_r} = 2:
    do this
else if {_r} = 3:
    do this
else:
    do this
Im gonna test this.
[doublepost=1556764460,1556159432][/doublepost]
Thats not how chance works.
You can basically only use 1 chance in a section.
Example:
code_language.skript:
Chance 25%:
    do this
Chance 25%:
    do this
Chance 25%:
    do this
Chance 25%:
    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_language.skript:
set {_r} to random integer between 1 and 4
if {_r} = 1:
    do this
else if {_r} = 2:
    do this
else if {_r} = 3:
    do this
else:
    do this
This works, thanks.
 
Status
Not open for further replies.