Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7558503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:23:16+00:00 2026-05-30T12:23:16+00:00

I am completely lost in C# as I have never used it before. However,

  • 0

I am completely lost in C# as I have never used it before. However, I am trying to add a feature in the following code where custom variables can be imported from a text file (and if possible, exported, but that’s not as important. Can someone please guide me on how I can accomplish this?

using System;
using System.IO;
using System.Text;
using System.Threading;
using System.Reflection;
using System.Collections.Generic;
using System.Data;
using System.Text.RegularExpressions;

using PRoCon.Core;
using PRoCon.Core.Plugin;
using PRoCon.Core.Plugin.Commands;
using PRoCon.Core.Players;
using PRoCon.Core.Players.Items;
using PRoCon.Core.Battlemap;
using PRoCon.Core.Maps;

namespace PRoConEvents
{
  public class CSettingChangeOnMap : PRoConPluginAPI, IPRoConPluginInterface
  {
    private int m_mapIndex;
    private int m_nextIndex;
    private List<string> myMapList;
    private List<string> gameMode;
    private List<int> numRounds;
    private List<string> variableNames;
    private List<List<string>> customVariables;
    private List<string> defaultVariables;
    private List<string> defaultVariablesBackup;

    private bool cameFromRunNext;
    private bool needsMapInitialization;
    private bool needsModeChange;
    private List<bool> variableHasBeenSet;
    private enumBoolYesNo refreshMapList;

    private void setNormalMode()
    {
      // Normal Preset Variables
      this.ExecuteCommand("procon.protected.send", "vars.autoBalance", "true");
      this.ExecuteCommand("procon.protected.send", "vars.friendlyFire", "false");
      this.ExecuteCommand("procon.protected.send", "vars.killCam", "true");
      this.ExecuteCommand("procon.protected.send", "vars.miniMap", "true");
      this.ExecuteCommand("procon.protected.send", "vars.hud", "true");
      this.ExecuteCommand("procon.protected.send", "vars.3dSpotting", "true");
      this.ExecuteCommand("procon.protected.send", "vars.nameTag", "true");
      this.ExecuteCommand("procon.protected.send", "vars.3pCam", "true");
      this.ExecuteCommand("procon.protected.send", "vars.regenerateHealth", "true");
      this.ExecuteCommand("procon.protected.send", "vars.vehicleSpawnAllowed", "true");
      this.ExecuteCommand("procon.protected.send", "vars.soldierHealth", "100");
      this.ExecuteCommand("procon.protected.send", "vars.playerRespawnTime", "100");
      this.ExecuteCommand("procon.protected.send", "vars.onlySquadLeaderSpawn", "false");

      // Remaining Variables Set From User's Default Variable List
      for (int i = 13; i < defaultVariables.Count; i++)
      {
        if (defaultVariables[i] != "YOUR_SERVER_NAME_HERE (Skip to Ignore)" && defaultVariables[i] != "YOUR_MAX_PLAYERS_HERE (Skip to Ignore)" && defaultVariables[i] != "YOUR_SERVER PASSWORD_HERE (Skip to Ignore)")
          this.ExecuteCommand("procon.protected.send", variableNames[i], defaultVariables[i]);
      }
    }

