The parser for the mission header section of the server config seems rather limited:
- Cannot parse numbers without periods for float attributes
- Cannot parse true and false for boolean attributes
The parser for the mission header section of the server config seems rather limited:
I created and published a test mod with the ID 5EAC510A8E6EC623, which contains the following code and in essence defines a float and boolean attribute for the mission header and prints their values in the chat for all clients:
//------------------------------------------------------------------------------------------------ modded class SCR_MissionHeader : MissionHeader { [Attribute(defvalue: "11.0", desc: "My mission header float variable")] float m_fMHT_myFloatVariable; [Attribute(defvalue: "false", desc: "My mission header boolean variable")] bool m_bMHT_myBooleanVariable; } //------------------------------------------------------------------------------------------------ modded class SCR_BaseGameMode : BaseGameMode { //------------------------------------------------------------------------------------------------ //! Schedule printing of my header variable override protected void OnGameStart() { super.OnGameStart(); if (!Replication.IsServer()) return; GetGame().GetCallqueue().CallLater(MHT_PrintMyVariable, 1000, true); } //------------------------------------------------------------------------------------------------ //! Broadcast and print my variable to all clients protected void MHT_PrintMyVariable() { SCR_MissionHeader header = SCR_MissionHeader.Cast(GetGame().GetMissionHeader()); if (!header) return; Rpc(MHT_PrintInChatBroadcast, string.Format("m_fMHT_myFloatVariable = %1\nm_bMHT_myBooleanVariable = %2", header.m_fMHT_myFloatVariable, header.m_bMHT_myBooleanVariable)); } //------------------------------------------------------------------------------------------------ //! Print chat message for all clients [RplRpc(RplChannel.Unreliable, RplRcver.Broadcast)] protected void MHT_PrintInChatBroadcast(string message) { PlayerController ctrl = GetGame().GetPlayerController(); if (!ctrl) return; SCR_ChatComponent.Cast(ctrl.FindComponent(SCR_ChatComponent)).ShowMessage(message); } }
{ "bindAddress": "", "bindPort": 2401, "publicAddress": "", "publicPort": 2401, "game": { "name": "Kex's Mission Header Test", "passwordAdmin": "pw", "scenarioId": "{83D06A42096F671C}Missions/MpTest/10_MpTest.conf", "maxPlayers": 10, "gameProperties": { "missionHeader": { "m_fMHT_myFloatVariable": 7, "m_bMHT_myBooleanVariable": true } }, "mods": [ { "modId": "5EAC510A8E6EC623", "name": "Mission Header Test" } ] } }