Jump to content

skQuery

Member
  • Content Count

    11
  • Joined

  • Last visited

Posts posted by skQuery

  1. 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

  2. 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}

     

  3. Kind of sucks your leaving,

     

    I've had good conversations with you. We may get in fights but thats past tense, current day matters 🙂 ly bro, good luck with your life.

    • Like 1
×
×
  • Create New...