    private void setInfantryMode()
    {
      // Infantry Only Preset Variables
      this.ExecuteCommand("procon.protected.send", "vars.autoBalance", "true");
      this.ExecuteCommand("procon.protected.send", "vars.friendlyFire", "false");
      this.ExecuteCommand("procon.protected.send", "vars.killCam", "true");
      this.ExecuteCommand("procon.protected.send", "vars.miniMap", "true");
      this.ExecuteCommand("procon.protected.send", "vars.hud", "true");
      this.ExecuteCommand("procon.protected.send", "vars.3dSpotting", "true");
      this.ExecuteCommand("procon.protected.send", "vars.nameTag", "true");
      this.ExecuteCommand("procon.protected.send", "vars.3pCam", "false");
      this.ExecuteCommand("procon.protected.send", "vars.regenerateHealth", "true");
      this.ExecuteCommand("procon.protected.send", "vars.vehicleSpawnAllowed", "false");
      this.ExecuteCommand("procon.protected.send", "vars.soldierHealth", "100");
      this.ExecuteCommand("procon.protected.send", "vars.playerRespawnTime", "100");
      this.ExecuteCommand("procon.protected.send", "vars.onlySquadLeaderSpawn", "false");

      // Remaining Variables Set From User's Default Variable List
      for (int i = 13; i < defaultVariables.Count; i++)
      {
        if (defaultVariables[i] != "YOUR_SERVER_NAME_HERE (Skip to Ignore)" && defaultVariables[i] != "YOUR_MAX_PLAYERS_HERE (Skip to Ignore)" && defaultVariables[i] != "YOUR_SERVER PASSWORD_HERE (Skip to Ignore)")
          this.ExecuteCommand("procon.protected.send", variableNames[i], defaultVariables[i]);
      }
    }

    private void setHardcoreMode()
    {
      // Hardcore Preset Variables
      this.ExecuteCommand("procon.protected.send", "vars.autoBalance", "true");
      this.ExecuteCommand("procon.protected.send", "vars.friendlyFire", "true");
      this.ExecuteCommand("procon.protected.send", "vars.killCam", "false");
      this.ExecuteCommand("procon.protected.send", "vars.miniMap", "true");
      this.ExecuteCommand("procon.protected.send", "vars.hud", "false");
      this.ExecuteCommand("procon.protected.send", "vars.3dSpotting", "false");
      this.ExecuteCommand("procon.protected.send", "vars.nameTag", "false");
      this.ExecuteCommand("procon.protected.send", "vars.3pCam", "false");
      this.ExecuteCommand("procon.protected.send", "vars.regenerateHealth", "false");
      this.ExecuteCommand("procon.protected.send", "vars.vehicleSpawnAllowed", "true");
      this.ExecuteCommand("procon.protected.send", "vars.soldierHealth", "60");
      this.ExecuteCommand("procon.protected.send", "vars.playerRespawnTime", "100");
      this.ExecuteCommand("procon.protected.send", "vars.onlySquadLeaderSpawn", "true");

      // Remaining Variables Set From User's Default Variable List
      for (int i = 13; i < defaultVariables.Count; i++)
      {
        if (defaultVariables[i] != "YOUR_SERVER_NAME_HERE (Skip to Ignore)" && defaultVariables[i] != "YOUR_MAX_PLAYERS_HERE (Skip to Ignore)" && defaultVariables[i] != "YOUR_SERVER PASSWORD_HERE (Skip to Ignore)")
          this.ExecuteCommand("procon.protected.send", variableNames[i], defaultVariables[i]);
      }
    }

    private void setCustomMode(int mapIndex)
    {
      // User's Map Specific Custom Variables
      for (int i = 0; i < variableNames.Count; i++)
      {
        if (customVariables[mapIndex][i] != "Enter Value Here! (Skip to Ignore)")
        {
          this.ExecuteCommand("procon.protected.send", variableNames[i], customVariables[mapIndex][i]);
          variableHasBeenSet.Add(true);
        }
        else
        {
          variableHasBeenSet.Add(false);
        }
      }

      // Remaining Variables Set From User's Default Variable List
      for (int i = 0; i < variableNames.Count; i++)
      {
        if (!variableHasBeenSet[i])
        {
          if (defaultVariables[i] != "YOUR_SERVER_NAME_HERE (Skip to Ignore)" && defaultVariables[i] != "YOUR_MAX_PLAYERS_HERE (Skip to Ignore)" && defaultVariables[i] != "YOUR_SERVER PASSWORD_HERE (Skip to Ignore)")
            this.ExecuteCommand("procon.protected.send", variableNames[i], defaultVariables[i]);
        }
      }

      variableHasBeenSet.Clear();
    }

