Shop Issues

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

    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.

Skill

New Member
Feb 5, 2017
5
0
0
Skript Version: 2.2-fixes.v8b
Skript Author: Njol
Minecraft Version: 1.8.8
---
I can't use the format as I've deleted most of my nonworking code in this by now. However, here's what I'm trying to do.

I'm making a Chestshop, and the issue is I'm unable to check if a chest has a specific item. The chest is a variable set from a sign-click event. Here's the code I do have.
code_language.skript:
on right click on sign:
    if line 1 of event-block is "&8[&2Sell&8]":
        set {_Item} to line 2 of event-block
        set {_Price} to line 3 of event-block
        set {_Player} to line 4 of event-block
        set {_Item} to uncolored {_Item}
        set {_Player} to uncolored {_Player}
        replace all "$" with "" in {_Price}
        set {_Price1} to uncolored {_Price}
        set {_Price2} to {_Price1} parsed as an integer
        set {_Item} to {_Item} parsed as an item
        set {_Player} to {_Player} parsed as an offline player
        if {_Player} is "%player%":
            send " &cYou can't use your own shop!"
            stop
        set {_Block} to block behind event-block
        if {_Block} has enough space for {_Item}:
            set {_Bal} to {_Player}'s balance
            set {_Bal} to {_Bal} parsed as an integer
            if {_Bal} is greater than {_Price2}:
                loop all items in player's inventory:
                    if loop-item is {_Item}:
                        remove 1 of loop-item from player
                        add {_Item} to {_Block}'s inventory
                        console command "eco give %player% %{_Price2}%"
                        console command "eco take %{_Player}% %{_Price2}%"
                        send " &rYou sold 1x &c%{_item}%&r to %{_player}% for $%{_price2}%!" 
                        if {disableChestAlerts.%{_Player}%} is not set:
                            send " &e&l%player%&r sold you a %{_item}% to your shop! &7(- $%{_Price2}%)" to {_Player}
                        set {_Sold} to true
                        stop loop
            else:
                send " &rShop owner has insufficient funds!"
                send " &e&l%player%&r tried to purchase from your shop, but you have insufficient funds!" to {_Player}
                stop
            if {_Sold} is not set:
                send " &cError: You don't have any %{_Item}%!"
        else:
            send " &cThis shop is full!"
    else if line 1 of event-block is "&8[&2Buy&8]":
        set {_Item} to uncolored line 2 of event-block
        set {_Price} to uncolored line 3 of event-block
        set {_Player} to uncolored line 4 of event-block
        #
        set {_Chest} to block behind event-block
        set {_Inv::*} to inventory of {_Chest}
        set {_E} to inventory of block behind event-block
(The issue is under the Buy. I've tried setting "block behind event-block" to a variable and trying these
code_language.skript:
if inventory of {_Chest} contains
if {_Chest} contains
and more, but to no prevail
 
code_language.skript:
set {_Chest} to the block behind event-block
    loop all items in {_Chest}'s inventory:
        if loop-value is something:
            #do something
 
Status
Not open for further replies.