Solved Repair System

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

Cupex

Member
Feb 16, 2020
43
1
8
26
Category: Tool Repair

Suggested name: Repair

Spigot/Skript Version: PaperMC-1.18.2/the newest

What I want:
So that's really easy to explain.
Use any tool (sword, axe, pickaxe, hoe, shovel, etc) to /repair. Depending on the damage and the type of tool (wood, stone, gold, iron, diamond, netherite), /repair costs more. So if the tool is not damaged too much, it costs less than if the tool is almost broken.

Thanks in advance ^^


Ideas for commands: /repair

Ideas for permissions: system.repair

When I'd like it by: as soon as someone has time to write this.
 
Code:
command /repair:
    permission: system.repair
    permission message: "&cYou don't have enough permission."
    description: &fRepairs your item for a price
    trigger:
        if player's tool is any pickaxe, axe, shovel, hoe, armor, bow, crossbow, shield, trident, flint and steel, fishing rod, shears or sword:
            if player's tool's durability > 0:
                set {_d} to durability of player's tool
                if type of player's tool is diamond tool:
                    set {_pMP} to 0.5*{_d}
                if type of player's tool is netherite tool:
                    set {_pMP} to 0.8*{_d}
                if type of player's tool is gold tool:
                    set {_pMP} to 0.3*{_d}
                if type of player's tool is iron tool:
                    set {_pMP} to 0.25*{_d}
                if type of player's tool is stone tool:
                    set {_pMP} to 0.10*{_d}
                if type of player's tool is wooden tool:
                    set {_pMP} to 0.05*{_d}
                if player's tool is a bow, crossbow, shears, fishing rod, flint and steel, trident or shield:
                    set {_pMP} to 0.13*{_d}
                if player's balance > {_pMP}:
                    remove {_pMP} from player's balance
                    repair player's tool
                    send "&aYou successfuly repaired your tool and paid %{_pMP}%$ for the repair." to player
                    play sound "block.anvil.use" with volume 2 and pitch 1 to player
                else:
                    send "&cYou don't have enough money to pay for the repair. (%{_pMP}-player's balance%$ needed)" to player
                    play sound "block.chest.close" with volume 2 and pitch 0 to player
            else:
                send "&cYour tool is not damaged and can't be repaired." to player
                play sound "block.chest.close" with volume 2 and pitch 0 to player
        else:
            send "&cYou must be holding a tool to perform this command." to player
            play sound "block.chest.close" with volume 2 and pitch 0 to player

simple skript, you can change the {_pMP} multipliers to whatever number you'd like to be charged per durability point for each tool type