/buy command

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

Loose

Member
Sep 2, 2020
1
0
1
22
Category: Shop

Suggested name: shop command

Spigot/Skript Version: latest

What I want:
When i do /buy (Item name) it will take the money from my balance and give me the item(with commands if possible). If I don't have the amount, it will simply message me that I don't have enough. No GUI

Ideas for commands:
/buy (item name)

Ideas for permissions:
no permission

When I'd like it by:

anytime
 
If the item you want to buy costs 100...
Code:
command /buy [<text>] [<text>]:
    set {_buyitem} to arg 1
    set {_amount} to arg 2
    set {_bal::%player%} to balance of player
    if {_bal::%player%} is larger than 99:
        give player {_amount} of {_buyitem} to player
        message "You bought %{_amount}% %{_buyitem}%!" to player
        subtract 100 from balance of player
        clear {_buyitem}
        clear {_amount}
        stop
    else if {_bal::%player%} is smaller than 100:
        message "You don't have enough money." to player
        clear {_buyitem}
        clear {_amount}
        stop