[DEVELOPPERS]How To use the configuration

Discuss the Dedicated Server Tools developed by Nadeo Live such as ManiaLive, Trust Circles, Dedicated Manager, Competition Manager and Lobbies

Moderator: NADEO

Post Reply
farfa
Nadeo
Nadeo
Posts: 601
Joined: 14 Jun 2010, 16:15
Location: In front of your hood with one lap late

[DEVELOPPERS]How To use the configuration

Post by farfa »

To use the configuration for your plug-in, it's as simple as saying "hello".
First in your plugin you have to define the configurable property as "static public" like this the configuration Loader will be able to override the default value you set. Here is a sample of what your class looks like if there is only this property

Code: Select all

namespace ManiaLivePlugin\farfa\MyMegaPluginWhichKillEveryThings

class MyMegaPluginWhichKillEveryThings extends \ManiaLive\PluginHandler\Plugin
{
      static property $myConfigurableProperty = 'myDefaultValue';
}
To use this property in your plug-in this is how PHP works

Code: Select all

namespace ManiaLivePlugin\farfa\MyMegaPluginWhichKillEveryThings

class MyMegaPluginWhichKillEveryThings extends \ManiaLive\PluginHandler\Plugin
{
      static property $myConfigurableProperty = 'myDefaultValue';

     function myCrazyMethod()
     {
          //This will display in the console the property value;
          echo self::$myConfigurableProperty;
     }
}
Now if you want to change the default value in you configuration file, here is what you have to add to the config.ini file

Code: Select all

;This is used to load the plugin
plugins.load[] = 'farfa\MyMegaPluginWhichKillEveryThings'
;This is the override of the default value
plugins.farfa\MyMegaPluginWhichKillEveryThings.myConfigurableProperty = 'myOverridingValue'
If the override is correct it should be displayed during the loading of the application.
Also known as: satanasdiabolo
Post Reply

Return to “Dedicated Server Tools”

Who is online

Users browsing this forum: No registered users and 1 guest