Introduction
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:
shop: 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 Commands: - 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% Lines: - '{#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:
- Place a sign
- Look at it and perform /cmi dsign new
- Add 3 text lines to it, so it will look like this
- 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