2017-03-22 17:57:21 +01:00
|
|
|
<?php
|
2017-03-26 19:44:55 +02:00
|
|
|
|
2017-03-24 22:08:51 +01:00
|
|
|
namespace ManiaControl\Script;
|
2017-03-22 17:57:21 +01:00
|
|
|
|
2017-04-07 18:30:48 +02:00
|
|
|
use ManiaControl\Callbacks\Callbacks;
|
2017-04-16 14:43:13 +02:00
|
|
|
use ManiaControl\Callbacks\Structures\XmlRpc\CallbackListStructure;
|
2017-05-06 15:07:22 +02:00
|
|
|
use ManiaControl\Callbacks\Structures\XmlRpc\DocumentationStructure;
|
|
|
|
use ManiaControl\Callbacks\Structures\XmlRpc\MethodListStructure;
|
2017-03-26 19:44:55 +02:00
|
|
|
use ManiaControl\General\UsageInformationAble;
|
|
|
|
use ManiaControl\General\UsageInformationTrait;
|
2017-05-13 23:05:47 +02:00
|
|
|
use ManiaControl\Logger;
|
2017-03-22 17:57:21 +01:00
|
|
|
use ManiaControl\ManiaControl;
|
2017-05-06 15:07:22 +02:00
|
|
|
use ManiaControl\Players\Player;
|
2017-05-13 23:05:47 +02:00
|
|
|
use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException;
|
2017-03-22 17:57:21 +01:00
|
|
|
|
2017-04-07 17:34:57 +02:00
|
|
|
/**
|
|
|
|
* Manager for Mode Script Events
|
|
|
|
*
|
|
|
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
2018-03-27 20:11:40 +02:00
|
|
|
* @copyright 2014-2018 ManiaControl Team
|
2017-04-07 17:34:57 +02:00
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
|
|
|
*/
|
2017-03-26 19:44:55 +02:00
|
|
|
class ModeScriptEventManager implements UsageInformationAble {
|
|
|
|
use UsageInformationTrait;
|
|
|
|
|
2018-03-27 19:56:09 +02:00
|
|
|
const API_VERSION = "2.5.0";
|
2017-03-23 20:39:32 +01:00
|
|
|
|
2017-03-22 17:57:21 +01:00
|
|
|
/** @var ManiaControl $maniaControl */
|
|
|
|
private $maniaControl;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Construct a new ranking manager instance
|
|
|
|
*
|
|
|
|
* @param ManiaControl $maniaControl
|
|
|
|
*/
|
|
|
|
public function __construct(ManiaControl $maniaControl) {
|
|
|
|
$this->maniaControl = $maniaControl;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enables XmlRpc Callbacks
|
|
|
|
*/
|
|
|
|
public function enableCallbacks() {
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('XmlRpc.EnableCallbacks', array('true'));
|
2017-03-22 18:21:33 +01:00
|
|
|
|
2017-03-23 20:39:32 +01:00
|
|
|
$this->setApiVersion(self::API_VERSION);
|
2017-04-16 14:43:13 +02:00
|
|
|
$this->unBlockAllCallbacks();
|
2017-03-22 17:57:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Disables XmlRpc Callbacks
|
|
|
|
*/
|
|
|
|
public function disableCallbacks() {
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('XmlRpc.EnableCallbacks', array('false'));
|
2017-03-22 17:57:21 +01:00
|
|
|
}
|
2017-03-22 18:21:33 +01:00
|
|
|
|
2017-05-06 15:07:22 +02:00
|
|
|
|
2017-03-22 18:21:33 +01:00
|
|
|
/**
|
2017-03-27 22:45:40 +02:00
|
|
|
* Request a list of all available callbacks. This method will trigger the "XmlRpc.CallbacksList" callback.
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
|
|
|
* @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable()
|
2017-03-22 18:21:33 +01:00
|
|
|
*/
|
2017-04-07 18:30:48 +02:00
|
|
|
public function getCallbacksList() {
|
|
|
|
$responseId = $this->generateResponseId();
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('XmlRpc.GetCallbacksList', array($responseId));
|
2017-04-07 18:30:48 +02:00
|
|
|
return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_CALLBACKSLIST, $responseId);
|
2017-03-22 18:21:33 +01:00
|
|
|
}
|
|
|
|
|
2017-05-06 15:07:22 +02:00
|
|
|
/**
|
|
|
|
* Prints the List of XMLRPC Callbacks in the Console
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
|
|
|
public function printCallbacksList() {
|
|
|
|
$this->getCallbacksList()->setCallable(function (CallbackListStructure $structure) {
|
|
|
|
var_dump($structure->getCallbacks());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-04-07 17:34:57 +02:00
|
|
|
/**
|
|
|
|
* Provide a Array of Callbacks you want to Block
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
2017-04-07 17:34:57 +02:00
|
|
|
* @param array $callbackNames
|
|
|
|
*/
|
|
|
|
public function blockCallbacks($callbackNames) {
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('XmlRpc.BlockCallbacks', $callbackNames);
|
2017-04-07 17:34:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Block a Single Callback
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
2017-04-07 17:34:57 +02:00
|
|
|
* @param $callbackName
|
|
|
|
*/
|
|
|
|
public function blockCallback($callbackName) {
|
|
|
|
$this->blockCallbacks(array($callbackName));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-04-16 14:43:13 +02:00
|
|
|
* UnBlocks All Callbacks
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
|
|
|
public function unBlockAllCallbacks() {
|
|
|
|
$this->getListOfDisabledCallbacks()->setCallable(function (CallbackListStructure $structure) {
|
|
|
|
$this->unBlockCallbacks($structure->getCallbacks());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Provide a Array of Callbacks you want to UnBlock
|
2017-04-07 17:34:57 +02:00
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
2017-04-07 17:34:57 +02:00
|
|
|
* @param array $callbackNames
|
|
|
|
*/
|
|
|
|
public function unBlockCallbacks($callbackNames) {
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('XmlRpc.UnblockCallbacks', $callbackNames);
|
2017-04-07 17:34:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Block a Single Callback
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
2017-04-07 17:34:57 +02:00
|
|
|
* @param $callbackName
|
|
|
|
*/
|
|
|
|
public function unBlockCallback($callbackName) {
|
|
|
|
$this->unBlockCallbacks(array($callbackName));
|
|
|
|
}
|
|
|
|
|
2017-03-27 22:45:40 +02:00
|
|
|
/**
|
|
|
|
* Request a list of all enabled callbacks. This method will trigger the "XmlRpc.CallbacksList_Enabled" callback.
|
|
|
|
*
|
2017-04-07 18:37:36 +02:00
|
|
|
* @api
|
2017-04-07 18:30:48 +02:00
|
|
|
* @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable()
|
2017-03-27 22:45:40 +02:00
|
|
|
*/
|
2017-04-07 18:30:48 +02:00
|
|
|
public function getListOfEnabledCallbacks() {
|
|
|
|
$responseId = $this->generateResponseId();
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('XmlRpc.GetCallbacksList_Enabled', array($responseId));
|
2017-04-07 18:30:48 +02:00
|
|
|
return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_ENABLEDCALLBACKS, $responseId);
|
2017-03-27 22:45:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Request a list of all disabled callbacks. This method will trigger the "XmlRpc.CallbacksList_Enabled" callback.
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
|
|
|
* @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable()
|
2017-03-27 22:45:40 +02:00
|
|
|
*/
|
2017-04-07 18:30:48 +02:00
|
|
|
public function getListOfDisabledCallbacks() {
|
|
|
|
$responseId = $this->generateResponseId();
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('XmlRpc.GetCallbacksList_Disabled', array($responseId));
|
2017-04-07 18:30:48 +02:00
|
|
|
return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_DISABLEDCALLBACKS, $responseId);
|
2017-03-27 22:45:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Description: Request help about a callback. This method will trigger the "XmlRpc.CallbackHelp" callback.
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
2017-03-27 22:45:40 +02:00
|
|
|
* @param $callbackName
|
2017-04-07 18:30:48 +02:00
|
|
|
* @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable()
|
2017-03-27 22:45:40 +02:00
|
|
|
*/
|
2017-04-07 18:30:48 +02:00
|
|
|
public function getCallbackHelp($callbackName) {
|
|
|
|
$responseId = $this->generateResponseId();
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('XmlRpc.GetCallbackHelp', array($callbackName, $responseId));
|
2017-04-07 18:30:48 +02:00
|
|
|
return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_CALLBACKHELP, $responseId);
|
2017-03-27 22:45:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Request a list of all available methods. This method will trigger the "XmlRpc.MethodsList" callback.s
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
|
|
|
* @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable()
|
2017-03-27 22:45:40 +02:00
|
|
|
*/
|
2017-04-07 18:30:48 +02:00
|
|
|
public function getMethodsList() {
|
|
|
|
$responseId = $this->generateResponseId();
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('XmlRpc.GetMethodsList', array($responseId));
|
2017-04-07 18:30:48 +02:00
|
|
|
return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_METHODSLIST, $responseId);
|
2017-03-27 22:45:40 +02:00
|
|
|
}
|
|
|
|
|
2017-05-06 15:07:22 +02:00
|
|
|
/**
|
|
|
|
* Prints the List of XMLRPC Methods in the Console
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
|
|
|
public function printMethodsList() {
|
|
|
|
$this->getMethodsList()->setCallable(function (MethodListStructure $structure) {
|
|
|
|
var_dump($structure->getMethods());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-03-22 18:21:33 +01:00
|
|
|
/**
|
|
|
|
* Sets the Api Version
|
2017-03-26 19:44:55 +02:00
|
|
|
*
|
2017-03-22 18:21:33 +01:00
|
|
|
* @param string $version
|
|
|
|
*/
|
2017-03-26 19:44:55 +02:00
|
|
|
public function setApiVersion($version = self::API_VERSION) {
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('XmlRpc.SetApiVersion', array($version));
|
2017-03-22 18:21:33 +01:00
|
|
|
}
|
|
|
|
|
2017-03-27 22:45:40 +02:00
|
|
|
/**
|
|
|
|
* Gets the Api Version
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
|
|
|
* @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable()
|
2017-03-27 22:45:40 +02:00
|
|
|
*/
|
2017-04-07 18:30:48 +02:00
|
|
|
public function getApiVersion() {
|
|
|
|
$responseId = $this->generateResponseId();
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('XmlRpc.GetApiVersion', array($responseId));
|
2017-04-07 18:30:48 +02:00
|
|
|
return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_APIVERSION, $responseId);
|
2017-03-27 22:45:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Request help about a method. This method will trigger the "XmlRpc.MethodHelp" callback.
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
|
|
|
* @param $methodName
|
|
|
|
* @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable()
|
2017-03-27 22:45:40 +02:00
|
|
|
*/
|
2017-04-07 18:30:48 +02:00
|
|
|
public function getMethodHelp($methodName) {
|
|
|
|
$responseId = $this->generateResponseId();
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('XmlRpc.GetMethodHelp', array($methodName, $responseId));
|
2017-04-07 18:30:48 +02:00
|
|
|
return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_METHODHELP, $responseId);
|
2017-03-27 22:45:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Request the current game mode xmlrpc callbacks and methods documentation. This method will trigger the "XmlRpc.Documentation" callback.
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
|
|
|
* @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable()
|
2017-03-27 22:45:40 +02:00
|
|
|
*/
|
2017-04-07 18:30:48 +02:00
|
|
|
public function getDocumentation() {
|
|
|
|
$responseId = $this->generateResponseId();
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('XmlRpc.GetDocumentation', array($responseId));
|
2017-04-07 18:30:48 +02:00
|
|
|
return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_DOCUMENTATION, $responseId);
|
2017-03-27 22:45:40 +02:00
|
|
|
}
|
|
|
|
|
2017-05-06 15:07:22 +02:00
|
|
|
/**
|
|
|
|
* Printes the XMLRPC Documentation in the Console
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
|
|
|
public function printDocumentation() {
|
|
|
|
$this->getDocumentation()->setCallable(function (DocumentationStructure $structure) {
|
|
|
|
var_dump($structure->getDocumentation());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-03-27 22:45:40 +02:00
|
|
|
/**
|
|
|
|
* Gets a List of All Api Version
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
|
|
|
* @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable()
|
2017-03-27 22:45:40 +02:00
|
|
|
*/
|
2017-04-07 18:30:48 +02:00
|
|
|
public function getAllApiVersions() {
|
|
|
|
$responseId = $this->generateResponseId();
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('XmlRpc.GetAllApiVersions', array($responseId));
|
2017-04-07 18:30:48 +02:00
|
|
|
return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_ALLAPIVERSIONS, $responseId);
|
2017-03-22 18:21:33 +01:00
|
|
|
}
|
2017-03-27 22:45:40 +02:00
|
|
|
|
2017-05-06 15:07:22 +02:00
|
|
|
/**
|
|
|
|
* Hides the Scoreboard on Pressing Alt
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
* @param \ManiaControl\Players\Player $player
|
|
|
|
*/
|
|
|
|
public function hideScoreBoardOnAlt(Player $player) {
|
|
|
|
$login = Player::parseLogin($player);
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Maniaplanet.UI.SetAltScoresTableVisibility', array($login, "False"));
|
2017-05-06 15:07:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays the Scoreboard on Pressing Alt
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
* @param \ManiaControl\Players\Player $player
|
|
|
|
*/
|
|
|
|
public function displayScoreBoardOnAlt(Player $player) {
|
|
|
|
$login = Player::parseLogin($player);
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Maniaplanet.UI.SetAltScoresTableVisibility', array($login, "True"));
|
2018-03-27 19:56:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides the Scoreboard
|
|
|
|
*
|
|
|
|
* @param \ManiaControl\Players\Player $player
|
|
|
|
*/
|
|
|
|
public function hideScoreBoard(Player $player) {
|
|
|
|
$login = Player::parseLogin($player);
|
|
|
|
$this->triggerModeScriptEvent('Maniaplanet.UI.SetScoresTableVisibility', array($login, "False"));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays the Scoreboard
|
|
|
|
*
|
|
|
|
* @param \ManiaControl\Players\Player $player
|
|
|
|
*/
|
|
|
|
public function displayScoreBoard(Player $player) {
|
|
|
|
$login = Player::parseLogin($player);
|
|
|
|
$this->triggerModeScriptEvent('Maniaplanet.UI.SetScoresTableVisibility', array($login, "True"));
|
2017-05-06 15:07:22 +02:00
|
|
|
}
|
2017-04-07 17:34:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Extend the duration of any ongoing warmup.
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
2017-04-13 20:46:23 +02:00
|
|
|
* @param $seconds < the duration of the extension in seconds.
|
2017-04-07 17:34:57 +02:00
|
|
|
*/
|
2017-04-13 20:46:23 +02:00
|
|
|
public function extendManiaPlanetWarmup($seconds) {
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Maniaplanet.WarmUp.Extend', array(strval($seconds * 1000)));
|
2017-04-07 17:34:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stop any ongoing warmup.
|
2017-04-07 18:37:36 +02:00
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
2017-04-07 17:34:57 +02:00
|
|
|
*/
|
|
|
|
public function stopManiaPlanetWarmup() {
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Maniaplanet.WarmUp.Stop');
|
2017-05-15 21:25:16 +02:00
|
|
|
$this->triggerModeScriptEvent('Maniaplanet.WarmUp.ForceStop');
|
2017-04-07 17:34:57 +02:00
|
|
|
}
|
|
|
|
|
2017-04-13 16:12:10 +02:00
|
|
|
/**
|
|
|
|
* Blocks the End of the Warmup,
|
|
|
|
*
|
|
|
|
* @param int $time Timer before the end of the warmup when all players are ready. Use a negative value to prevent the warmup from ending even if all players are ready.
|
|
|
|
*/
|
|
|
|
public function blockEndWarmUp($time = -1) {
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Maniaplanet.WarmUp.BlockEndWarmUp', array("True", strval($time)));
|
2017-04-13 16:12:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Blocks the End of the Warmup,
|
|
|
|
*
|
|
|
|
* @param int $time Timer before the end of the warmup when all players are ready. Use a negative value to prevent the warmup from ending even if all players are ready.
|
|
|
|
*/
|
|
|
|
public function unBlockEndWarmUp($time = -1) {
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Maniaplanet.WarmUp.BlockEndWarmUp', array("False", strval($time)));
|
2017-04-13 16:12:10 +02:00
|
|
|
}
|
|
|
|
|
2017-04-07 17:34:57 +02:00
|
|
|
/**
|
|
|
|
* Get the status of the warmup.
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
|
|
|
* @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable()
|
2017-04-07 17:34:57 +02:00
|
|
|
*/
|
2017-04-07 18:30:48 +02:00
|
|
|
public function getWarmupStatus() {
|
|
|
|
$responseId = $this->generateResponseId();
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Maniaplanet.WarmUp.GetStatus', array($responseId));
|
2017-04-07 18:30:48 +02:00
|
|
|
return new InvokeScriptCallback($this->maniaControl, Callbacks::MP_WARMUP_STATUS, $responseId);
|
2017-04-07 17:34:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the status of the pause.
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
|
|
|
* @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable()
|
2017-04-07 17:34:57 +02:00
|
|
|
*/
|
2017-04-13 16:12:10 +02:00
|
|
|
public function getPauseStatus() {
|
2017-04-07 18:30:48 +02:00
|
|
|
$responseId = $this->generateResponseId();
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Maniaplanet.Pause.GetStatus', array($responseId));
|
2017-04-13 16:12:10 +02:00
|
|
|
return new InvokeScriptCallback($this->maniaControl, Callbacks::MP_PAUSE_STATUS, $responseId);
|
2017-04-07 17:34:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-04-13 16:12:10 +02:00
|
|
|
* Start a Pause and triggers a Callback for the Pause Status
|
2017-04-07 17:34:57 +02:00
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
|
|
|
* @return \ManiaControl\Script\InvokeScriptCallback To get The Pause Status You can directly set a callable on it via setCallable()
|
2017-04-07 17:34:57 +02:00
|
|
|
*/
|
2017-04-13 16:12:10 +02:00
|
|
|
public function startPause() {
|
2017-04-07 18:30:48 +02:00
|
|
|
$responseId = $this->generateResponseId();
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Maniaplanet.Pause.SetActive', array("True", $responseId));
|
2017-04-13 16:12:10 +02:00
|
|
|
return new InvokeScriptCallback($this->maniaControl, Callbacks::MP_PAUSE_STATUS, $responseId);
|
2017-04-07 17:34:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-04-13 16:12:10 +02:00
|
|
|
* End a Pause and triggers a Callback for the Pause Status
|
2017-04-07 17:34:57 +02:00
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
|
|
|
* @return \ManiaControl\Script\InvokeScriptCallback To get The Pause Status You can directly set a callable on it via setCallable()
|
2017-04-07 17:34:57 +02:00
|
|
|
*/
|
2017-04-13 16:12:10 +02:00
|
|
|
public function endPause() {
|
|
|
|
$responseId = $this->generateResponseId();
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Maniaplanet.Pause.SetActive', array("False", $responseId));
|
2017-04-13 16:12:10 +02:00
|
|
|
return new InvokeScriptCallback($this->maniaControl, Callbacks::MP_PAUSE_STATUS, $responseId);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns if the GameMode is a TeamMode or not
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
* @return \ManiaControl\Script\InvokeScriptCallback To get The TeamMode Status You can directly set a callable on it via setCallable()
|
|
|
|
*/
|
|
|
|
public function isTeamMode() {
|
2017-04-07 18:30:48 +02:00
|
|
|
$responseId = $this->generateResponseId();
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Maniaplanet.Mode.GetUseTeams', array($responseId));
|
2017-04-13 16:12:10 +02:00
|
|
|
return new InvokeScriptCallback($this->maniaControl, Callbacks::MP_USES_TEAMMODE, $responseId);
|
2017-04-07 17:34:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Move the spectators' timers UI.
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
2017-04-07 17:34:57 +02:00
|
|
|
* @param $x
|
|
|
|
* @param $y
|
|
|
|
* @param $z
|
|
|
|
*/
|
2017-05-12 19:43:25 +02:00
|
|
|
public function setComboTimerPosition($x, $y, $z) {
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Shootmania.Combo.SetTimersPosition', array(strval(floatval($x)), strval(floatval($y)), strval(floatval($z))));
|
2017-04-07 17:34:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Move the progression UI.
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
2017-04-07 17:34:57 +02:00
|
|
|
* @param $x
|
|
|
|
* @param $y
|
|
|
|
* @param $z
|
|
|
|
*/
|
2017-05-12 19:43:25 +02:00
|
|
|
public function setSiegeProgressionUIPosition($x, $y, $z) {
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Shootmania.Siege.SetProgressionUIPosition', array(strval(floatval($x)), strval(floatval($y)), strval(floatval($z))));
|
2017-04-07 17:34:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-27 22:45:40 +02:00
|
|
|
/**
|
|
|
|
* Request the current scores. This method will trigger the "Shootmania.Scores" callback.
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
|
|
|
* @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable()
|
2017-03-27 22:45:40 +02:00
|
|
|
*/
|
2017-04-07 18:30:48 +02:00
|
|
|
public function getShootmaniaScores() {
|
|
|
|
$responseId = $this->generateResponseId();
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Shootmania.GetScores', array($responseId));
|
2017-04-07 18:30:48 +02:00
|
|
|
return new InvokeScriptCallback($this->maniaControl, Callbacks::SM_SCORES, $responseId);
|
2017-03-27 22:45:40 +02:00
|
|
|
}
|
|
|
|
|
2017-06-21 19:25:58 +02:00
|
|
|
/**
|
|
|
|
* Request the current properties of the AFK libraries.
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
* @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable()
|
|
|
|
*/
|
|
|
|
public function getShootmaniaAFKProperties() {
|
|
|
|
$responseId = $this->generateResponseId();
|
|
|
|
$this->triggerModeScriptEvent(' Shootmania.AFK.GetProperties', array($responseId));
|
|
|
|
return new InvokeScriptCallback($this->maniaControl, Callbacks::SM_AFKPROPERTIES, $responseId);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the properties of the AFK library.
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
* @param int $idleTimeLimit
|
|
|
|
* @param int $spawnTimeLimit
|
|
|
|
* @param int $checkInterval
|
|
|
|
* @param int $forceSpec
|
|
|
|
*/
|
|
|
|
public function setShootmaniaAFKProperties($idleTimeLimit, $spawnTimeLimit, $checkInterval, $forceSpec) {
|
|
|
|
$this->triggerModeScriptEvent('Shootmania.AFK.SetProperties', array(strval($idleTimeLimit), strval($spawnTimeLimit), strval($checkInterval), strval($forceSpec)));
|
|
|
|
}
|
|
|
|
|
2017-03-27 22:45:40 +02:00
|
|
|
/**
|
|
|
|
* Request the current ui properties. This method will trigger the "Shootmania.UIProperties" callback.
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
|
|
|
* @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable()
|
2017-03-27 22:45:40 +02:00
|
|
|
*/
|
2017-04-07 18:30:48 +02:00
|
|
|
public function getShootmaniaUIProperties() {
|
|
|
|
$responseId = $this->generateResponseId();
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Shootmania.UI.GetProperties', array($responseId));
|
2017-04-07 18:30:48 +02:00
|
|
|
return new InvokeScriptCallback($this->maniaControl, Callbacks::SM_UIPROPERTIES, $responseId);
|
2017-03-27 22:45:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the ui properties.
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
2017-03-27 22:45:40 +02:00
|
|
|
* @param string Json-Encoded Xml UI Property String
|
2017-04-21 21:09:21 +02:00
|
|
|
* @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable() to get the updated Properties
|
2017-03-27 22:45:40 +02:00
|
|
|
*/
|
|
|
|
public function setShootmaniaUIProperties($properties) {
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Shootmania.UI.SetProperties', array($properties));
|
2017-04-21 21:09:21 +02:00
|
|
|
return $this->getShootmaniaUIProperties();
|
2017-03-27 22:45:40 +02:00
|
|
|
}
|
2017-03-31 22:39:35 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Request the current scores. This method will trigger the "Trackmania.Scores" callback.
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
|
|
|
* @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable()
|
2017-03-31 22:39:35 +02:00
|
|
|
*/
|
2017-04-07 18:30:48 +02:00
|
|
|
public function getTrackmaniaScores() {
|
|
|
|
$responseId = $this->generateResponseId();
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Trackmania.GetScores', array($responseId));
|
2017-04-07 18:30:48 +02:00
|
|
|
return new InvokeScriptCallback($this->maniaControl, Callbacks::TM_SCORES, $responseId);
|
2017-03-31 22:39:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Request the current points repartition. This method will trigger the "Trackmania.PointsRepartition" callback.
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
|
|
|
* @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable()
|
2017-03-31 22:39:35 +02:00
|
|
|
*/
|
2017-04-07 18:30:48 +02:00
|
|
|
public function getTrackmaniaPointsRepartition() {
|
|
|
|
$responseId = $this->generateResponseId();
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Trackmania.GetPointsRepartition', array($responseId));
|
2017-04-07 18:30:48 +02:00
|
|
|
return new InvokeScriptCallback($this->maniaControl, Callbacks::TM_POINTSREPARTITION, $responseId);
|
2017-03-31 22:39:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the points repartition.
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
2017-03-31 22:39:35 +02:00
|
|
|
* @param array String Array of Points
|
|
|
|
*/
|
|
|
|
public function setTrackmaniaPointsRepartition($pointArray) {
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Trackmania.SetPointsRepartition', $pointArray);
|
2017-03-31 22:39:35 +02:00
|
|
|
}
|
|
|
|
|
2017-05-17 12:18:15 +02:00
|
|
|
/**
|
|
|
|
* Sets the Trackmania Player Points
|
|
|
|
*
|
|
|
|
* @param \ManiaControl\Players\Player $player
|
|
|
|
* @param string|int $roundPoints //< The round points, use an empty string to not update.
|
|
|
|
* @param string|int $mapPoints //< The map points, use an empty string to not update.
|
|
|
|
* @param string|int $matchPoints //< The match points, use an empty string to not update.
|
|
|
|
*/
|
|
|
|
public function setTrackmaniaPlayerPoints(Player $player, $roundPoints = "", $mapPoints = "", $matchPoints = "") {
|
|
|
|
$login = Player::parseLogin($player);
|
|
|
|
$this->triggerModeScriptEvent('Trackmania.SetPlayerPoints', array($login, strval($roundPoints), strval($mapPoints), strval($matchPoints)));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the Trackmania Team Points
|
|
|
|
*
|
|
|
|
* @param int $teamId //< Id of the team t. Can be 1 or 2.
|
|
|
|
* @param string|int $roundPoints
|
|
|
|
* @param string|int $mapPoints
|
|
|
|
* @param string|int $matchPoints
|
|
|
|
*/
|
|
|
|
public function setTrackmaniaTeamPoints($teamId, $roundPoints = "", $mapPoints = "", $matchPoints = "") {
|
|
|
|
$this->triggerModeScriptEvent('Trackmania.SetTeamPoints', array(strval($teamId), strval($roundPoints), strval($mapPoints), strval($matchPoints)));
|
|
|
|
}
|
|
|
|
|
2017-03-31 22:39:35 +02:00
|
|
|
/**
|
|
|
|
* Request the current ui properties. This method will trigger the "Shootmania.UIProperties" callback.
|
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
|
|
|
* @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable()
|
2017-03-31 22:39:35 +02:00
|
|
|
*/
|
2017-04-07 18:30:48 +02:00
|
|
|
public function getTrackmaniaUIProperties() {
|
|
|
|
$responseId = $this->generateResponseId();
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Trackmania.UI.GetProperties', array($responseId));
|
2017-05-08 20:26:28 +02:00
|
|
|
return new InvokeScriptCallback($this->maniaControl, Callbacks::TM_UIPROPERTIES, $responseId);
|
2017-03-31 22:39:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the ui properties.
|
2017-04-07 18:37:36 +02:00
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
2017-03-31 22:39:35 +02:00
|
|
|
* @param string Json-Encoded Xml UI Property String
|
2017-04-21 21:09:21 +02:00
|
|
|
* @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable() to get the updated Properties
|
2017-03-31 22:39:35 +02:00
|
|
|
*/
|
|
|
|
public function setTrackmaniaUIProperties($properties) {
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Trackmania.UI.SetProperties', array($properties));
|
2017-04-21 21:09:21 +02:00
|
|
|
return $this->getTrackmaniaUIProperties();
|
2017-03-31 22:39:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stop the whole warm up sequence.
|
2017-04-07 18:37:36 +02:00
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
2017-03-31 22:39:35 +02:00
|
|
|
*/
|
|
|
|
public function stopTrackmaniaWarmup() {
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Trackmania.WarmUp.Stop');
|
2017-03-31 22:39:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stop the current warm up round.
|
2017-04-07 18:37:36 +02:00
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
2017-03-31 22:39:35 +02:00
|
|
|
*/
|
|
|
|
public function stopTrackmaniaRound() {
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Trackmania.WarmUp.StopRound');
|
2017-03-31 22:39:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stop the current round. Only available in Cup, Rounds and Team modes.
|
2017-04-07 18:37:36 +02:00
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @api
|
2017-03-31 22:39:35 +02:00
|
|
|
*/
|
|
|
|
public function forceTrackmaniaRoundEnd() {
|
2017-05-13 23:05:47 +02:00
|
|
|
$this->triggerModeScriptEvent('Trackmania.ForceEndRound');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Triggers a ModeScript Event
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
* @param $eventName
|
2017-05-17 13:48:41 +02:00
|
|
|
* @param array $data
|
2017-05-13 23:05:47 +02:00
|
|
|
*/
|
2017-05-17 13:48:41 +02:00
|
|
|
public function triggerModeScriptEvent($eventName, $data = array()) {
|
2017-05-14 09:25:52 +02:00
|
|
|
$this->maniaControl->getClient()->triggerModeScriptEvent($eventName, $data, function ($exception) use ($eventName) {
|
|
|
|
if ($exception instanceof GameModeException) {
|
|
|
|
if ($exception->getMessage() != 'Not in script mode.') {
|
|
|
|
throw $exception;
|
|
|
|
}
|
|
|
|
Logger::logWarning($eventName . " can't be triggered because you are not in Scriptmode, start your server in Scriptmode!");
|
2017-05-13 23:05:47 +02:00
|
|
|
}
|
2017-05-14 09:25:52 +02:00
|
|
|
});
|
2017-03-31 22:39:35 +02:00
|
|
|
}
|
2017-04-07 18:30:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates the needed Unique ResponseId
|
2017-04-07 18:37:36 +02:00
|
|
|
*
|
2017-04-07 18:30:48 +02:00
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function generateResponseId() {
|
|
|
|
return uniqid("ManiaControl.");
|
|
|
|
}
|
2017-03-22 17:57:21 +01:00
|
|
|
}
|