nisen Posted December 4, 2012 Share Posted December 4, 2012 Hey, iim very new to C# install scripts, but here what i wanto do: have it automatically pick one of two esps to install, depending on one of two esps it detects allready installed, so no popup/message, or options box the user has to choose its for is a mod that works both in FO3 and FNV, where everything beside the esp's are the same, so want the install menu to look the same, and just know which game its installing to btw i know a way to do this with xml scripts, but now wanto do it with C# and am reading the Zumbs blog tutorials but the closest it mentions is for it to check fose version and not install if too old... any help appreciated for a noob, even script examples to figure out myself Link to comment Share on other sites More sharing options...
AlexxEG Posted December 4, 2012 Share Posted December 4, 2012 (edited) Try these functions: bool IsPluginActive(string findPlugin) { foreach (string plugin in GetActivePlugins()) if (plugin == findPlugin) return true; return false; } bool IsPluginPresent(string findPlugin) { foreach (string plugin in GetAllPlugins()) if (plugin == findPlugin) return true; return false; } Have not been able to test them, since I'm at school, but they should work. Edited December 4, 2012 by Alexx378 Link to comment Share on other sites More sharing options...
nisen Posted December 4, 2012 Author Share Posted December 4, 2012 (edited) thanks but might not work with esm's, and still unsure how itd fit it into the script. guess id need an example with one that has an esm requirement to know if youd just replace the ...Plugin with ...Master Edited December 4, 2012 by nisen Link to comment Share on other sites More sharing options...
AlexxEG Posted December 4, 2012 Share Posted December 4, 2012 (edited) I think it works with masters also. Just switch for example IsPluginActive("plugin.esp") with IsPluginActive("plugin.esm") Here is a example: using fomm.Scripting; class Script : FalloutNewVegasBaseScript { public static bool OnActivate() { if (IsPluginPresent("plugin.esp")) { // Do something if "plugin.esp" is present. InstallFileFromFomod("example.esp"); } if (IsPluginActive("plugin.esp")) { // Do something if "plugin.esp" is both present // and active. InstallFileFromFomod("example.esp"); } return true; } static bool IsPluginActive(string findPlugin) { findPlugin = findPlugin.ToLower(); foreach (string plugin in GetActivePlugins()) if (plugin.ToLower() == findPlugin) return true; return false; } static bool IsPluginPresent(string findPlugin) { findPlugin = findPlugin.ToLower(); foreach (string plugin in GetAllPlugins()) if (plugin.ToLower() == findPlugin) return true; return false; } } Edited December 4, 2012 by Alexx378 Link to comment Share on other sites More sharing options...
nisen Posted December 5, 2012 Author Share Posted December 5, 2012 Thanks that worked but using it wont install any of the other files and has an odd message where it immediately installs the esp on activating the fomod, then says it allready exists and needs permission to overwrite. The other files it needs to install are handled by a UI which just doesnt show up, soon as you confirm the unnecessary overwrite, its done Link to comment Share on other sites More sharing options...
AlexxEG Posted December 5, 2012 Share Posted December 5, 2012 How does your code look like now?I'm could probably write it for you, but wanna use your code as a starting point. Link to comment Share on other sites More sharing options...
nisen Posted December 6, 2012 Author Share Posted December 6, 2012 Thanks for the offer Alex, but i kept overwriting the duds and dont have that one available or know where my earlier working template is. Am just going to try another one with checkboxes, innitially tried radio buttons but they never showed up, even tho fomm reckoned the script was good. C# is just a weird language for me, dont understand how much of it fits together, Link to comment Share on other sites More sharing options...
AlexxEG Posted December 6, 2012 Share Posted December 6, 2012 So you're going to write it yourself?Btw, the reason it asked to overwrite is probably because you used both functions, you only need to use one of them. Link to comment Share on other sites More sharing options...
nisen Posted December 8, 2012 Author Share Posted December 8, 2012 Hey sry for the delay, im slowly wrapping my head around how its organized, but seems alotof scripts use different styles to do similar things so havent worked out much yet. Using both types of OnActive is probably what caused the duplicate install but havent checked to see if using only one fixed that. Its just a lot simpler atm to write it in xml, otherwise itd take me a week just to decide whos version of the way to do something ill go with. Ill return with a better grasp later. cheers Link to comment Share on other sites More sharing options...
AlexxEG Posted December 8, 2012 Share Posted December 8, 2012 Alright, good luck! :) Link to comment Share on other sites More sharing options...
Recommended Posts