event-item and functions problem

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

Le4ft

Member
Jun 26, 2023
20
0
1
Hi,
this is my code:
Code:
on inventory click:
    if name of player's current inventory is "&d&lMystic Well":
        if event-item is "&cMystic Sword":
            openWellTierI(player, event-item)
Everything works fine, but when I put my sword into the "Mystic Well" and I want to enchant that, it just close my inventory and nothing else happens. It doesn't add any lore to my item.
This is a snippet from my Mystic Well GUI
Code:
make gui slot "k" with enchanted book named "&aEnchant to Tier I" with lore "" and "&7Price: &61000g" and "":
    enchantTierI({_p}, {_i})
{_p} stands for player and {_i} is the event-item
Code:
function enchantTierI(p: player, i: item):
    set {_ench} to a random element out of {swordench::*}
    set {_tier} to a random integer between 1 and 3

    if {_tier} = 1:
        set {_roman} to "I"
    if {_tier} = 2:
        set {_roman} to "II"
    if {_tier} = 3:
        set {_roman} to "III"

    set {final} to "%{_ench}% %{_roman}%"

    delete {_i}'s lore
    set the name of {_i} to "&cTier I Sword"
    add "&o" to {_i}'s lore

    addLoreSword({_p}, {_i}, {final})
    msgEnch({_p}, "Tier I Sword", {_ench})
Does anyone know why the Mystic Well doesn't do anything?
 
Hi,
this is my code:
Code:
on inventory click:
    if name of player's current inventory is "&d&lMystic Well":
        if event-item is "&cMystic Sword":
            openWellTierI(player, event-item)
Everything works fine, but when I put my sword into the "Mystic Well" and I want to enchant that, it just close my inventory and nothing else happens. It doesn't add any lore to my item.
This is a snippet from my Mystic Well GUI
Code:
make gui slot "k" with enchanted book named "&aEnchant to Tier I" with lore "" and "&7Price: &61000g" and "":
    enchantTierI({_p}, {_i})
{_p} stands for player and {_i} is the event-item
Code:
function enchantTierI(p: player, i: item):
    set {_ench} to a random element out of {swordench::*}
    set {_tier} to a random integer between 1 and 3

    if {_tier} = 1:
        set {_roman} to "I"
    if {_tier} = 2:
        set {_roman} to "II"
    if {_tier} = 3:
        set {_roman} to "III"

    set {final} to "%{_ench}% %{_roman}%"

    delete {_i}'s lore
    set the name of {_i} to "&cTier I Sword"
    add "&o" to {_i}'s lore

    addLoreSword({_p}, {_i}, {final})
    msgEnch({_p}, "Tier I Sword", {_ench})
Does anyone know why the Mystic Well doesn't do anything?
No way...

You have to put player In the function, not just {_p} . There is a reason you can't use player inside a function. Same thing wit the item. I'm not gonna show you how to make it the player's held item though (mainly bc of laziness), so have fun figuring that out. Hope this helps =)
 
  • Like
Reactions: Luke_Sky_Walker