    public void setVariableList()
    {
      variableNames.Add("vars.autoBalance");
      variableNames.Add("vars.friendlyFire");
      variableNames.Add("vars.killCam");
      variableNames.Add("vars.miniMap");
      variableNames.Add("vars.hud");
      variableNames.Add("vars.3dSpotting");
      variableNames.Add("vars.3pCam");
      variableNames.Add("vars.nameTag");
      variableNames.Add("vars.regenerateHealth");
      variableNames.Add("vars.vehicleSpawnAllowed");
      variableNames.Add("vars.soldierHealth");
      variableNames.Add("vars.playerRespawnTime");
      variableNames.Add("vars.onlySquadLeaderSpawn");
      variableNames.Add("vars.roundStartPlayerCount");
      variableNames.Add("vars.roundRestartPlayerCount");
      variableNames.Add("vars.gameModeCounter");
      variableNames.Add("vars.teamKillCountForKick");
      variableNames.Add("vars.teamKillValueForKick");
      variableNames.Add("vars.teamKillValueIncrease");
      variableNames.Add("vars.teamKillValueDecreasePerSecond");
      variableNames.Add("vars.teamKillKickForBan");
      variableNames.Add("vars.idleTimeout");
      variableNames.Add("vars.idleBanRounds");
      variableNames.Add("vars.serverName");
      variableNames.Add("vars.maxPlayers");
      variableNames.Add("vars.gamePassword");
      variableNames.Add("vars.vehicleSpawnDelay");
    }

    public void setDefaultVariables()
    {
      defaultVariables.Add("true");
      defaultVariables.Add("false");
      defaultVariables.Add("true");
      defaultVariables.Add("true");
      defaultVariables.Add("true");
      defaultVariables.Add("true");
      defaultVariables.Add("true");
      defaultVariables.Add("true");
      defaultVariables.Add("true");
      defaultVariables.Add("true");
      defaultVariables.Add("100");
      defaultVariables.Add("100");
      defaultVariables.Add("false");
      defaultVariables.Add("1");
      defaultVariables.Add("1");
      defaultVariables.Add("100");
      defaultVariables.Add("5");
      defaultVariables.Add("4.1");
      defaultVariables.Add("1");
      defaultVariables.Add("0.05");
      defaultVariables.Add("0");
      defaultVariables.Add("300");
      defaultVariables.Add("0");
      defaultVariables.Add("YOUR_SERVER_NAME_HERE (Skip to Ignore)");
      defaultVariables.Add("YOUR_MAX_PLAYERS_HERE (Skip to Ignore)");
      defaultVariables.Add("YOUR_SERVER PASSWORD_HERE (Skip to Ignore)");
      defaultVariables.Add("100");

      defaultVariablesBackup.Add("true");
      defaultVariablesBackup.Add("false");
      defaultVariablesBackup.Add("true");
      defaultVariablesBackup.Add("true");
      defaultVariablesBackup.Add("true");
      defaultVariablesBackup.Add("true");
      defaultVariablesBackup.Add("true");
      defaultVariablesBackup.Add("true");
      defaultVariablesBackup.Add("true");
      defaultVariablesBackup.Add("true");
      defaultVariablesBackup.Add("100");
      defaultVariablesBackup.Add("100");
      defaultVariablesBackup.Add("false");
      defaultVariablesBackup.Add("1");
      defaultVariablesBackup.Add("1");
      defaultVariablesBackup.Add("100");
      defaultVariablesBackup.Add("5");
      defaultVariablesBackup.Add("4.1");
      defaultVariablesBackup.Add("1");
      defaultVariablesBackup.Add("0.05");
      defaultVariablesBackup.Add("0");
      defaultVariablesBackup.Add("300");
      defaultVariablesBackup.Add("0");
      defaultVariablesBackup.Add("YOUR_SERVER_NAME_HERE (Skip to Ignore)");
      defaultVariablesBackup.Add("YOUR_MAX_PLAYERS_HERE (Skip to Ignore)");
      defaultVariablesBackup.Add("YOUR_SERVER PASSWORD_HERE (Skip to Ignore)");
      defaultVariablesBackup.Add("100");
    }

