small fix
This commit is contained in:
parent
0db776a2e5
commit
6a1a014696
@ -63,12 +63,12 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Script Settings' AUTO_INCREMENT=1;";
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Script Settings' AUTO_INCREMENT=1;";
|
||||||
|
|
||||||
$statement = $mysqli->prepare($query);
|
$statement = $mysqli->prepare($query);
|
||||||
if($mysqli->error) {
|
if ($mysqli->error) {
|
||||||
trigger_error($mysqli->error, E_USER_ERROR);
|
trigger_error($mysqli->error, E_USER_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
if($statement->error) {
|
if ($statement->error) {
|
||||||
trigger_error($statement->error, E_USER_ERROR);
|
trigger_error($statement->error, E_USER_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -93,8 +93,8 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
public function loadSettingsFromDatabase() {
|
public function loadSettingsFromDatabase() {
|
||||||
$scriptSettings = (array)$this->maniaControl->client->getModeScriptSettings();
|
$scriptSettings = (array)$this->maniaControl->client->getModeScriptSettings();
|
||||||
|
|
||||||
if(isset($scriptSettings['faultString'])) {
|
if (isset($scriptSettings['faultString'])) {
|
||||||
if($scriptSettings['faultString'] == 'Not in script mode.') {
|
if ($scriptSettings['faultString'] == 'Not in script mode.') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
trigger_error('Error occured: ' . $scriptSettings['faultString']);
|
trigger_error('Error occured: ' . $scriptSettings['faultString']);
|
||||||
@ -105,21 +105,21 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
$serverId = $this->maniaControl->server->index;
|
$serverId = $this->maniaControl->server->index;
|
||||||
$query = "SELECT * FROM `" . self::TABLE_SCRIPT_SETTINGS . "` WHERE serverIndex = " . $serverId . ";";
|
$query = "SELECT * FROM `" . self::TABLE_SCRIPT_SETTINGS . "` WHERE serverIndex = " . $serverId . ";";
|
||||||
$result = $mysqli->query($query);
|
$result = $mysqli->query($query);
|
||||||
if($mysqli->error) {
|
if ($mysqli->error) {
|
||||||
trigger_error($mysqli->error);
|
trigger_error($mysqli->error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$loadedSettings = array();
|
$loadedSettings = array();
|
||||||
while($row = $result->fetch_object()) {
|
while($row = $result->fetch_object()) {
|
||||||
if(!isset($scriptSettings[$row->settingName])) {
|
if (!isset($scriptSettings[$row->settingName])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$loadedSettings[$row->settingName] = $row->settingValue;
|
$loadedSettings[$row->settingName] = $row->settingValue;
|
||||||
settype($loadedSettings[$row->settingName], gettype($scriptSettings[$row->settingName]));
|
settype($loadedSettings[$row->settingName], gettype($scriptSettings[$row->settingName]));
|
||||||
}
|
}
|
||||||
$result->close();
|
$result->close();
|
||||||
if(!$loadedSettings) {
|
if (!$loadedSettings) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +133,6 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle()
|
* @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle()
|
||||||
*/
|
*/
|
||||||
public function getTitle() {
|
public function getTitle() {
|
||||||
@ -141,7 +140,6 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu()
|
* @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu()
|
||||||
*/
|
*/
|
||||||
public function getMenu($width, $height, Script $script) {
|
public function getMenu($width, $height, Script $script) {
|
||||||
@ -202,14 +200,14 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
/** @var \Maniaplanet\DedicatedServer\Structures\ScriptSettings $scriptParam */
|
/** @var \Maniaplanet\DedicatedServer\Structures\ScriptSettings $scriptParam */
|
||||||
$settingName = $scriptParam->name;
|
$settingName = $scriptParam->name;
|
||||||
|
|
||||||
if(!isset($scriptSettings[$settingName])) {
|
if (!isset($scriptSettings[$settingName])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($pageFrame)) {
|
if (!isset($pageFrame)) {
|
||||||
$pageFrame = new Frame();
|
$pageFrame = new Frame();
|
||||||
$frame->add($pageFrame);
|
$frame->add($pageFrame);
|
||||||
if(!empty($pageFrames)) {
|
if (!empty($pageFrames)) {
|
||||||
$pageFrame->setVisible(false);
|
$pageFrame->setVisible(false);
|
||||||
}
|
}
|
||||||
array_push($pageFrames, $pageFrame);
|
array_push($pageFrames, $pageFrame);
|
||||||
@ -233,13 +231,13 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
$settingValue = $scriptSettings[$settingName];
|
$settingValue = $scriptSettings[$settingName];
|
||||||
|
|
||||||
$substyle = '';
|
$substyle = '';
|
||||||
if($settingValue === false) {
|
if ($settingValue === false) {
|
||||||
$substyle = Quad_Icons64x64_1::SUBSTYLE_LvlRed;
|
$substyle = Quad_Icons64x64_1::SUBSTYLE_LvlRed;
|
||||||
} else if($settingValue === true) {
|
} else if ($settingValue === true) {
|
||||||
$substyle = Quad_Icons64x64_1::SUBSTYLE_LvlGreen;
|
$substyle = Quad_Icons64x64_1::SUBSTYLE_LvlGreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($substyle != '') {
|
if ($substyle != '') {
|
||||||
$quad = new Quad_Icons64x64_1();
|
$quad = new Quad_Icons64x64_1();
|
||||||
$settingFrame->add($quad);
|
$settingFrame->add($quad);
|
||||||
$quad->setX($width / 2 * 0.545);
|
$quad->setX($width / 2 * 0.545);
|
||||||
@ -271,7 +269,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
$script->addTooltip($nameLabel, $descriptionLabel);
|
$script->addTooltip($nameLabel, $descriptionLabel);
|
||||||
|
|
||||||
$y -= $settingHeight;
|
$y -= $settingHeight;
|
||||||
if($index % $pageMaxCount == $pageMaxCount - 1) {
|
if ($index % $pageMaxCount == $pageMaxCount - 1) {
|
||||||
unset($pageFrame);
|
unset($pageFrame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -280,13 +278,12 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see \ManiaControl\Configurators\ConfiguratorMenu::saveConfigData()
|
* @see \ManiaControl\Configurators\ConfiguratorMenu::saveConfigData()
|
||||||
*/
|
*/
|
||||||
public function saveConfigData(array $configData, Player $player) {
|
public function saveConfigData(array $configData, Player $player) {
|
||||||
|
|
||||||
$prefix = explode(".", $configData[3][0]['Name']);
|
$prefix = explode(".", $configData[3][0]['Name']);
|
||||||
if($prefix[0] != self::ACTION_PREFIX_SETTING) {
|
if ($prefix[0] != self::ACTION_PREFIX_SETTING) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,12 +296,12 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
|
|
||||||
|
|
||||||
$settingName = substr($setting['Name'], $prefixLength + 1);
|
$settingName = substr($setting['Name'], $prefixLength + 1);
|
||||||
if(!isset($scriptSettings[$settingName])) {
|
if (!isset($scriptSettings[$settingName])) {
|
||||||
var_dump('no setting ' . $settingName);
|
var_dump('no setting ' . $settingName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($setting['Value'] == $scriptSettings[$settingName]) {
|
if ($setting['Value'] == $scriptSettings[$settingName]) {
|
||||||
// Not changed
|
// Not changed
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -328,7 +325,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
public function handleManialinkPageAnswer(array $callback) {
|
public function handleManialinkPageAnswer(array $callback) {
|
||||||
$actionId = $callback[1][2];
|
$actionId = $callback[1][2];
|
||||||
$boolSetting = (strpos($actionId, self::ACTION_SETTING_BOOL) === 0);
|
$boolSetting = (strpos($actionId, self::ACTION_SETTING_BOOL) === 0);
|
||||||
if(!$boolSetting) {
|
if (!$boolSetting) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,7 +350,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
*/
|
*/
|
||||||
public function toggleBooleanSetting($setting, Player $player) {
|
public function toggleBooleanSetting($setting, Player $player) {
|
||||||
$scriptSettings = $this->maniaControl->client->getModeScriptSettings();
|
$scriptSettings = $this->maniaControl->client->getModeScriptSettings();
|
||||||
if(!isset($scriptSettings[$setting])) {
|
if (!isset($scriptSettings[$setting])) {
|
||||||
var_dump('no setting ' . $setting);
|
var_dump('no setting ' . $setting);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -372,12 +369,12 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
* @param bool
|
* @param bool
|
||||||
*/
|
*/
|
||||||
private function applyNewScriptSettings(array $newSettings, Player $player) {
|
private function applyNewScriptSettings(array $newSettings, Player $player) {
|
||||||
if(!$newSettings) {
|
if (!$newSettings) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$success = $this->maniaControl->client->setModeScriptSettings($newSettings);
|
$this->maniaControl->client->setModeScriptSettings($newSettings);
|
||||||
} catch(\Exception $e) {
|
} catch(\Exception $e) {
|
||||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||||
return false;
|
return false;
|
||||||
@ -394,7 +391,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
) ON DUPLICATE KEY UPDATE
|
) ON DUPLICATE KEY UPDATE
|
||||||
`settingValue` = VALUES(`settingValue`);";
|
`settingValue` = VALUES(`settingValue`);";
|
||||||
$statement = $mysqli->prepare($query);
|
$statement = $mysqli->prepare($query);
|
||||||
if($mysqli->error) {
|
if ($mysqli->error) {
|
||||||
trigger_error($mysqli->error);
|
trigger_error($mysqli->error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -408,14 +405,14 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
$chatMessage .= '$<' . '$fff' . preg_replace('/^S_/', '', $setting) . '$z$s$ff0 ';
|
$chatMessage .= '$<' . '$fff' . preg_replace('/^S_/', '', $setting) . '$z$s$ff0 ';
|
||||||
$chatMessage .= 'to $fff' . $this->parseSettingValue($value) . '$>';
|
$chatMessage .= 'to $fff' . $this->parseSettingValue($value) . '$>';
|
||||||
|
|
||||||
if($settingIndex <= $settingsCount - 2) {
|
if ($settingIndex <= $settingsCount - 2) {
|
||||||
$chatMessage .= ', ';
|
$chatMessage .= ', ';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add To Database
|
// Add To Database
|
||||||
$statement->bind_param('iss', $this->maniaControl->server->index, $setting, $value);
|
$statement->bind_param('iss', $this->maniaControl->server->index, $setting, $value);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
if($statement->error) {
|
if ($statement->error) {
|
||||||
trigger_error($statement->error);
|
trigger_error($statement->error);
|
||||||
$statement->close();
|
$statement->close();
|
||||||
return false;
|
return false;
|
||||||
@ -443,7 +440,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function parseSettingValue($value) {
|
private function parseSettingValue($value) {
|
||||||
if(is_bool($value)) {
|
if (is_bool($value)) {
|
||||||
return ($value ? 'True' : 'False');
|
return ($value ? 'True' : 'False');
|
||||||
}
|
}
|
||||||
return (string)$value;
|
return (string)$value;
|
||||||
|
@ -63,12 +63,12 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
UNIQUE KEY `setting` (`serverIndex`, `settingName`)
|
UNIQUE KEY `setting` (`serverIndex`, `settingName`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Server Settings' AUTO_INCREMENT=1;";
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Server Settings' AUTO_INCREMENT=1;";
|
||||||
$statement = $mysqli->prepare($query);
|
$statement = $mysqli->prepare($query);
|
||||||
if($mysqli->error) {
|
if ($mysqli->error) {
|
||||||
trigger_error($mysqli->error, E_USER_ERROR);
|
trigger_error($mysqli->error, E_USER_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
if($statement->error) {
|
if ($statement->error) {
|
||||||
trigger_error($statement->error, E_USER_ERROR);
|
trigger_error($statement->error, E_USER_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -95,13 +95,13 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
$mysqli = $this->maniaControl->database->mysqli;
|
$mysqli = $this->maniaControl->database->mysqli;
|
||||||
$query = "SELECT * FROM `" . self::TABLE_SERVER_SETTINGS . "` WHERE serverIndex = " . $serverId . ";";
|
$query = "SELECT * FROM `" . self::TABLE_SERVER_SETTINGS . "` WHERE serverIndex = " . $serverId . ";";
|
||||||
$result = $mysqli->query($query);
|
$result = $mysqli->query($query);
|
||||||
if($mysqli->error) {
|
if ($mysqli->error) {
|
||||||
trigger_error($mysqli->error);
|
trigger_error($mysqli->error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$serverSettings = $this->maniaControl->client->getServerOptions()->toArray();
|
$serverSettings = $this->maniaControl->client->getServerOptions()->toArray();
|
||||||
while($row = $result->fetch_object()) {
|
while($row = $result->fetch_object()) {
|
||||||
if(!isset($serverSettings[$row->settingName])) {
|
if (!isset($serverSettings[$row->settingName])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$oldType = gettype($serverSettings[$row->settingName]);
|
$oldType = gettype($serverSettings[$row->settingName]);
|
||||||
@ -109,7 +109,7 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
settype($serverSettings[$row->settingName], $oldType);
|
settype($serverSettings[$row->settingName], $oldType);
|
||||||
}
|
}
|
||||||
$result->close();
|
$result->close();
|
||||||
if(!$serverSettings) {
|
if (!$serverSettings) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +123,6 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle()
|
* @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle()
|
||||||
*/
|
*/
|
||||||
public function getTitle() {
|
public function getTitle() {
|
||||||
@ -131,7 +130,6 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu()
|
* @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu()
|
||||||
*/
|
*/
|
||||||
public function getMenu($width, $height, Script $script) {
|
public function getMenu($width, $height, Script $script) {
|
||||||
@ -178,14 +176,14 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
foreach($serverSettings as $name => $value) {
|
foreach($serverSettings as $name => $value) {
|
||||||
// Continue on CurrentMaxPlayers...
|
// Continue on CurrentMaxPlayers...
|
||||||
$pos = strpos($name, "Current"); // TODO maybe current irgentwo anzeigen
|
$pos = strpos($name, "Current"); // TODO maybe current irgentwo anzeigen
|
||||||
if($pos !== false) {
|
if ($pos !== false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($pageFrame)) {
|
if (!isset($pageFrame)) {
|
||||||
$pageFrame = new Frame();
|
$pageFrame = new Frame();
|
||||||
$frame->add($pageFrame);
|
$frame->add($pageFrame);
|
||||||
if(!empty($pageFrames)) {
|
if (!empty($pageFrames)) {
|
||||||
$pageFrame->setVisible(false);
|
$pageFrame->setVisible(false);
|
||||||
}
|
}
|
||||||
array_push($pageFrames, $pageFrame);
|
array_push($pageFrames, $pageFrame);
|
||||||
@ -208,9 +206,9 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
$nameLabel->setTextColor("FFF");
|
$nameLabel->setTextColor("FFF");
|
||||||
|
|
||||||
$substyle = '';
|
$substyle = '';
|
||||||
if($value === false) {
|
if ($value === false) {
|
||||||
$substyle = Quad_Icons64x64_1::SUBSTYLE_LvlRed;
|
$substyle = Quad_Icons64x64_1::SUBSTYLE_LvlRed;
|
||||||
} else if($value === true) {
|
} else if ($value === true) {
|
||||||
$substyle = Quad_Icons64x64_1::SUBSTYLE_LvlGreen;
|
$substyle = Quad_Icons64x64_1::SUBSTYLE_LvlGreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,7 +222,7 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
$entry->setName(self::ACTION_PREFIX_SETTING . '.' . $name);
|
$entry->setName(self::ACTION_PREFIX_SETTING . '.' . $name);
|
||||||
$entry->setDefault($value);
|
$entry->setDefault($value);
|
||||||
|
|
||||||
if($name == "Comment") { //
|
if ($name == "Comment") { //
|
||||||
$entry->setAutoNewLine(true);
|
$entry->setAutoNewLine(true);
|
||||||
$entry->setSize($width * 0.48, $settingHeight * 3 + $settingHeight * 0.9);
|
$entry->setSize($width * 0.48, $settingHeight * 3 + $settingHeight * 0.9);
|
||||||
$settingFrame->setY($y - $settingHeight * 1.5);
|
$settingFrame->setY($y - $settingHeight * 1.5);
|
||||||
@ -233,7 +231,7 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
$id += 3;
|
$id += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($substyle != '') {
|
if ($substyle != '') {
|
||||||
$quad = new Quad_Icons64x64_1();
|
$quad = new Quad_Icons64x64_1();
|
||||||
$settingFrame->add($quad);
|
$settingFrame->add($quad);
|
||||||
$quad->setX($width / 2 * 0.46);
|
$quad->setX($width / 2 * 0.46);
|
||||||
@ -247,7 +245,7 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$y -= $settingHeight;
|
$y -= $settingHeight;
|
||||||
if($id % $pageMaxCount == $pageMaxCount - 1) {
|
if ($id % $pageMaxCount == $pageMaxCount - 1) {
|
||||||
unset($pageFrame);
|
unset($pageFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,13 +256,11 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see \ManiaControl\Configurators\ConfiguratorMenu::saveConfigData()
|
* @see \ManiaControl\Configurators\ConfiguratorMenu::saveConfigData()
|
||||||
*/
|
*/
|
||||||
public function saveConfigData(array $configData, Player $player) {
|
public function saveConfigData(array $configData, Player $player) {
|
||||||
|
|
||||||
$prefix = explode(".", $configData[3][0]['Name']);
|
$prefix = explode(".", $configData[3][0]['Name']);
|
||||||
if($prefix[0] != self::ACTION_PREFIX_SETTING) {
|
if ($prefix[0] != self::ACTION_PREFIX_SETTING) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,14 +271,14 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
$actionArray = explode(".", $configData[2]);
|
$actionArray = explode(".", $configData[2]);
|
||||||
|
|
||||||
$boolSettingName = '';
|
$boolSettingName = '';
|
||||||
if(isset($actionArray[2])) {
|
if (isset($actionArray[2])) {
|
||||||
$boolSettingName = self::ACTION_PREFIX_SETTING . '.' . $actionArray[2];
|
$boolSettingName = self::ACTION_PREFIX_SETTING . '.' . $actionArray[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
$newSettings = array();
|
$newSettings = array();
|
||||||
foreach($configData[3] as $setting) {
|
foreach($configData[3] as $setting) {
|
||||||
// Check if it was a boolean button
|
// Check if it was a boolean button
|
||||||
if($setting['Name'] == $boolSettingName) {
|
if ($setting['Name'] == $boolSettingName) {
|
||||||
$setting['Value'] = ($setting['Value'] ? false : true);
|
$setting['Value'] = ($setting['Value'] ? false : true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,7 +303,7 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
public function handleManialinkPageAnswer(array $callback) {
|
public function handleManialinkPageAnswer(array $callback) {
|
||||||
$actionId = $callback[1][2];
|
$actionId = $callback[1][2];
|
||||||
$boolSetting = (strpos($actionId, self::ACTION_SETTING_BOOL) === 0);
|
$boolSetting = (strpos($actionId, self::ACTION_SETTING_BOOL) === 0);
|
||||||
if(!$boolSetting) {
|
if (!$boolSetting) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,7 +322,8 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function applyNewServerSettings(array $newSettings, Player $player) {
|
private function applyNewServerSettings(array $newSettings, Player $player) {
|
||||||
if(!$newSettings) {
|
var_dump($newSettings);
|
||||||
|
if (!$newSettings) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,7 +346,7 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
) ON DUPLICATE KEY UPDATE
|
) ON DUPLICATE KEY UPDATE
|
||||||
`settingValue` = VALUES(`settingValue`);";
|
`settingValue` = VALUES(`settingValue`);";
|
||||||
$statement = $mysqli->prepare($query);
|
$statement = $mysqli->prepare($query);
|
||||||
if($mysqli->error) {
|
if ($mysqli->error) {
|
||||||
trigger_error($mysqli->error);
|
trigger_error($mysqli->error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -361,12 +358,13 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
// $chatMessage = '$ff0' . $title . ' $<' . $player->nickname . '$> set ScriptSetting' . ($settingsCount > 1 ? 's' : '') . ' ';
|
// $chatMessage = '$ff0' . $title . ' $<' . $player->nickname . '$> set ScriptSetting' . ($settingsCount > 1 ? 's' : '') . ' ';
|
||||||
|
|
||||||
foreach($newSettings as $setting => $value) {
|
foreach($newSettings as $setting => $value) {
|
||||||
if($value == null) {
|
if ($value === null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$statement->bind_param('iss', $this->maniaControl->server->index, $setting, $value);
|
$statement->bind_param('iss', $this->maniaControl->server->index, $setting, $value);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
if($statement->error) {
|
if ($statement->error) {
|
||||||
trigger_error($statement->error);
|
trigger_error($statement->error);
|
||||||
$statement->close();
|
$statement->close();
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user