How to set up variables

A variable is a feature that allows the customer to have a choice when purchasing a package. They can come in the form of either a dropdown or custom entered text. 
An example use of a variable would be to give the player a choice of username colour. You can also give the option to receive an extra item within their package.
These custom variables work as part of a command the same way as our list of default variables, found here. They replace the identifier, e.g. "{name}", "{uuid}", "{packageName}", with the value described like the player username, player UUID and the package name. 

Creating Variables

To create a variable you will need to head to the "Variables" section of your Buycraft server panel.
The first option is the identifier, it is the name for your variable, in this example, we can use "prefix". Then in the package commands, we can get the customer's chosen option by using "{prefix}". In the same way, you would use "{name}" for the customers Minecraft username.
The description will display to the customer above the different options. In this example, you might use "Choose your prefix.". Then you will need to specify the options the customer can choose.
You can give a multiple-choice option for players or you can let the user enter own input in a text field. The text field option has some validation rules like only numbers or only letters. You can also choose the length the player's input needs to be.
In the multiple-choice option, the "Name" field is what displays to the customer and the "Value" is what would replace your {prefix} identifier. You can enter single words or even whole commands here. The "Price" field is an optional field which you can use to add an amount to the package price if the player chooses it.

Using variables in a package

Once you have created your new variable you can use it in a package command. To make the variable active you need to select it as enabled in the Variables drop-down on the package edit page.
To use the variable you created in a command you need to enter the identifier. Make sure it is in place of where the value of the players choice will appear!
Using our example, adding a prefix with permissions would look like this:
pex user {name} prefix {prefix}
When the customer purchases the package they will have the choice of what their prefix will be. The value of the player's choice will replace the {prefix} variable.

Still need help? Contact Us Contact Us