# Simple chest shop # A chest/sign shop Skript for survival and vanilla friendly servers. # By redbau options: prefix: &5[&dWilderShop&5]&f prefix_sign: &5[&d\$&5] command /shop: trigger: message "" message "{@prefix} Peddler Ranks can setup a chest shop" message "&5See a tutorial: &dhttp://imgur.com/a/hRjg7" message "1) Add a sign to your chest (use shift+click)..." message " Line 1: $" message " Line 2: " message " Line 3: <1-64> " message " Skip Line 4" message "2) Verify the price is correct by opening the chest and reading the chat [Shop] output." message "3) You're done, nice work!" message "" command /$: trigger: message "" message "{@prefix} Peddler ranks can setup a shop anywhere!" message "&5See a tutorial: &dhttp://imgur.com/a/hRjg7" message "1) Place a chest on a new claim" message "2) Add a sign to your chest (use shift+click)..." message " Line 1: $" message " Line 2: " message " Line 3: <1-64> " message " Skip Line 4" message "3) Give players access with &d/containertrust public" message "Beware: /containertrust public makes all chests without shop signs FREE to loot! Setup a special claim so you don't put your whole base at risk. Be sure you test your chests and prices..." message "4) Verify the price is correct: open the chest and read chat [Shop] output. You're done, nice work!" message "" on sign change: player has permission "sell.sk" line 1 of event-block = "[$]" or "$" set {_desc} to line 2 of event-block set {_s::*} to line 3 of event-block split at " " set {_cnt} to {_s::1} parsed as number if "%{_cnt}%" = "": message "{@prefix} Invalid number!" set event-block to air drop a sign at event-location cancel event stop set {_money} to {_s::2} if "%{_money}%" = "": message "{@prefix} Invalid currency!" set event-block to air drop a sign at event-location cancel event stop if "%{_money}%" = "d": set {_money} to diamond if "%{_money}%" = "db": set {_money} to "diamond_block" if "%{_money}%" = "i" or "iron": set {_money} to "iron_ingot" if "%{_money}%" = "ib": set {_money} to "iron_block" if "%{_money}%" = "g" or "gold": set {_money} to "gold_ingot" if "%{_money}%" = "gb": set {_money} to "gold_block" if "%{_money}%" = "e": set {_money} to emerald if "%{_money}%" = "eb": set {_money} to "emerald_block" if {_cnt} > 64: message "{@prefix} Price should be between 1-64!" set event-block to air drop a sign at event-location cancel event stop if {_money} parsed as item is not diamond or diamond block or iron ingot or iron block or gold ingot or gold block or emerald or emerald block: message "{@prefix} Use a valid currency: iron, i, iron block, ib, diamond, d, db, gold, g, gb, emerald, e, eb!" set event-block to air drop a sign at event-location cancel event stop set line 1 of event-block to "{@prefix_sign}" replace "blocks" in {_money} with "block" #shorten '64 diamond_blocks' to fit on sign set line 2 of event-block to "&5&l%{_desc}%" set line 3 of event-block to "%{_cnt}% %{_money}%" set line 4 of event-block to "&6%name of player%" message "{@prefix} Chest shop created and open for business!" message "{@prefix} Selling each item stack for: %{_cnt}% %{_money}%." on join: if file "plugins/Skript/shop/%uuid of player%.yml" does not exist: create file "plugins/Skript/shop/%uuid of player%.yml" set yml value "playername" of file "plugins/Skript/shop/%uuid of player%.yml" to "%player%" set yml value "shop" of file "plugins/Skript/shop/%uuid of player%.yml" to false on rightclick on a chest or trapped chest: # works with both types of chests set {_tmpchest} to location of event-block loop blocks in front of {_tmpchest}: if type of loop-block is air: set yml value "shop" of file "plugins/Skript/shop/%uuid of player%.yml" to false stop if type of loop-block is wall sign: if line 1 of loop-block is "{@prefix_sign}": set yml value "shop" of file "plugins/Skript/shop/%uuid of player%.yml" to true set yml value "chestloc" of file "plugins/Skript/shop/%uuid of player%.yml" to "%location of event-block%" set {_s::*} to line 3 of loop-block split at " " set {_cnt} to {_s::1} set {_money} to {_s::2} set {_costnum} to {_s::1} parsed as number set yml value "costnum" of file "plugins/Skript/shop/%uuid of player%.yml" to {_costnum} set {_costitem} to {_s::2} replace "_" in {_costitem} with " " #check proper item name with space # set {_costitem} to {_costitem} parsed as item set yml value "costitem" of file "plugins/Skript/shop/%uuid of player%.yml" to {_costitem} set {_shopowner} to uncolored line 4 of loop-block set yml value "shopowner" of file "plugins/Skript/shop/%uuid of player%.yml" to {_shopowner} message "{@prefix} Items inside will cost: &d%{_costnum}% %{_costitem}% &5per stack." stop on inventory close: if yml value "shop" of file "plugins/Skript/shop/%uuid of player%.yml" is true: set yml value "shop" of file "plugins/Skript/shop/%uuid of player%.yml" to false set yml value "costitem" of file "plugins/Skript/shop/%uuid of player%.yml" to "" set yml value "costnum" of file "plugins/Skript/shop/%uuid of player%.yml" to "" set yml value "shopowner" of file "plugins/Skript/shop/%uuid of player%.yml" to "" set yml value "chestloc" of file "plugins/Skript/shop/%uuid of player%.yml" to "" on inventory click: if yml value "shop" of file "plugins/Skript/shop/%uuid of player%.yml" is true: set {_shopowner} to yml value "shopowner" of file "plugins/Skript/shop/%uuid of player%.yml" set {_chestloc} to yml value "chestloc" of file "plugins/Skript/shop/%uuid of player%.yml" set {_costnum} to yml value "costnum" of file "plugins/Skript/shop/%uuid of player%.yml" set {_costnum} to {_costnum} parsed as number set {_costitem} to yml value "costitem" of file "plugins/Skript/shop/%uuid of player%.yml" set {_costitem} to {_costitem} parsed as item #[todo] fix sometimes null %inventory type% console log warning. if inventory type of clicked inventory is "PLAYER": if name of player is not "%{_shopowner}%": message "{@prefix} Can't place items in someone else's shop!" cancel event if inventory type of clicked inventory is "CHEST": set {_itemslot} to clicked slot set {_theitem} to clicked item set {_theitem} to {_theitem} parsed as item if {_theitem} is not air: if name of player is not "%{_shopowner}%": if {_costnum} of {_costitem} is {_theitem}: cancel event stop if player has {_costnum} of {_costitem}: # [bug] Using item stack == always true if player has enough space for 64 stone: remove {_costnum} of {_costitem} from player's inventory add {_theitem} to player's inventory # Swap item with money set slot {_itemslot} of clicked inventory to {_costnum} of {_costitem} log "%player% -> %{_theitem}% [%{_costnum}% %{_costitem}%] from %{_shopowner}% (%{_chestloc}%)" to "shop.log" #log "&6%player% &8-> &f%{_theitem}% &8[&a%{_costnum}% %{_costitem}%&8]" to "shop/%uuid of player%.log" log "&6%player% &8-> &f%{_theitem}% &8[&a%{_costnum}% %{_costitem}%&8]" to "shop/%{_shopowner}%.log" message "{@prefix} Purchased %{_theitem}% for: %{_costnum}% %{_costitem}%." cancel event else: message "{@prefix} You don't have enough free inventory space!" cancel event else: message "{@prefix} &cYou don't have &4%{_costnum}% %{_costitem}%!" cancel event stop else: message "{@prefix} You own this item." command /shoplog: permission: sell.sk trigger: set {_name} to name of player set {_name} to convert string "%{_name}%" to lowercase set {_lnct} to line count of file "plugins/Skript/logs/shop/%{_name}%.log" if {_lnct} > 0: message "" message "{@prefix} &5Total purchases from your shop: &6%{_lnct}%" message file contents of "plugins/Skript/logs/shop/%{_name}%.log" else: message "&5No shop purchases yet!"