    public List<string> getListOfDefaults()
    {
      List<string> myListReturn = new List<string>();

      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");
      myListReturn.Add("Enter Value Here! (Skip to Ignore)");

      return myListReturn;
    }

    public void getMapIndices()
    {
      this.ExecuteCommand("procon.protected.send", "mapList.getMapIndices");
    }

    public void getMapRounds()
    {
      this.ExecuteCommand("procon.protected.send", "mapList.getRounds");
    }

    public void getMapList()
    {
      this.ExecuteCommand("procon.protected.send", "mapList.list");
    }

    public void initializeMapList()
    {
      myMapList.Clear();
      gameMode.Clear();
      numRounds.Clear();
      customVariables.Clear();

      needsMapInitialization = true;
      getMapList();
    }

    public CSettingChangeOnMap()
    {
      this.myMapList = new List<string>();
      this.gameMode = new List<string>();
      this.numRounds = new List<int>();
      this.variableNames = new List<string>();
      this.customVariables = new List<List<string>>();
      this.defaultVariables = new List<string>();
      this.defaultVariablesBackup = new List<string>();

      this.cameFromRunNext = false;
      this.needsMapInitialization = true;
      this.needsModeChange = false;
      this.variableHasBeenSet = new List<bool>();
      this.refreshMapList = enumBoolYesNo.No;

      this.setVariableList();
      this.setDefaultVariables();
    }

    public string GetPluginName()
    {
      return "Server Settings Change On Map";
    }

    public string GetPluginVersion()
    {
      return "1.4.5";
    }

    public string GetPluginAuthor()
    {
      return "TimSad";
    }

    public string GetPluginWebsite()
    {
      return "www.phogue.net/forumvb/showthread.php?3388-Settings-Change-on-Specific-Map-%281.1.0-12-13-2011%29-BF3";
    }

    public string GetPluginDescription()
    {
      return @"<h2>Description</h2>
        <p>This plugin allows you to set different game modes and custom variables throughout your map rotation.  You have the option of Normal Mode, Infantry Only Mode, Hardcore Mode, and Custom Settings mode.</p>
        <h2>Settings</h2>
        <p><b>Default Variables (Server Startup Variables)</b> - Set each of these to match whatever your server starts up with using the Startup.txt file. Each one starts with their default values in their fields. 
        This is used to change the unspecified variables <i>back</i> to your server's startup values. For example, when you leave a custom variable field blank for one map, it won't use the same value that was defined for the previous map 
        and will instead revert it back to default per this Default Variables list.</p>
        <p><b>Get/Refresh Your Map List?</b> - Use this to load each of your maps from your map list into a variable to assign a game mode to. (Plugin must be enabled for this to work)</p>
        <p>Set your maps under <b>Your Map Rotation</b> to whichever game settings you would like to be played for that map.</p>
        ";
    }

    public void OnPluginLoaded(string strHostName, string strPort, string strPRoConVersion)
    {
      this.RegisterEvents(this.GetType().Name, "OnMaplistGetMapIndices", "OnRoundOver", "OnMaplistGetRounds", "OnRunNextLevel", "OnMaplistList");
    }

    public void OnPluginEnable()
    {
      this.ExecuteCommand("procon.protected.pluginconsole.write", "^bServer Settings Change On Map ^2Enabled!");
    }

    public void OnPluginDisable()
    {
      this.ExecuteCommand("procon.protected.pluginconsole.write", "^bServer Settings Change On Map ^1Disabled =(");
    }

