Limit the uses of an item (Sellwand)

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

NotNinjaTalon

Member
Mar 2, 2020
12
1
1
Hello, I'm currently making a skyblock server, anyways I've been trying to skript sellwands. I'm wanting various ones limited to a certain amount of uses, at the moment I've only got an infinite one. How could I make this limited to around 100 uses etc. Hope one of you guys can help me out!

Heres my current code:

Code:
options:
    tag: &d&lSELLWAND &8»&7

command /sellwand:
    trigger:
        if player's inventory contains name tag named "&8» &d&lSELLWAND" with lore "&7  &oRight-Click &7on a chest.":
            send "{@tag} You already have a &dsell wand&7."
            stop
        else:
            give 1 name tag named "&8» &d&lSELLWAND" with lore "&7  &oRight-Click &7on a chest." to player
            send "{@tag} You got a &dsell wand&7."
            stop

on right-click:
    if event-block is chest or trapped chest:
        if player's tool is name tag named "&8» &d&lSELLWAND" with lore "&7  &oRight-Click &7on a chest.":
            cancel event
            loop all items in inventory of clicked block:
                if loop-item is cactus:

                    set {_items} to number of cactus in inventory of event-block

                    set {_money} to unformat("%{balance::%player%}%")
                    set {_result} to ({_items} * 10)
                    add {_result} to {_money}
                    set {_resultFormat} to format({_result})
                    set {balance::%player%} to format({_money})

                    send "{@tag} You sold &d%{_items}% &7of &dcactus &7and you got &d$%{_resultFormat}%&7." to player

                    remove all cactus from inventory of event-block

                if loop-item is sugar cane:

                    set {_items} to number of sugar cane in inventory of event-block

                    set {_money} to unformat("%{balance::%player%}%")
                    set {_result} to ({_items} * 5)
                    add {_result} to {_money}
                    set {_resultFormat} to format({_result})
                    set {balance::%player%} to format({_money})

                    send "{@tag} You sold &d%{_items}% &7of &dsugar cane &7and you got &d$%{_resultFormat}%&7." to player

                    remove all sugar cane from inventory of event-block

                if loop-item is pumpkin:

                    set {_items} to number of sugar cane in inventory of event-block

                    set {_money} to unformat("%{balance::%player%}%")
                    set {_result} to ({_items} * 6.25)
                    add {_result} to {_money}
                    set {_resultFormat} to format({_result})
                    set {balance::%player%} to format({_money})

                    send "{@tag} You sold &d%{_items}% &7of &dpumpkin &7and you got &d$%{_resultFormat}%&7." to player

                    remove all pumpkin from inventory of event-block

                if loop-item is melon slice:

                    set {_items} to number of melon slice in inventory of event-block

                    set {_money} to unformat("%{balance::%player%}%")
                    set {_result} to ({_items} * 2.5)
                    add {_result} to {_money}
                    set {_resultFormat} to format({_result})
                    set {balance::%player%} to format({_money})

                    send "{@tag} You sold &d%{_items}% &7of &dmelon slice &7and you got &d$%{_resultFormat}%&7." to player

                    remove all melon slice from inventory of event-block

                if loop-item is poppy:

                    set {_items} to number of poppy in inventory of event-block

                    set {_money} to unformat("%{balance::%player%}%")
                    set {_result} to ({_items} * 1)
                    add {_result} to {_money}
                    set {_resultFormat} to format({_result})
                    set {balance::%player%} to format({_money})

                    send "{@tag} You sold &d%{_items}% &7of &dpoppy &7and you got &d$%{_resultFormat}%&7." to player

                    remove all poppy from inventory of event-block

                if loop-item is iron ingot:

                    set {_items} to number of iron ingot in inventory of event-block

                    set {_money} to unformat("%{balance::%player%}%")
                    set {_result} to ({_items} * 37.5)
                    add {_result} to {_money}
                    set {_resultFormat} to format({_result})
                    set {balance::%player%} to format({_money})

                    send "{@tag} You sold &d%{_items}% &7of &diron ingot &7and you got &d$%{_resultFormat}%&7." to player

                    remove all iron ingot from inventory of event-block


on right-click:
    if event-block is chest or trapped chest:
        if player's tool is name tag named "&8» &d&lSELLWAND" with lore "&7  &oRight-Click &7on a chest.":
            cancel event
            loop all items in inventory of clicked block:
                if loop-item is iron ore:

                    set {_items} to number of iron ore in inventory of event-block

                    set {_money} to unformat("%{balance::%player%}%")
                    set {_result} to ({_items} * 18.75)
                    add {_result} to {_money}
                    set {_resultFormat} to format({_result})
                    set {balance::%player%} to format({_money})

                    send "{@tag} You sold &d%{_items}% &7of &diron ore &7and you got &d$%{_resultFormat}%&7." to player

                    remove all iron ore from inventory of event-block
 
Last edited:
Please put that into a code so i can read it much easier..
[doublepost=1587231948,1587231838][/doublepost]And you can do like every time they sell it removes like 100 dur from it, and when that reaches 0 or less, it removes the sellwand.
[doublepost=1587232021][/doublepost]After the code when it's confirmed it selled, you can do "Take 100 from {Dur::%player's held item%}" i think
[doublepost=1587232069][/doublepost]But you have to set the variable to something though, so before the player gets the item in their inventory, it sets the variable to like 1k
 
Please put that into a code so i can read it much easier..
[doublepost=1587231948,1587231838][/doublepost]And you can do like every time they sell it removes like 100 dur from it, and when that reaches 0 or less, it removes the sellwand.
[doublepost=1587232021][/doublepost]After the code when it's confirmed it selled, you can do "Take 100 from {Dur::%player's held item%}" i think
[doublepost=1587232069][/doublepost]But you have to set the variable to something though, so before the player gets the item in their inventory, it sets the variable to like 1k
My bad, the code is now formatted, if possible could you try to add the durability aspect to it. An example of like 10 uses or something like that'd would be great. Thanks in advanced.
 
My bad, the code is now formatted, if possible could you try to add the durability aspect to it. An example of like 10 uses or something like that'd would be great. Thanks in advanced.
Of course, do you got discord? I can hit you up there! (Mine is Potato#2997)
 
Status
Not open for further replies.