Page 1 of 2

Sound Events Manager - help thread

Posted: 11 Jan 2015, 12:48
by Lumpik
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.

Re: Sound Events Manager - help wanted

Posted: 12 Jan 2015, 21:56
by Lumpik
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) !

Re: Sound Events Manager - help wanted

Posted: 14 Jan 2015, 21:20
by Lumpik
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.

Re: Sound Events Manager - help wanted

Posted: 14 Jan 2015, 22:04
by steeffeen
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

Re: Sound Events Manager - help wanted

Posted: 14 Jan 2015, 23:38
by Lumpik
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 ?

Re: Sound Events Manager - help wanted

Posted: 15 Jan 2015, 10:48
by steeffeen
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