    public List<CPluginVariable> GetDisplayPluginVariables()
    {
      List<CPluginVariable> lstReturn = new List<CPluginVariable>();

      for (int i = 0; i < defaultVariables.Count; i++)
      {
        lstReturn.Add(new CPluginVariable("Default Variables (Server Startup Variables)|" + variableNames[i], defaultVariables[i].GetType(), defaultVariables[i]));
      }

      lstReturn.Add(new CPluginVariable("Refresh Map List|Get/Refresh Your Map List?", typeof(enumBoolYesNo), refreshMapList));

      for(int i = 0; i < myMapList.Count; i++)
      {
        lstReturn.Add(new CPluginVariable("Your Map Rotation|" + myMapList[i], "enum.Actions(Normal Mode|Infantry Only Mode|Hardcore Mode|Custom Settings)", gameMode[i]));
      }

      for (int i = 0; i < myMapList.Count; i++)
      {
        if (gameMode[i] == "Custom Settings")
        {
          for (int j = 0; j < this.variableNames.Count; j++)
          {
            lstReturn.Add(new CPluginVariable("Custom Variables: " + myMapList[i] + "|" + "Map #" + ((i + 1).ToString()) + ": " + this.variableNames[j], customVariables[i][j].GetType(), customVariables[i][j]));
          }
        }
      }

        return lstReturn;
    }

    public List<CPluginVariable> GetPluginVariables()
    {
      List<CPluginVariable> lstReturn = new List<CPluginVariable>();

      for (int i = 0; i < defaultVariables.Count; i++)
      {
        lstReturn.Add(new CPluginVariable(variableNames[i], defaultVariables[i].GetType(), defaultVariables[i]));
      }

      lstReturn.Add(new CPluginVariable("Get/Refresh Your Map List?", typeof(enumBoolYesNo), refreshMapList));

      for(int i = 0; i < myMapList.Count; i++)
      {
        lstReturn.Add(new CPluginVariable(myMapList[i], "enum.Actions(Normal Mode|Infantry Only Mode|Hardcore Mode|Custom Settings)", gameMode[i]));
      }

      for (int i = 0; i < myMapList.Count; i++)
      {
        if (gameMode[i] == "Custom Settings")
        {
          for (int j = 0; j < variableNames.Count; j++)
          {
            lstReturn.Add(new CPluginVariable("Map #" + ((i + 1).ToString()) + ": " + this.variableNames[j], customVariables[i][j].GetType(), customVariables[i][j]));
          }
        }
      }

        return lstReturn;
    }

    public void SetPluginVariable(string strVariable, string strValue)
    {
      for (int i = 0; i < defaultVariables.Count; i++)
      {
        if (strVariable.CompareTo(variableNames[i]) == 0)
        {
          defaultVariables[i] = strValue;

          if (defaultVariables[i] == "")
            defaultVariables[i] = defaultVariablesBackup[i];
        }
      }

      if (strVariable.CompareTo("Get/Refresh Your Map List?") == 0)
      {
        if (strValue == "Yes")
        {
          initializeMapList();
          Thread.Sleep(200);
        }
      }

      for(int i = 0; i < myMapList.Count; i++)
      {
        if (strVariable.CompareTo(myMapList[i]) == 0)
        {
          gameMode[i] = strValue;
        }
      }

      for (int i = 0; i < myMapList.Count; i++)
      {
        if (gameMode[i] == "Custom Settings")
        {
          for (int j = 0; j < variableNames.Count; j++)
          {
            if (strVariable.CompareTo("Map #" + ((i + 1).ToString()) + ": " + this.variableNames[j]) == 0)
            {
              customVariables[i][j] = strValue;

              if (customVariables[i][j] == "")
                customVariables[i][j] = "Enter Value Here! (Skip to Ignore)";
            }
          }
        }
      }
    }

    public override void OnMaplistList(List<MaplistEntry> lstMaplist)
    {
      if (needsMapInitialization)
      {
        int mapNumber = 0;

        for (int i = 0; i < lstMaplist.Count; i++)
        {
          mapNumber++;
          numRounds.Add(lstMaplist[i].Rounds);

          if (lstMaplist[i].MapFileName == "MP_Subway")
          {
            myMapList.Add("Operation Metro - Map #" + mapNumber.ToString());
            gameMode.Add("Normal Mode");
          }
          else if (lstMaplist[i].MapFileName == "MP_001")
          {
            myMapList.Add("Grand Bazaar - Map #" + mapNumber.ToString());
            gameMode.Add("Normal Mode");
          }
          else if (lstMaplist[i].MapFileName == "MP_003")
          {
            myMapList.Add("Teheran Highway - Map #" + mapNumber.ToString());
            gameMode.Add("Normal Mode");
          }
          else if (lstMaplist[i].MapFileName == "MP_007")
          {
            myMapList.Add("Caspian Border - Map #" + mapNumber.ToString());
            gameMode.Add("Normal Mode");
          }
          else if (lstMaplist[i].MapFileName == "MP_011")
          {
            myMapList.Add("Seine Crossing - Map #" + mapNumber.ToString());
            gameMode.Add("Normal Mode");
          }
          else if (lstMaplist[i].MapFileName == "MP_012")
          {
            myMapList.Add("Operation Firestorm - Map #" + mapNumber.ToString());
            gameMode.Add("Normal Mode");
          }
          else if (lstMaplist[i].MapFileName == "MP_013")
          {
            myMapList.Add("Damavand Peak - Map #" + mapNumber.ToString());
            gameMode.Add("Normal Mode");
          }
          else if (lstMaplist[i].MapFileName == "MP_017")
          {
            myMapList.Add("Noshahr Canals - Map #" + mapNumber.ToString());
            gameMode.Add("Normal Mode");
          }
          else if (lstMaplist[i].MapFileName == "MP_018")
          {
            myMapList.Add("Kharg Island - Map #" + mapNumber.ToString());
            gameMode.Add("Normal Mode");
          }
          else if (lstMaplist[i].MapFileName == "XP1_001")
          {
            myMapList.Add("Strike at Karkand - Map #" + mapNumber.ToString());
            gameMode.Add("Normal Mode");
          }
          else if (lstMaplist[i].MapFileName == "XP1_002")
          {
            myMapList.Add("Gulf of Oman - Map #" + mapNumber.ToString());
            gameMode.Add("Normal Mode");
          }
          else if (lstMaplist[i].MapFileName == "XP1_003")
          {
            myMapList.Add("Sharqi Peninsula - Map #" + mapNumber.ToString());
            gameMode.Add("Normal Mode");
          }
          else if (lstMaplist[i].MapFileName == "XP1_004")
          {
            myMapList.Add("Wake Island - Map #" + mapNumber.ToString());
            gameMode.Add("Normal Mode");
          }
        }

        for (int i = 0; i < myMapList.Count; i++)
          customVariables.Add(getListOfDefaults());

        this.ExecuteCommand("procon.protected.pluginconsole.write", "Successfully Retrieved Map List!");
        needsMapInitialization = false;
      }
    }

