skQuery Posted January 4, 2020 Share Posted January 4, 2020 (edited) ShopAPI A script api that brings creating shops to ease __________________________________________________________________________________________ Syntax: buy([item], [amount], %player%) #Checks for the requested %player% balance. #Gives the [item] to %player% with the [amount] provided. Sell("single", [item], [price], %player%) #Sells a single piece of [item] and adding [price] to %player% balance. Sell("all", [item], [price], %player%) #Sells all of [item] in %player% inventory and adding [price] to their balance. Requirements: Skript: This script wouldn't run without this plugin. Vault: This plugin is to handle the economy this script contains TuSKe: This is only required if you plan on making a shop gui instead. Example: format a gui slot 0 of player with stone lored "&6&l* &e[Buyable] &f$3 &7per||&6&l* &e[Sellable] &f$0.01 &7per||||&e[Click to Transact]||||&7&o (( Tip: Use middle mouse button to sell all. ))" to run: if click type is left mouse button: Buy(stone, 3, player) if click type is middle mouse button: Sell("all", stone, 0.01, player) if click type is right mouse button: Sell("single", stone, 0.01, player) Code: function Sell(type: text, item: item type, price: num, p: player): set {_amount} to amount of {_item} in {_p}'s inventory set {_totalProfit} to {_amount} * {_price} set {_v::*} to vanilla name of {_item} replace all "minecraft:" and "_block" with "" in {_v::1} replace all "_" with " " in {_v::1} if {_type} contains "all": if {_amount} is greater than or equal to 1: add ({_amount} * {_price}) to {_p}'s balance send "&e&l(!) &eYou successfully sold all &6&n%{_v::1}%&7 (&8%{_amount}%&8x&7) &efor &6&n$%{_totalProfit}%" to {_p} remove all {_item} from {_p} else: send "&e&l(!) &eYou don't have enough &6&n%{_v::*}%&e to sell." to {_p} if {_type} contains "single": if {_amount} is greater than or equal to 1: add {_price} to {_p}'s balance send "&e&l(!) &eYou successfully sold all &6&n%{_v::1}%&7 (&81x&7) &efor &6&n$%{_price}%" to {_p} remove 1 of {_item} from {_p} else: send "&e&l(!) &eYou don't have enough &6&n%{_v::1}%&e to sell." to {_p} function Buy(item: item type, price: num, p: player): set {_v::*} to vanilla name of {_item} replace all "minecraft:" and "_block" with "" in {_v::1} replace all "_" with " " in {_v::1} if {_p}'s balance is greater than or equal to {_price}: remove {_price} from {_p}'s balance give {_p} 1 of {_item} send "&e&l(!) &eYou successfully bought &71x &6&n%{_v::1}%&e for &6&n$%{_price}%&e." to {_p} else: send "&e&l(!) &eYou don't have enough money, you need &6&n$%{_price}%&e to buy this item." to {_p} Edited January 16, 2020 by skQuery Link to comment Share on other sites More sharing options...
Tepoloco Posted January 4, 2020 Share Posted January 4, 2020 Awesome script! Thanks Tepoloco Discord - Tepoloco#0001 Link to comment Share on other sites More sharing options...
skQuery Posted January 4, 2020 Author Share Posted January 4, 2020 (edited) 46 minutes ago, NotNaga said: Awesome script! Thanks You're welcome Edited January 4, 2020 by skQuery Link to comment Share on other sites More sharing options...
xlr100 Posted January 4, 2020 Share Posted January 4, 2020 Nice script, I can see a lot of effort went into it. Although making it with the default skript menus and the on inventory click event would take less lines, work more efficiently and prevent some problems like /skript reload all breaking the menus Link to comment Share on other sites More sharing options...
skQuery Posted January 4, 2020 Author Share Posted January 4, 2020 (edited) 10 minutes ago, OMan100 said: Nice script, I can see a lot of effort went into it. Although making it with the default skript menus and the on inventory click event would take less lines, work more efficiently and prevent some problems like /skript reload all breaking the menus Thanks for your review. I don't think inventory click event would take less lines or work more efficiently because I've heard that it can cause menus to not work as expected. The api is allowing users to use 1 line of code to buy and sell/sell all blocks or items. I get you probably counted the example code "format gui slot" as part of the api, but it isn't. You can DM me on discord and we can talk more, skQuery#1234 Edited January 4, 2020 by skQuery Link to comment Share on other sites More sharing options...
NanToes Posted April 4, 2021 Share Posted April 4, 2021 How do you use this? Link to comment Share on other sites More sharing options...
AHelpingCandy Posted April 4, 2021 Share Posted April 4, 2021 They... put examples just look into it. IGN ➣ Pickey ( Soon ) Joined MineHut ➣ January 7th 2019 Joined Forums ➣ January 11th 2021 Admin on NotedGens Manager on NotedGens Developer on CropiedDeveloper on Gennow (Genable) ==========================================Best Job: Badlion ( Client Moderator [ Failed Trial / Demoted] )Retired From: InvadedLands ( Moderator ) Retired From: MineTime ( Sr.Moderator ) Retired From: Hero Mines ( Helper ) Link to comment Share on other sites More sharing options...
TBTN Posted May 20, 2021 Share Posted May 20, 2021 It doesn't work for me I get 5 errors Link to comment Share on other sites More sharing options...
pAxiee Posted May 21, 2021 Share Posted May 21, 2021 Please make sure that you aren't responding to posts that haven't been responded to in over a month. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts