Sound Events Manager - help thread

ManiaControl, the completely new designed and easy to use controller managing all your Maniaplanet server.

Moderators: kremsy, Jocy, Wabbitface, steeffeen, NADEO

User avatar
Lumpik
Posts: 41
Joined: 04 Jan 2015, 22:00
Contact:

Sound Events Manager - help thread

Post by Lumpik » 11 Jan 2015, 12:48

Hello everybody,

i'm trying to code a multi-mode plugin to play sounds on triggers, such as beginning of round, kills, etc...
The main mode is SpeedBall but i can test on Siege or Elite if needed.

My main problem is the lake of documentation and explanation so i'm asking for help.
I've read many documentation but none can explain me the interactions between ShootMania, ManiaControl, Mode scripts and Plugin Script.

So, here's my 1st problem :
I'm catching a "LibXmlRpc_OnArmorEmpty" callback on my handleCallbacks() function but i can't get informations from this callback (shooter, victim, etc...).
A summary of my code :

Code: Select all

public function load(ManiaControl $maniaControl) {
	$this->maniaControl = $maniaControl;
	//Register callbacks
	$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_MODESCRIPTCALLBACK, $this, 'handleCallbacks');
	$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_MODESCRIPTCALLBACKARRAY, $this, 'handleCallbacks');
}

public function handleCallbacks(array $callback) {
	$callbackName = $callback[1][0];
	switch($callbackName) {
	case 'LibXmlRpc_OnArmorEmpty':
		$data = $callback[1][1];
		$info=json_decode($data, true);
		$this->LibXmlRpc_OnArmorEmpty($info);
	break;
	}
}
It's mainly a copy/paste from the EliteX plugin by Sen-sai so it should work.
You can download the full code of my plugin here : http://maniacontrol.com/plugins/70

1) In my LibXmlRpc_OnArmorEmpty() function, how could i get informations from my $callback ?
2) What kind of object is $info ?
3) Which function returns $callback ? The SpeedBall main script ?
4) Why do i get a "LibXmlRpc_OnArmorEmpty" callback while EliteX plugin (for example) get a "OnArmorEmpty" callback ? Does it depend on the mode ?

I've tried many ways to display information but none works...

​Could you help me please ?
I can join a TS server and try to speak English if it would ​be easier.

Thanks.
Last edited by Lumpik on 03 Feb 2015, 17:50, edited 1 time in total.

kremsy
Posts: 1725
Joined: 21 Jul 2011, 09:51

Re: Sound Events Manager - help wanted

Post by kremsy » 11 Jan 2015, 15:42

If you switch the Channel of Mania-Control to nightly, there is a newer and easier solution possible now (will release it today or tomorrow as beta).

Code: Select all

	
		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ONARMOREMPTY, $this, 'onArmorEmpty');


public function onArmorEmpty(ArmorEmptyStructure $structure) {
		//$victim = $structure->getVictim() returns player object of victim, other properties are all in the structure
	}
You can use all available Properties with using the ArmorEmptyStructure.

Code: Select all

	
private $shooter;
private $victim;
private $damage;
private $shooterPoints;
private $weapon;
//All this properties have getter Methods
The same thing exists for other Callbacks as well.
Lukas alias Kremsy, Developer of:
ManiaControl: http://www.maniacontrol.com
ParagonLeague: http://league.paragon-esports.com
MPAseco: http://mpaseco.org
ManiaViewer: http://www.maniaviewer.com

kremsy
Posts: 1725
Joined: 21 Jul 2011, 09:51

Re: Sound Events Manager - help wanted

Post by kremsy » 11 Jan 2015, 16:37

Released new ManiaControl Beta version including the new Callback Structures!
Lukas alias Kremsy, Developer of:
ManiaControl: http://www.maniacontrol.com
ParagonLeague: http://league.paragon-esports.com
MPAseco: http://mpaseco.org
ManiaViewer: http://www.maniaviewer.com

User avatar
Lumpik
Posts: 41
Joined: 04 Jan 2015, 22:00
Contact:

Re: Sound Events Manager - help wanted

