custom plugin events and working sqlite explorer
Posted: 04 Jan 2011, 02:40
Custom plugin events ?
Well i managed to to this tonight after 3~4 hours of trial & error, as i'm totally noob with this new object orientated programming thingy. hopefully we get official support for plugin events for final version of manialive, as this can be ground breaking
for example i did a custom event for onCopperDonation...
you need to do new event class onCopperDonate.php
it has the class as following:
at CopperDonate.php you add this new class
and at the point, when you want the event to happen, command
Then to the plugins where you want the event to happen...
Sqlite Browser for sqlite 2.1
The program version must be this 1.1, which is ancient, but it is freeware and works with manialive database.
http://mesh.dl.sourceforge.net/project/ ... .1-win.zip
now go, make new plugins,
-- Reaby
Well i managed to to this tonight after 3~4 hours of trial & error, as i'm totally noob with this new object orientated programming thingy. hopefully we get official support for plugin events for final version of manialive, as this can be ground breaking

for example i did a custom event for onCopperDonation...
you need to do new event class onCopperDonate.php
it has the class as following:
Code: Select all
namespace [define the namespace here for autoload]
class onCopperDonate extends \ManiaLive\Event\Event
{
protected $login;
protected $amount;
function __construct($login, $amount)
{
$this->login = $login;
$this->amount = $amount;
}
function fireDo($listener)
{
call_user_func_array(array($listener, 'onCopperDonate'), array($this->login, $this->amount));
}
}
at CopperDonate.php you add this new class
Code: Select all
use ManiaLive\Event\Dispatcher;
use ManiaLivePlugins\MLEPP\DonateCoppers\Events\onCopperDonate;
Code: Select all
Dispatcher::dispatch(new onCopperDonate($login,$amount));
Code: Select all
use ManiaLive\Event\Dispatcher;
function onInit() {
if ($this->isPluginLoaded('MLEPP\DonateCoppers', 0.1)) {
Dispatcher::register(\ManiaLivePlugins\MLEPP\DonateCoppers\Events\onCopperDonate::getClass(), $this);
}
}
function onCopperDonate($login, $amount) {
$this->sendChat("Hahaha, plugin interaction, and so $login gives $amount of coppers!");
}
Sqlite Browser for sqlite 2.1
The program version must be this 1.1, which is ancient, but it is freeware and works with manialive database.
http://mesh.dl.sourceforge.net/project/ ... .1-win.zip
now go, make new plugins,
-- Reaby