Shops

Shops allow you to easily set up a way for players to buy or sell items, using gold coin items as currency. You can set up as many shop systems as you want, and customize each one via a text file. You can then reference one of those files and access a store via the **RPGx\_OpenStore** event.

In each shop file, you can set up the items a shopkeeper can sell, as well as items they can buy from players (both of which are randomized during each shop "tick", which can be set under Server Settings in the Drafting Table GUI) - randomized items are meant to simulate altering supply for the store. You can also set the buy / sell price for each item in the text file, as well as the frequency for how often it appears in the store (when randomized). In addition, you can set the money the shopkeeper starts with and defaults to (if they have less than this amount), during each shop tick; A shop keeper's money affects how many items you can sell to them.

## Shop File Setup

   Text reference files for shops are located in the **config/server/RPGx\_Beta/Shops/** folder (which will be created for you the first time you host the RPGx add-on). To create a shop, first create a new .txt file, and name it to whatever you want your shop to be called (which will be referenced by the event). Then, enter 4 categories in the file, separated by a line:

**////NAME////**

**////MONEY////**

**////SELL////**

**////BUY////**

Under "////NAME////", enter the name of your store (which appears in the GUI). Under "////MONEY////", enter the money the shopkeeper starts with. Under "////SELL////", enter items you want players to be able to sell to the shopkeeper, using this format:

**Item UIname** [TAB] **Cost** [TAB] **Frequency**

Change "Item UIname" to the UI Name for that item (the way it appears in the wrench GUI, when adding an item to a brick). Hit "Tab" on your keyboard and then enter the "Cost" of that item (how many gold coins the shopkeeper will pay the player when that item is sold to them). Hit "Tab" again and insert a "Frequency" for the item - this is a percent value (%) between **0** and **100**, which affects how often that items appears in the store under the "Sell" category. Enter new items below the previous ones on a new line, using the same format.

Under "////BUY////", enter items you want players to be able to buy from the shopkeeper, using the exact same format as items under "////SELL////" mentioned above. Make sure to save your file when finished; you can inspect the "DefaultShop" file as an example of how shops are set up (this file is automatically created for you).

## Event Setup

   Once you're finished with the shop file, start up Blockland and host a server. Once in the server, plant a brick (usually bot spawns are best, but any brick should work) and open the wrench events GUI. Add the following event to the brick:

**onBotActivated** -> **Self** -> **RPGx\_OpenStore** -> **Add** "**FileName"**

Replace "FileName" with the name of the shop file you set up in **config/server/RPGx\_Beta/Shops/** (make sure you don't include quotes in the name; the file path and extension are not necessary). If you set up the store event on another type of brick (instead of a bot spawn), use "onActivate" instead of "onBotActivated". Once the event is applied, the shop GUI will open once the brick / bot is activated by the player.

**Note:** Selecting "Add" in the event popup menu (under Output Parameters) will cause the brick to be set as a "shop brick", allowing it to receive updates during shop ticks.

**Note:** To remove the shop from the brick, select **Remove** instead of **Add** in the event's output parameters, and then activate the event - this will prevent if from receiving updates during shop ticks. You can simply remove the shop event from the brick to disable the store, however, "removing" the shop will prevent the shop brick from receiving updates during ticks.