Page 1 of 1

Search someone helping me write a new Plugin

Posted: 17 Jan 2015, 21:41
by Mirery
I'm new to eXpansion and i would have to learn a lot of things to create a new Plugin...

Perhaps someone of you feels boring enough to help me...

All i want is a Chat Command if the User use it he will get a reply but it has to be a private message .

Re: Search someone helping me write a new Plugin

Posted: 17 Jan 2015, 22:48
by oliverde8
Hi,
there is a few tutorials written here for plugin making : https://github.com/eXpansionPluginPack/ ... developers
I do recommend you to use an ide such as netbeans/phpstorm you should have auto completion nearly everywhere which should make your task easier. :D
You can also use Manialive tutorials to understand a few things. Our tutorials where written but I never tested the code in them. Feel free to ask any question :D and good look with the devs

Re: Search someone helping me write a new Plugin

Posted: 18 Jan 2015, 13:30
by w1lla
For manialive it can be done like this:

Code: Select all

<?php
namespace ManiaLivePlugins\UserTest\UserTest;

	use ManiaLive\Data\Storage;
	use ManiaLive\Utilities\Console;

class UserTest extends \ManiaLive\PluginHandler\Plugin {

function onInit() {

}

function onLoad() {
$cmd = $this->registerChatCommand('pmme', 'pmme', 0, false);
		$cmd->help = 'PM Myself';
}

function pmme($login) {
$this->connection->chatSendServerMessage('$fff» $fa0Welcome, You got a PM Message!', $login);
}

}
?>
This can be done in ManiaLive, for eXpansion its a bit different but it might work in combination with both i believe.

In config.ini write following:

Code: Select all

 manialive.plugins[] = '\ManiaLivePlugins\UserTest\UserTest'

Re: Search someone helping me write a new Plugin

Posted: 18 Jan 2015, 13:50
by oliverde8
[quote="w1lla"][/quote]
This would work in eXpansion but without autoload and i18n and other eXpansion specific stuff.

Equivalent of this for eXpansion would be :

Code: Select all

<?php
namespace ManiaLivePlugins\UserTest\UserTest;

   use ManiaLive\Data\Storage;
   use ManiaLive\Utilities\Console;

class UserTest extends ManiaLivePlugins\eXpansion\Core\types\BasicPlugin {

function exp_onInit() {
}

function exp_onLoad() {
$cmd = $this->registerChatCommand('pmme', 'pmme', 0, false);
      $cmd->help = 'PM Myself';
}

function pmme($login) {
$this->exp_chatSendServerMessage('$fff» $fa0Welcome, You got a PM Message!', $login);
}

}
?>
and plus you need to define and MetaData file as explained in the first tutorial :)

Re: Search someone helping me write a new Plugin

Posted: 18 Jan 2015, 13:51
by w1lla
Correct. But i did it only basic manialive way tutorial ^^.

Re: Search someone helping me write a new Plugin

Posted: 22 Jan 2015, 19:00
by Mirery
oliverde8 wrote:

Code: Select all

function pmme($login) {
$this->exp_chatSendServerMessage('$fff» $fa0Welcome, You got a PM Message!', $login);
}

This isn't working^^

Do i not need to set this Part to true??? In all other Plugins it is -1 and true not 0 and false... 0 false isn't working. 0 ture is working

Code: Select all

function exp_onLoad() {
$cmd = $this->registerChatCommand('pmme', 'pmme', 0, true);
      $cmd->help = 'PM Myself';
}

Re: Search someone helping me write a new Plugin

Posted: 22 Jan 2015, 19:26
by oliverde8
hi, can you post all your plugin as you test it. And have you activated the plugin?

Re: Search someone helping me write a new Plugin

Posted: 23 Jan 2015, 06:15
by Mirery

Code: Select all

<?php
namespace ManiaLivePlugins\eXpansion\Invite;

   use ManiaLive\Data\Storage;
   use ManiaLive\Utilities\Console;

class Invite extends \ManiaLivePlugins\eXpansion\Core\types\BasicPlugin {

function exp_onInit() {
}

public function exp_onLoad() {
      $cmd = $this->registerChatCommand('invite', 'invite', 0, true);
      $cmd->help = 'PM Myself';
}

function invite($login) {
$zahl = mt_rand();
$this->exp_chatSendServerMessage('$fff» $fa0Welcome your Login is your Accountname and your Password is, ' . $zahl . '' , $login);
}

}
?>
THIS CODE IS THE WORKING CODE!!! But your code was:
$cmd = $this->registerChatCommand('pmme', 'pmme', 0, false);
This was just a smal test and i just want to inform you that your "false" hint was make me crazy for a long time, but then i had have a look into other Plugins and all the registerChatCommands are true there for example your Quiz.php
$command = $this->registerChatCommand("ask", "ask", -1, true);
$command = $this->registerChatCommand("kysy", "ask", -1, true);
$command = $this->registerChatCommand("points", "showPointsWindow", 0, true);
$command = $this->registerChatCommand("pisteet", "showPointsWindow", 0, true);
$command = $this->registerChatCommand("tilanne", "showPoints", 0, true);
$command = $this->registerChatCommand("point", "addPointsWindow", 0, true);
$command = $this->registerChatCommand("piste", "addPointsWindow", 0, true);
$command = $this->registerChatCommand("cancel", "cancel", 0, true);
$command = $this->registerChatCommand("peruuta", "cancel", 0, true);
$command = $this->registerChatCommand("answer", "showAnswer", 0, true);
$command = $this->registerChatCommand("vastaus", "showAnswer", 0, true);
$command = $this->registerChatCommand("question", "showQuestion", 0, true);
$command = $this->registerChatCommand("kysymys", "showQuestion", 0, true);
$command = $this->registerChatCommand("reset", "reset", 0, true);
$command = $this->registerChatCommand("nollaa", "reset", 0, true);
So i also do it and sinsce then my testplugin is working. But what means the 0 and -1? "ask" and "kysy" are -1 and all other 0....

Re: Search someone helping me write a new Plugin

Posted: 23 Jan 2015, 09:28
by oliverde8
Well if you use an idea it will tell you which parameters is what,
For register chat Command :
1 name of the command
2 method to call
3 number of parameters required, 0 means none - 1 infinite
4 should the login of the user of the cmd be sent as a parameter to themethod