Skip to content
home/templates/player chest shops (with stock check)
economyAdvancednewmc 1.20.x – 1.21.x47 lines

player chest shops (with stock check)

players create a chest shop with a [Shop] sign — line 2 = price, line 3 = item. buyers right-click the sign; the script verifies the chest below has stock, removes one item from it, transfers money, gives the item to the buyer.

vanilla Skriptno addons required.
chest-shop.sk47 lines
on sign change:
    if line 1 is "[Shop]":
        if block at location 1 below event-block is not a chest:
            send "&cPlace a chest UNDER the sign first." to player
            cancel event
            stop
        set line 1 of event-block to "&8[&aShop&8]"
        set line 4 of event-block to "&7%player%"
        set {shop.owner::%location of event-block%} to player
        set {shop.price::%location of event-block%} to line 2 parsed as integer
        set {shop.item::%location of event-block%} to line 3
        send "&aShop created! Price: &a$%line 2% &7for &f%line 3%" to player

on right click on sign:
    if line 1 of event-block is not "&8[&aShop&8]":
        stop
    cancel event
    set {_loc} to location of event-block
    set {_owner} to {shop.owner::%{_loc}%}
    set {_price} to {shop.price::%{_loc}%}
    set {_item_text} to {shop.item::%{_loc}%}
    if {_owner} is not set:
        send "&cThis shop's data is missing. Ask the owner to re-create it." to player
        stop
    if player is {_owner}:
        send "&7You can't buy from your own shop." to player
        stop
    if {money.%uuid of player%} ? 0 < {_price}:
        send "&cYou need &a$%{_price}%&c to buy this." to player
        stop
    set {_chest} to block at location 1 below event-block
    if {_chest} is not a chest:
        send "&cThis shop has no chest. Tell the owner." to player
        stop
    set {_item} to {_item_text} parsed as item
    if {_chest}'s inventory does not contain {_item}:
        send "&cThis shop is out of stock." to player
        stop
    # Atomic transfer: debit chest, debit buyer, credit seller, give item.
    remove 1 of {_item} from {_chest}'s inventory
    remove {_price} from {money.%uuid of player%}
    add {_price} to {money.%uuid of {_owner}%}
    give 1 of {_item} to player
    send "&aBought &f%{_item_text}% &afor &a$%{_price}%&a." to player
    if {_owner} is online:
        send "&e%player% &abought &f%{_item_text}% &afrom your shop (&a$%{_price}%&a)" to {_owner}

get it running

chest-shop.sk · 47 lines · vanilla Skript
  1. 1

    copy or download

    grab the .sk file with the buttons up top.

    chest-shop.sk· ready to drop in
  2. 2

    drop it in your scripts folder

    save it exactly here on your server — no typos, just copy the path:

    …/plugins/Skript/scripts/chest-shop.sk
  3. 3

    reload in-game

    run this in chat or console — your script goes live instantly:

    /sk reload chest-shop
that's it — your script is live. hop in-game to try it.
/ related templates

more economy templates

comments