How to set up variables

Custom variables allow the player a choice of multiple options or entering their own option when purchasing a package. 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, such as the player username, player UUID and the package name.
An example of how you might use this would be for the player to choose from a list of prefixes you chosen, or allow the player to enter their own. 

Creating Variables

To create a variable start by heading to the "Variables" section of your Buycraft server panel and clicking "Create Variable".
Once on the variable creation screen the first option is the identifier which the name for your variable, in this example, we'll use "prefix". 
Once this is set up you will be able to use {prefix} in the package commands to get the customer's chosen option, in the same way, you would use "{username}" for the customers Minecraft username.
The description will display to the customer above the different options when they add this package to their basket. In this example, you might use "Choose your prefix.". 
Next you will need to specify the options the customer can choose - there are a few options for what you would like the player to enter when they are checking out. 
  • Dropdown -  Will allow you to set the choices for your players in a dropdown.
  • Alphabetic - Will allow players to type their own input, only letters no spaces.
  • Numeric - Will allow players to type their own input, only numbers no spaces.
  • Alphanumerical - Will allow players to type their own input, numbers and letters no spaces.
  • Email address - Will only accept a valid email address.
  • Player username - Will only accept a valid username.
  • Text - Will allow general text and you can choose if it accepts, letters, numbers, spaces or special characters.
In the multiple-choice option, the "Name" field is what displays to the customer and the "Value" is what would replace your {prefix} identifier. For the value, you can enter single words or even whole commands here depending on your needs. The "Price" field is an optional field which you can use to increase the package price for their choice by amount or percentage.

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