    public void OnMaplistGetRounds(int currentRound, int totalRounds)
    {
      if (needsModeChange)
      {
        if (cameFromRunNext) // Came from OnRunNextLevel
        {
          if (gameMode[m_mapIndex] == "Normal Mode")
            setNormalMode();
          else if (gameMode[m_mapIndex] == "Infantry Only Mode")
            setInfantryMode();
          else if (gameMode[m_mapIndex] == "Hardcore Mode")
            setHardcoreMode();
          else if (gameMode[m_mapIndex] == "Custom Settings")
            setCustomMode(m_mapIndex);

          cameFromRunNext = false;
        }
        else if (!cameFromRunNext) // Came from OnRoundOver
        {
          if (gameMode[m_nextIndex] == "Normal Mode" && currentRound == numRounds[m_mapIndex] - 1)
            setNormalMode();
          else if (gameMode[m_nextIndex] == "Infantry Only Mode" && currentRound == numRounds[m_mapIndex] - 1)
            setInfantryMode();
          else if (gameMode[m_nextIndex] == "Hardcore Mode" && currentRound == numRounds[m_mapIndex] - 1)
            setHardcoreMode();
          else if (gameMode[m_nextIndex] == "Custom Settings" && currentRound == numRounds[m_mapIndex] - 1)
            setCustomMode(m_nextIndex);
        }

        needsModeChange = false;
      }

    }

    public void OnMaplistGetMapIndices(int mapIndex, int nextIndex)
    {
      m_mapIndex = mapIndex;
      m_nextIndex = nextIndex;
      getMapRounds();
    }

    public override void OnRoundOver(int iWinningTeamID)
    {
      needsModeChange = true;
      getMapIndices();
    }

    public override void OnRunNextLevel()
    {
      needsModeChange = true;
      cameFromRunNext = true;
      getMapIndices();
    }
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T12:23:17+00:00Added an answer on May 30, 2026 at 12:23 pm

    Sounds like you want to serialize your C# state into a text format. Xml serialization: http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx

    Serialization basics:
    http://msdn.microsoft.com/en-us/library/ms233843.aspx

    Edit:

    Example implementation using XmlSerializer:

    public struct MyData
    {
        public List<string> myMapList;
        public List<string> gameMode;
        public List<int> numRounds;
        public List<string> variableNames;
        public List<List<string>> customVariables;
        public List<string> defaultVariables;
        public List<string> defaultVariablesBackup;
    }
    private void SaveAllData()
    {
        string dataFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "MyData.txt");
    
        MyData myData = new MyData()
        {
            myMapList = myMapList,
            gameMode = gameMode,
            numRounds = numRounds,
            variableNames = variableNames,
            customVariables = customVariables,
            defaultVariables = defaultVariables,
            defaultVariablesBackup = defaultVariablesBackup
        };
        XmlSerializer serializer = new XmlSerializer(typeof(MyData));
        TextWriter writer = new StreamWriter(dataFile);
        serializer.Serialize(writer, myData);
        writer.Dispose();
        writer = null;
    }
    private void LoadAllData()
    {
        string dataFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "MyData.txt");
    
        XmlSerializer serializer = new XmlSerializer(typeof(MyData));
        TextReader reader = new StreamReader(dataFile);
        MyData myData = (MyData)serializer.Deserialize(reader);
        reader.Dispose();
        reader = null;
    
        myMapList = myData.myMapList;
        gameMode = myData.gameMode;
        numRounds = myData.numRounds;
        variableNames = myData.variableNames;
        customVariables = myData.customVariables;
        defaultVariables = myData.defaultVariables;
        defaultVariablesBackup = myData.defaultVariablesBackup;
    }
    

    You’ll need these using statements:

    using System.Xml.Serialization;
    using System.IO;
    

    Place this somewhere in your “CSettingChangeOnMap” class. You may want to rename some things. I hope this helps 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've never done this before, so im lost here. I have the following transactions
I have never written multi-threaded code before (barring a few basic backgroundworker tricks) and
I have this code, to get followers and friends(peeps you are following), However I'm
We've completely lost our repository and we have 8 developers with uncomitted changes. Restoring
I am trying to compile SDL_ttf with MinGW and Code::Blocks. I have imported the
I have an assignment to correct an ambiguous BNF, but I am completely lost.
This is very stupid but I seem to be completely lost trying to test
I am completely lost on this one-- I have a .Rpt file that runs
I am completely lost with encoding issues, I have no idea what's going on,
I'm completely lost and apparently have fall way behind with regards to my web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.