Awards have been improved from the previous version. Awards are created in the admin panel, but are associated with an
Award plugin. This class allows you to check any conditions to see if the award should be given. These award classes can also be passed a parameter (a number, string or JSON string), so you can use the same
Award class for multiple awards.
All of the awards are run and scanned on the
UserStatsChanged event, so when a PIREP is accepted, or other properties for the user are changed (e.g, the number of flights, flight hours, etc). The user being scanned is passed in as the
Adding an Award
An award consists of two parts:
- An award plugin
- The award link
The award link is created in the admin panel, linking an award to a plugin. The plugin allows for advanced, reusable plugins and can be as complex or as simple as you like. To create an award from a plugin, view the awards page:
Award Plugin Structure
The award class needs to be placed in either the main Awards directory, or in a module, which can then be distributed as a full package.
modules/Awards/PilotFlightAwards.php is a fully-commented example
The Award class basically looks like this:
$parameter is the value that is set in the Award row in the admin panel. It's optional, so it might be good for you to set a default if it's null. An example could be the number of flights, so you can use the same
Award class for different types of awards.
Your Award class, in the
check($parameter) function, has access the class property called
$this->user. For example, if you want to see the user's flights, or if you wanted to have an award for a low landing rate: