Implementing something similar to this might solve it, but I wish this was open source so I could test it out:
public void LoadSettings()
{
// Load the settings from the XML file
XDocument xmlDoc = XDocument.Load("AutoEngineSoundSwap.xml");
// Create a list of SwapSets
List<SwapSet> swapSets = new List<SwapSet>();
// Loop through the SwapSet elements in the XML file
foreach (XElement swapSetElement in xmlDoc.Descendants("SwapSet"))
{
// Get the ModType attribute
int modType = int.Parse(swapSetElement.Attribute("ModType").Value);
// Create a new SwapSet object
SwapSet swapSet = new SwapSet();
swapSet.ModType = modType;
swapSet.Swaps = new List<Swap>();
// Loop through the SWAP elements in the SwapSet element
foreach (XElement swapElement in swapSetElement.Elements("SWAP"))
{
// Get the attributes of the SWAP element
int modID = int.Parse(swapElement.Attribute("ModID").Value);
string engineSound = swapElement.Attribute("EngineSound").Value;
int powerMult = 1;
if (swapElement.Attribute("PowerMult") != null)
{
powerMult = int.Parse(swapElement.Attribute("PowerMult").Value);
}
// Create a new Swap object
Swap swap = new Swap();
swap.ModID = modID;
swap.EngineSound = engineSound;
swap.PowerMult = powerMult;
// Add the Swap object to the SwapSet object
swapSet.Swaps.Add(swap);
}
// Add the SwapSet object to the list of SwapSets
swapSets.Add(swapSet);
}
// Store the SwapSets in the dictionary
foreach (SwapSet swapSet in swapSets)
{
if (!swapDictionary.ContainsKey(swapSet.ModType))
{
swapDictionary.Add(swapSet.ModType, swapSet.Swaps);
}
else
{
swapDictionary[swapSet.ModType].AddRange(swapSet.Swaps);
}
}
}
I don't know how this mod was made as I can't find documentation, but it can't handle multiple SwapSets, and it causes this exception: Failed to instantiate script AutoEngineSoundSwap because constructor threw an exception: System.ArgumentException: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at AutoEngineSoundSwap.LoadSettings()
@exee Very cool. Thanks!
What do I manually need to edit to make the noises louder? The optional file that comes with the mod is too loud
Awesome mod! In the next update, could you add the option to change the buttons?
This broke my mods folder (being on the latest patch). Causes vehicles from mpchristmas2 to not load. Beware!
An armoured version of this would be so hot
You are such a chaotic and unpredictable mod creator...
I love it
Find a way to remove gears and this'll be perfect.
Implementing something similar to this might solve it, but I wish this was open source so I could test it out:
public void LoadSettings()
{
// Load the settings from the XML file
XDocument xmlDoc = XDocument.Load("AutoEngineSoundSwap.xml");
// Create a list of SwapSets
List<SwapSet> swapSets = new List<SwapSet>();
// Loop through the SwapSet elements in the XML file
foreach (XElement swapSetElement in xmlDoc.Descendants("SwapSet"))
{
// Get the ModType attribute
int modType = int.Parse(swapSetElement.Attribute("ModType").Value);
// Create a new SwapSet object
SwapSet swapSet = new SwapSet();
swapSet.ModType = modType;
swapSet.Swaps = new List<Swap>();
// Loop through the SWAP elements in the SwapSet element
foreach (XElement swapElement in swapSetElement.Elements("SWAP"))
{
// Get the attributes of the SWAP element
int modID = int.Parse(swapElement.Attribute("ModID").Value);
string engineSound = swapElement.Attribute("EngineSound").Value;
int powerMult = 1;
if (swapElement.Attribute("PowerMult") != null)
{
powerMult = int.Parse(swapElement.Attribute("PowerMult").Value);
}
// Create a new Swap object
Swap swap = new Swap();
swap.ModID = modID;
swap.EngineSound = engineSound;
swap.PowerMult = powerMult;
// Add the Swap object to the SwapSet object
swapSet.Swaps.Add(swap);
}
// Add the SwapSet object to the list of SwapSets
swapSets.Add(swapSet);
}
// Store the SwapSets in the dictionary
foreach (SwapSet swapSet in swapSets)
{
if (!swapDictionary.ContainsKey(swapSet.ModType))
{
swapDictionary.Add(swapSet.ModType, swapSet.Swaps);
}
else
{
swapDictionary[swapSet.ModType].AddRange(swapSet.Swaps);
}
}
}
I don't know how this mod was made as I can't find documentation, but it can't handle multiple SwapSets, and it causes this exception: Failed to instantiate script AutoEngineSoundSwap because constructor threw an exception: System.ArgumentException: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at AutoEngineSoundSwap.LoadSettings()
@VxRuz_DanZ Maybe he has some unmet dependencies. Does this mod have any depencencies?