Post by Lumpik » 12 Jan 2015, 21:56

Thank you Kremzy ! :D
I've just tested and it works fine !

Just some precisions, maybe for nubbies but :
1) we have to declare the Structures :

Code: Select all

use ManiaControl\Callbacks\Structures\ArmorEmptyStructure;
use ManiaControl\Callbacks\Structures\NearMissStructure;
use ManiaControl\Callbacks\Structures\CaptureStructure;
use ManiaControl\Callbacks\Structures\PlayerHitStructure;
2) "shooter" and "victim" are Player objets so we have to use this to get the login :

Code: Select all

$structure->getShooter()->login
It seems you added some other callbacks, like OnHit, OnNearMiss, etc...
For those who wants to use them : https://github.com/ManiaControl/ManiaCo ... lbacks.php

Kremsy, have you updated the documentation ?
I'm talking about this link : http://docs.maniacontrol.com/classes/Ma ... backs.html
If not, i hope you will (if you can) ;)

I'll code a little more my plugin and i'll be back when i'll need to play a custom sound.
I hope it's easy to do (but it doesn't looks like) !

kremsy
Posts: 1725
Joined: 21 Jul 2011, 09:51

Re: Sound Events Manager - help wanted

Post by kremsy » 12 Jan 2015, 22:27

Will try to generate a new version of the docs. About sounds, it is really easy, just use the FML.
Lukas alias Kremsy, Developer of:
ManiaControl: http://www.maniacontrol.com
ParagonLeague: http://league.paragon-esports.com
MPAseco: http://mpaseco.org
ManiaViewer: http://www.maniaviewer.com

User avatar
Lumpik
Posts: 41
Joined: 04 Jan 2015, 22:00
Contact:

Re: Sound Events Manager - help wanted

Post by Lumpik » 14 Jan 2015, 21:20

I've implemented the audio.php example from FML (https://github.com/steeffeen/FancyMania ... /audio.php) in my plugin, in onRequestRespawn() function, but i get this error :

Code: Select all

[14-Jan-2015 19:45:39 UTC] [PHP WARNING]: Cannot modify header information - headers already sent by (output started at /srv/shootmania/newspeedball/maniacontrol/core/Logger.php:108)
File&Line: /srv/shootmania/newspeedball/maniacontrol/libs/FML/ManiaLink.php: 314
Trace:
#0: header(string(Content-Type: application/xml; charset=u..)) in File libs/FML/ManiaLink.php on Line 314
#1: FML\ManiaLink->render(boolean(1)) in File plugins/Lumpik/SoundEventsManager.php on Line 305
#2: Lumpik\SoundEventsManager->onRequestRespawn(object(ManiaControl\Players\Player))
#3: call_user_func_array(array(object(Lumpik\SoundEventsManager), string(onRequestRespawn)), array(object(ManiaControl\Players\Player))) in File core/Callbacks/Listening.php on Line 62
#4: ManiaControl\Callbacks\Listening->triggerCallbackWithParams(array(object(ManiaControl\Players\Player))) in File core/Callbacks/CallbackManager.php on Line 285
#5: ManiaControl\Callbacks\CallbackManager->triggerCallback(string(Callbacks.OnPlayerRequestRespawn), object(ManiaControl\Players\Player)) in File core/Callbacks/LibXmlRpcCallbacks.php on Line 147
#6: ManiaControl\Callbacks\LibXmlRpcCallbacks->handleScriptCallback(string(LibXmlRpc_OnPlayerRequestRespawn), array(string(skapik)))
#7: call_user_func_array(array(object(ManiaControl\Callbacks\LibXmlRpcCallbacks), string(handleScriptCallback)), array(string(LibXmlRpc_OnPlayerRequestRespawn)array(string(skapik)))...) in File core/Callbacks/Listening.php on Line 62
#8: ManiaControl\Callbacks\Listening->triggerCallbackWithParams(array(string(LibXmlRpc_OnPlayerRequestRespawn)array(string(skapik)))) in File core/Callbacks/CallbackManager.php on Line 285
#9: ManiaControl\Callbacks\CallbackManager->triggerCallback(string(Callbacks.ScriptCallback), string(LibXmlRpc_OnPlayerRequestRespawn), array(string(skapik))) in File core/Callbacks/CallbackManager.php on Line 298
#10: ManiaControl\Callbacks\CallbackManager->handleScriptCallback(array(string(ManiaPlanet.ModeScriptCallbackArray), array(string(LibXmlRpc_OnPlayerRequestRespawn), array(string(skapik))))) in File core/Callbacks/CallbackManager.php on Line 254
#11: ManiaControl\Callbacks\CallbackManager->handleCallback(array(string(ManiaPlanet.ModeScriptCallbackArray), array(string(LibXmlRpc_OnPlayerRequestRespawn), array(string(skapik))))) in File core/Callbacks/CallbackManager.php on Line 223
#12: ManiaControl\Callbacks\CallbackManager->manageCallbacks() in File core/ManiaControl.php on Line 628
#13: ManiaControl\ManiaControl->loop() in File core/ManiaControl.php on Line 541
#14: ManiaControl\ManiaControl->run() in File ManiaControl.php on Line 47
Could you tell me what's wrong ?

Full source of my plugin is available in http://www.maniacontrol.com/plugins/70, v0.2.
Last edited by Lumpik on 14 Jan 2015, 22:27, edited 1 time in total.

User avatar
steeffeen
Translator
Translator
Posts: 2472
Joined: 14 Oct 2012, 16:22
Location: Germany

Re: Sound Events Manager - help wanted

Post by steeffeen » 14 Jan 2015, 22:04

the audio example is for a manialink that outputs the XML via echo
but a server controller doesn't print the xml
so:

Code: Select all

$maniaLink->render(true);
doesn't make sense and is causing the issue
you need to send the manialink to the players instead
    Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

    ManiaControl, FancyManiaLinks

    User avatar
    Lumpik
    Posts: 41
    Joined: 04 Jan 2015, 22:00
    Contact:

    Re: Sound Events Manager - help wanted

    Post by Lumpik » 14 Jan 2015, 23:38

    That works !!
    Thank you steeffeen :D

    Next questions will be for steeffeen, as it's SpeedBall specific :
    1) Is there a callback/something for passes ? I've seen you're using SBXmlRpc::OnPass(_Event) in your SB script but i don't know how to get it in my plugin. Is it possible ? How ?
    2) Is there a callback/something for phases (normal/reduction/instant) ? Any other way to get the actual phase or the phase change ?

    User avatar
    steeffeen
    Translator
    Translator
    Posts: 2472
    Joined: 14 Oct 2012, 16:22
    Location: Germany

    Re: Sound Events Manager - help wanted

    Post by steeffeen » 15 Jan 2015, 10:48

    1) you simply register for the callback "SpeedBall_OnPass" which is sent by the method SBXmlRpc::OnPass()
    2) there is no such thing currently and i can't think of a good way to find out the phase
    maybe calculate the phase based on the lapsed time xP
      Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

      ManiaControl, FancyManiaLinks

      kremsy
      Posts: 1725
      Joined: 21 Jul 2011, 09:51

      Re: Sound Events Manager - help wanted

      Post by kremsy » 15 Jan 2015, 10:58

      steeffeen wrote:1) you simply register for the callback "SpeedBall_OnPass" which is sent by the method SBXmlRpc::OnPass()
      2) there is no such thing currently and i can't think of a good way to find out the phase
      maybe calculate the phase based on the lapsed time xP
      To Register the Callback you can do it the following way:

      Code: Select all

      $this->maniaControl->getCallbackManager()->registerScriptCallbackListener("SpeedBall_OnPass", $this, "yourMethodName");
      And please set your ManiaControl to the development Mode.
      Lukas alias Kremsy, Developer of:
      ManiaControl: http://www.maniacontrol.com
      ParagonLeague: http://league.paragon-esports.com
      MPAseco: http://mpaseco.org
      ManiaViewer: http://www.maniaviewer.com

      Post Reply

      Return to “ManiaControl”

      Who is online

      Users browsing this forum: No registered users and 1 guest