On this page you will find a few examples of how to use the existing features of CMI together to let you create a way to sell an item to a player. 

This is a great way for server owners to offer things such as buy a permission, unlock a rank, sell what you’re holding in your hand, or buy something like a kit or golden apple. 

Every server is run differently, so these examples are to help you understand how to put features together to make a unique experience for your players. It’s up to you to expand and extend the examples to fit your server.

We will show you how to make what you could basically call an item shop with a hologram, and then with a sign. 

For any of this to work, you will need to define the worth of an item for selling or for buy. This can be done with /cmi setworth which will open UI where you can define prices.

Side note: you can learn more about CMI features on this website; Interactive Commands, Dynamic Signs, Holograms, and the commands.

Example 1: Sell through hologram

A basic example of a hologram that not only shows items’ worth but indicates it with the correct icon and can be clicked to sell items from your hand. Lets show you how this is done.

The entire hologram section should look like this:

  Loc: LT_Craft;-102.5;74.12;86.29
  Interval: 0.1
  LOSInterval: 1
  Range: 8
  RangeExtra: 16
  Spacing: 0.25
  SpacingIcon: 1.0
  Interactable: true
  - check:%cmi_iteminhand_worthc%>0#!
  - hasitem:%cmi_iteminhand_type%-%cmi_iteminhand_amount%?#! asConsole! cmi msg [playerName]
    !{#cancan}You have sold &2%cmi_iteminhand_realname% {#cancan}x &2%cmi_iteminhand_amount%
    {#cancan}for &2%cmi_iteminhand_worth%
  - item:%cmi_iteminhand_type%-%cmi_iteminhand_amount%?#! asConsole! cmi money give
    [playerName] %cmi_iteminhand_worthc%
  - '{#Cancan}Sell'
  - ICON:%itemInHand%
  - '{#Cancan}Worth: {#edward}%cmi_iteminhand_worth%'
  - '%cmi_iteminhand_realname%'
  - '{#gray}Worth of one: %cmi_iteminhand_worth_one%'

Simply copy/paste this entire section into ~/plugins/CMI/Saves/Holograms.yml file and update its location values to fit your needs. You can always update it more accurately in-game.

Note: If you rather have a player buy an item. You’d have to apply the same principle but with checks and commands to achieve that. 

Example 2: Sell through Sign

A similar approach can be used for signs. Lets go and set up a dynamic sign that we then use interactive commands on to achieve this:

  1. Place a sign
  2. Look at it and perform /cmi dsign new
  3. Add 3 text lines to it, so it will look like this
  1. Open sign UI by clicking on and adjust the update time to 0.1 for a more fluid experience

The first part is done, you should see a sign changing its text when you select different items in your inventory

The second part is to create interactable commands. Simple perform /cmi ic new sellshop

This will open a similar interface. While looking at the sign we just made clicked on the first green + sign which will add this block to the list.
Next would be to switch to the command editor which can be done by clicking on ! sign then click + sign and you can enter commands. Commands are exactly the same as for holograms and it should look like.
    And you are done. The sign should update with information on how much you will get when clicking on the sign and what you will sell.

    Note: If you rather make a sign that players can click to buy an item, and then it takes their money. You can use the same principle and use the specialized commands to check if they have the available balance, and then use cmi give to put the item in their inventory.

    Extra info:
    You can use any check and command that is valid, for example, check if someone has permission, if not, set it, or another permission. Or give them a kit. You can be creative and use an entity, block, sign, or whatever works for /cmi ic, to make a shop to buy/sell, with a player. Of course not everything is possible, CMI isn’t a shopping plugin. But you can get a lot done by combining existing features. I hope this page gives server owners some inspiration to do just that.