Giving enchanted items

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

    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.

ItsDarkElf

Member
Mar 27, 2022
3
0
1
Finland
I am just struggling with giving enchanted items to a player. It just doesn't work.

Server version: git-Paper-408(MC: 1.17.1)
Skript version: 2.6.3
Addons: Skellet, SkBee and skript-gui
Skellet version: 1.9.11
SkBee version: 1.9.1
skript-gui: 1.3-beta1

Code:
function dmgui(p: player, guinum: number):
    if {_guinum} is 1:
        create a gui with virtual chest inventory with size 3 named "&6Lootboxes":
            format gui slot 11 with chest named "&7Common Lootbox" with lore "&7%{dmcommonlb::%{_p}'s uuid%}%":
                if {dmcommonlb::%{_p}'s uuid%} > 0:
                    dmlootboxopen(player, 80, 90, 95, 98, 99, 100, 0, 0, 0)
                    remove 1 from {dmcommonlb::%{_p}'s uuid%}
                    dmgui(player, 1)
            format gui slot 12 with chest named "&bRare Lootbox" with lore "&7%{dmrarelb::%{_p}'s uuid%}%":
                if {dmrarelb::%{_p}'s uuid%} > 0:
                    dmlootboxopen(player, 0, 0, 80, 90, 96, 99, 100, 0, 0)
                    remove 1 from {dmrarelb::%{_p}'s uuid%}
                    dmgui(player, 1)
            format gui slot 13 with chest named "&5Epic Lootbox" with lore "&7%{dmepiclb::%{_p}'s uuid%}%":
                if {dmepiclb::%{_p}'s uuid%} > 0:
                    dmlootboxopen(player, 0, 0, 0, 0, 85, 97, 99, 100, 0)
                    remove 1 from {dmepiclb::%{_p}'s uuid%}
                    dmgui(player, 1)
            format gui slot 14 with chest named "&6Legendary Lootbox" with lore "&7%{dmlegendarylb::%{_p}'s uuid%}%":
                if {dmlegendarylb::%{_p}'s uuid%} > 0:
                    dmlootboxopen(player, 0, 0, 0, 0, 55, 66, 96, 98, 100)
                    remove 1 from {dmlegendarylb::%{_p}'s uuid%}
                    dmgui(player, 1)
            format gui slot 15 with chest named "&dMythic Lootbox" with lore "&7%{dmmythiclb::%{_p}'s uuid%}%":
                if {dmmythiclb::%{_p}'s uuid%} > 0:
                    dmlootboxopen(player, 0, 0, 0, 0, 25, 25, 89, 99, 100)
                    remove 1 from {dmmythiclb::%{_p}'s uuid%}
                    dmgui(player, 1)
        open last gui for {_p}

function dmlootboxopen(p: player, common: number, common+: number, rare: number, rare+: number, epic: number, epic+: number, legendary: number, mythic: number, omega: number):
    set {_1} to random integer between 1 and 100
    if {_1} is between 0 and {_common}:
        send "{@dmprefix} &7Ansaitsit juuri &7Common &7Loot" to {_p}
        dmlootrandomiser({_p}, "&7Common", 5)
    else if {_1} is between 0 and {_common+}:
        send "{@dmprefix} &7Ansaitsit juuri &7Common+ &7Loot" to {_p}
        dmlootrandomiser({_p}, "&7Common+", 6)
    else if {_1} is between 0 and {_rare}:
        send "{@dmprefix} &7Ansaitsit juuri &bRare &7Loot" to {_p}
        dmlootrandomiser({_p}, "&bRare", 12)
    else if {_1} is between 0 and {_rare+}:
        send "{@dmprefix} &7Ansaitsit juuri &bRare+ &7Loot" to {_p}
        dmlootrandomiser({_p}, "&bRare+", 13)
    else if {_1} is between 0 and {_epic}:
        send "{@dmprefix} &7Ansaitsit juuri &5Epic &7Loot" to {_p}
        dmlootrandomiser({_p}, "&5Epic", 15)
    else if {_1} is between 0 and {_epic+}:
        send "{@dmprefix} &7Ansaitsit juuri &5Epic+ &7Loot" to {_p}
        dmlootrandomiser({_p}, "&5Epic+", 16)
    else if {_1} is between 0 and {_legendary}:
        send "{@dmprefix} &7Ansaitsit juuri &6Legendary &7Loot" to {_p}
        dmlootrandomiser({_p}, "&6Legendary", 18)
    else if {_1} is between 0 and {_mythic}:
        send "{@dmprefix} &7Ansaitsit juuri &dMythic &7Loot" to {_p}
        dmlootrandomiser({_p}, "&dMythic", 20)
    else if {_1} is between 0 and {_omega}:
        send "{@dmprefix} &7Ansaitsit juuri &aOmega &7Loot" to {_p}
        broadcast "{@dmprefix} &7%{_p}% avasi lootbox:ista &aOmega &7tavaraa" in world of {_p}
        dmlootrandomiser({_p}, "&aOmega", 28)

function dmlootrandomiser(p: player, rarity: text, encvalue: number):
    set {_1} to random integer between 1 and {_encvalue}
    if {_rarity} is "&aOmega":
        if {_1} is 1:
            give netherite sword of "sharpness %{_1}%" parsed as enchantment type named "%{_rarity}% &7Miekka" to {_p}
        else if {_1} is 2:
            give netherite axe of "sharpness %{_1}%" parsed as enchantment type named "%{_rarity}% &7Kirves" to {_p}
        else if {_1} is 3:
            give netherite helmet of "protection %{_1}%" parsed as enchantment type named "%{_rarity}% &7Kypärä" to {_p}
        else if {_1} is 4:
            give netherite chestplate of "protection %{_1}%" parsed as enchantment type named "%{_rarity}% &7Panssari" to {_p}
        else if {_1} is 5:
            give netherite leggings of "protection %{_1}%" parsed as enchantment type named "%{_rarity}% &7Housut" to {_p}
        else if {_1} is 6:
            give netherite boots of "protection %{_1}%" parsed as enchantment type named "%{_rarity}% &7Saappaat" to {_p}
    else if {_rarity} is "&dMythic" or "&6Legendary":
        if {_1} is 1:
            give diamond sword of "sharpness %{_1}%" parsed as enchantment type named "%{_rarity}% &7Miekka" to {_p}
        else if {_1} is 2:
            give diamond axe of "sharpness %{_1}%" parsed as enchantment type named "%{_rarity}% &7Kirves" to {_p}
        else if {_1} is 3:
            give diamond helmet of "protection %{_1}%" parsed as enchantment type named "%{_rarity}% &7Kypärä" to {_p}
        else if {_1} is 4:
            give diamond chestplate of "protection %{_1}%" parsed as enchantment type named "%{_rarity}% &7Panssari" to {_p}
        else if {_1} is 5:
            give diamond leggings of "protection %{_1}%" parsed as enchantment type named "%{_rarity}% &7Housut" to {_p}
        else if {_1} is 6:
            give diamond boots of "protection %{_1}%" parsed as enchantment type named "%{_rarity}% &7Saappaat" to {_p}
    else:
        if {_1} is 1:
            give iron sword of "sharpness %{_1}%" parsed as enchantment type named "%{_rarity}% &7Miekka" to {_p}
        else if {_1} is 2:
            give iron axe of "sharpness %{_1}%" parsed as enchantment type named "%{_rarity}% &7Kirves" to {_p}
        else if {_1} is 3:
            give iron helmet of "protection %{_1}%" parsed as enchantment type named "%{_rarity}% &7Kypärä" to {_p}
        else if {_1} is 4:
            give iron chestplate of "protection %{_1}%" parsed as enchantment type named "%{_rarity}% &7Panssari" to {_p}
        else if {_1} is 5:
            give iron leggings of "protection %{_1}%" parsed as enchantment type named "%{_rarity}% &7Housut" to {_p}
        else if {_1} is 6:
            give iron boots of "protection %{_1}%" parsed as enchantment type named "%{_rarity}% &7Saappaat" to {_p}
 
Status
Not open for further replies.