fasutas_1972

make me an skript that will let u do /coralshop and it opens a gui where u can boy keys tags and chatcolors

Kodari AI
KodariOct 3 at 11:39 pm 1
CoralshopGUI
A Skript plugin that adds a /coralshop command, opening a GUI where players can purchase keys, tags, and chat colors using in-game currency. The shop interface displays available items with prices, and purchases are processed instantly, granting the selected item to the player and deducting the cost from their balance.

Place coralshop.sk in plugins/Skript/scripts/ and run /sk reload coralshop. Purchases use emeralds; admins can grant them with /coralshopadd <player> <amount>.

Kodari can make mistakes. Review important code before using.
Files
coralshop.sk
Code
1 148
coralshop.sk
options:
    prefix: &3[CoralShop]&r

function openCoralShop(p: player):
    set {_gui} to chest inventory with 3 rows named "&3&lCoral Shop"
    set slot 11 of {_gui} to tripwire hook named "&b&lKeys" with lore "&7Buy crate keys with emeralds."
    set slot 13 of {_gui} to name tag named "&e&lChat Tags" with lore "&7Unlock a tag for your chat name."
    set slot 15 of {_gui} to light blue dye named "&d&lChat Colors" with lore "&7Unlock a color for your chat."
    open {_gui} to {_p}

function openCoralKeys(p: player):
    set {_gui} to chest inventory with 3 rows named "&3&lCoral Keys"
    set slot 11 of {_gui} to tripwire hook named "&fCommon Crate Key" with lore "&7Cost: &e5 emeralds"
    set slot 15 of {_gui} to tripwire hook named "&bRare Crate Key" with lore "&7Cost: &e15 emeralds"
    set slot 22 of {_gui} to barrier named "&cBack"
    open {_gui} to {_p}

function openCoralTags(p: player):
    set {_gui} to chest inventory with 3 rows named "&3&lChat Tags"
    set slot 10 of {_gui} to name tag named "&3[Coral]" with lore "&7Cost: &e10 emeralds"
    set slot 13 of {_gui} to name tag named "&b[Diver]" with lore "&7Cost: &e10 emeralds"
    set slot 16 of {_gui} to name tag named "&a[Turtle]" with lore "&7Cost: &e10 emeralds"
    set slot 22 of {_gui} to barrier named "&cBack"
    open {_gui} to {_p}

function openCoralColors(p: player):
    set {_gui} to chest inventory with 3 rows named "&3&lChat Colors"
    set slot 10 of {_gui} to blue dye named "&9Blue Chat" with lore "&7Cost: &e8 emeralds"
    set slot 13 of {_gui} to light blue dye named "&bAqua Chat" with lore "&7Cost: &e8 emeralds"
    set slot 16 of {_gui} to light purple dye named "&dPink Chat" with lore "&7Cost: &e8 emeralds"
    set slot 22 of {_gui} to barrier named "&cBack"
    open {_gui} to {_p}

function coralshopPurchase(p: player, category: text, product: text, price: number):
    if {_category} is "tag":
        if {coralshop.owned.tag::%uuid of {_p}%::%{_product}%} is true:
            if {_product} is "coral":
                set {coralshop.active-tag::%uuid of {_p}%} to "&3[Coral]"
            else if {_product} is "diver":
                set {coralshop.active-tag::%uuid of {_p}%} to "&b[Diver]"
            else:
                set {coralshop.active-tag::%uuid of {_p}%} to "&a[Turtle]"
            send "{@prefix} &aTag equipped." to {_p}
            stop
    else if {_category} is "color":
        if {coralshop.owned.color::%uuid of {_p}%::%{_product}%} is true:
            if {_product} is "blue":
                set {coralshop.active-color::%uuid of {_p}%} to "&9"
            else if {_product} is "aqua":
                set {coralshop.active-color::%uuid of {_p}%} to "&b"
            else:
                set {coralshop.active-color::%uuid of {_p}%} to "&d"
            send "{@prefix} &aChat color equipped." to {_p}
            stop

    if {_p} does not have {_price} emeralds:
        send "{@prefix} &cYou need %{_price}% emeralds for that." to {_p}
        stop

    remove {_price} emeralds from {_p}

    if {_category} is "key":
        if {_product} is "common":
            give {_p} tripwire hook named "&fCommon Crate Key"
        else:
            give {_p} tripwire hook named "&bRare Crate Key"
    else if {_category} is "tag":
        set {coralshop.owned.tag::%uuid of {_p}%::%{_product}%} to true
        if {_product} is "coral":
            set {coralshop.active-tag::%uuid of {_p}%} to "&3[Coral]"
        else if {_product} is "diver":
            set {coralshop.active-tag::%uuid of {_p}%} to "&b[Diver]"
        else:
            set {coralshop.active-tag::%uuid of {_p}%} to "&a[Turtle]"
    else:
        set {coralshop.owned.color::%uuid of {_p}%::%{_product}%} to true
        if {_product} is "blue":
            set {coralshop.active-color::%uuid of {_p}%} to "&9"
        else if {_product} is "aqua":
            set {coralshop.active-color::%uuid of {_p}%} to "&b"
        else:
            set {coralshop.active-color::%uuid of {_p}%} to "&d"

    send "{@prefix} &aPurchase successful!" to {_p}

command /coralshop:
    trigger:
        openCoralShop(player)

command /coralshopadd <player> <number>:
    permission: coralshop.admin
    permission message: &cYou don't have permission to use that command.
    trigger:
        if arg-2 is less than 1:
            send "{@prefix} &cAmount must be at least 1."
            stop
        give arg-2 emeralds to arg-1
        send "{@prefix} &aGave %arg-2% emeralds to %arg-1%."

on inventory click:
    if name of event-inventory is "&3&lCoral Shop":
        cancel event
        if clicked slot is 11:
            openCoralKeys(player)
        else if clicked slot is 13:
            openCoralTags(player)
        else if clicked slot is 15:
            openCoralColors(player)

    else if name of event-inventory is "&3&lCoral Keys":
        cancel event
        if clicked slot is 11:
            coralshopPurchase(player, "key", "common", 5)
        else if clicked slot is 15:
            coralshopPurchase(player, "key", "rare", 15)
        else if clicked slot is 22:
            openCoralShop(player)

    else if name of event-inventory is "&3&lChat Tags":
        cancel event
        if clicked slot is 10:
            coralshopPurchase(player, "tag", "coral", 10)
        else if clicked slot is 13:
            coralshopPurchase(player, "tag", "diver", 10)
        else if clicked slot is 16:
            coralshopPurchase(player, "tag", "turtle", 10)
        else if clicked slot is 22:
            openCoralShop(player)

    else if name of event-inventory is "&3&lChat Colors":
        cancel event
        if clicked slot is 10:
            coralshopPurchase(player, "color", "blue", 8)
        else if clicked slot is 13:
            coralshopPurchase(player, "color", "aqua", 8)
        else if clicked slot is 16:
            coralshopPurchase(player, "color", "pink", 8)
        else if clicked slot is 22:
            openCoralShop(player)

on chat:
    set {_tag} to ""
    if {coralshop.active-tag::%uuid of player%} is set:
        set {_tag} to "%{coralshop.active-tag::%uuid of player%}% "
    set {_color} to "&f"
    if {coralshop.active-color::%uuid of player%} is set:
        set {_color} to {coralshop.active-color::%uuid of player%}
    set chat format to "%{_tag}%%{_color}%%player%&8: %{_color}%%message%"