Mode script change in SM not updating ModeScriptSettings?

Moderator: NADEO

Mode script change in SM not updating ModeScriptSettings?

Postby anvolcano » 15 Jul 2012, 17:28

Spent this morning trying to add functionality to my server scripts to change the mode script when a command is called. In terms of just the API methods, it does, in order:

Code: Select all
SetScriptName(new_script)
LoadMatchSettings(match_settings_for_mode)
NextMap()
SetModeScriptSettings(new_script_settings)


Theoretically, this should set the next script used to the script chosen, load the match settings (map list) for the new script, cycle to the next map in that map settings file, and then set new script settings for the new mode.

The last part of that is where it has an issue. Unfortunately, it appears that when the script mode is changed, the mode script setting keys - i.e., "RoundsToWin" in BattleWaves or "S_OffZoneTimeLimit" in Royal - are not updated, and the old script's settings are not replaced with the new script's default settings. So, for example, if I changed from Royal to BattleWaves, the settings will still be "S_MapPointsLimit," "S_OffZoneActiviationTime," etc. - all of the Royal settings - and will not include any of the BattleWaves settings, such as "RoundsToWin" or "RoundsLimit."

This, of course, breaks the new script, since it can't find any of the settings. It ends up getting the server stuck in a loop of the script crashing and the map restarting.

At first, I thought a workaround would be to just set all of the settings with SetModeScriptSettings(), including the defaults. But this, of course, fails with an "Unknown setting" fault from the API, since you can't add new keys with SetModeScriptSettings.

Here is the Python script that contains my change mode function that is having the issue. I'm not sure if I'm missing something here that would make it work. I wanted to eventually have a server that could swap between modes on-the-fly, instead of needing a restart like it does now, but I don't see a way to do so if there's no way to work around this bug. Btw, I'm using API 2012-06-19, don't know if this is an issue in other versions.
anvolcano
 
Posts: 41
Joined: 06 Jul 2012, 09:25

Re: Mode script change in SM not updating ModeScriptSettings

Postby Mikey » 02 Oct 2012, 02:16

Just Searched the forum. And this is the same as what I have found.
LoadMatchSettings does not initialize the script, ie define the #settings
The script has changed, only maps of the type of the new script can be played or added. but game play does not work.
Using latest version for 1.3c
Mikey
 
Posts: 189
Joined: 16 Jun 2010, 01:22
Location: Down Under

Re: Mode script change in SM not updating ModeScriptSettings

Postby Mikey » 08 Oct 2012, 04:51

After some more experimenting I have more infos. When changing game modes via loading matchfiles.

After calling LoadMatchSettings then using GetScriptName it returns the correct scipts for current and next value
After the next map has loaded, using GetScriptName again, it says it is using the correct script
Using GetModeScriptSettings it shows the settings do match the correct game mode.
But no game can be played, as there is an error Null value something and the server is in an error loop.
Also the console output at this moment displays the script as the previous script.
Using SetScriptName to the correct script makes no difference and errors continue.

The onlyway i have found to make it work is to handle the scrip.txt in php and then SetModeScriptText

There is definatley a bug related to using a different script either by loadmathsetting or setscript.
Mikey
 
Posts: 189
Joined: 16 Jun 2010, 01:22
Location: Down Under

Re: Mode script change in SM not updating ModeScriptSettings

Postby w1lla » 13 Oct 2012, 15:34

The error as Mikey reports to is based on going from Battle to Royal through the Methods provided by nadeo.

An example code used for this is shown below:

Code: Select all
if (!$client->query('LoadMatchSettings', 'MatchSettings/SMStormRoyal.txt')) {
   die('An error occurred - ' . $client->getErrorCode() . ':' . $client->getErrorMessage());
}
$methods = $client->getResponse();
var_dump($methods);

if (!$client->query('GetScriptName')) {
   die('An error occurred - ' . $client->getErrorCode() . ':' . $client->getErrorMessage());
}
$methods1 = $client->getResponse();
var_dump($methods1);

if (!$client->query('GetModeScriptSettings')) {
   die('An error occurred - ' . $client->getErrorCode() . ':' . $client->getErrorMessage());
}
$methods2 = $client->getResponse();
var_dump($methods2);

if (!$client->query('NextMap')) {
   die('An error occurred - ' . $client->getErrorCode() . ':' . $client->getErrorMessage());
}
$methods3 = $client->getResponse();
var_dump($methods3);


The problem however it that the script gives an error of:
Code: Select all
[184,7] Can not access to member of Null Value.


This happens on battle:

Code: Select all
foreach (Clan => Spawn in ClanSpawnAnchors) {
   Spawn.Base.Clan = Clan;
   Spawn.Base.IsActive = True;
}


For Royal to Battle the following errors behold:

Code: Select all
[125,5] Can not access to member of Null Value.



Only solution is this:
farfa wrote:If you want to start a dedicated server to test a script, you can't edit easily your script.
This script will give you this power :yes:
You just have to download manialive, no need to setup it. It just use it as a library.
Then execute the following code by replacing what it needs to be replaced (everything between [])
Code: Select all
<?php
require [PathToManiaLive].'/libraries/autoload.php';
$config = \ManiaLive\DedicatedApi\Config::getInstance();
$config->host = '[yourHostName]';
$config->port = [yourServerPort];
$config->password = [yourSuperAdminPassword];
$config->timeout = 6;
$myScriptText = file_get_contents('[Path_to_my_script]');
var_dump(\ManiaLive\DedicatedApi\Connection::getInstance()->setModeScripttext($myScriptText));
?>


edit by w1lla:
Changed SetRule to SetMode
TM² Info
SM Info
QM Info

OS: Windows XP
MB: MS-7599
Processor: AMD Athlon II X2 250
RAM Memory: 4 GB DDR3
Video: ATI HD Radeon 5500 1 GB

Mode Creation

ManiaScript Docs
User avatar
w1lla
 
Posts: 1402
Joined: 15 Jun 2010, 11:09
Location: Netherlands
Manialink: maniaplanetblog


Return to Dedicated Server

Who is online

Users browsing this forum: No registered users and 3 guests