Jump to content

C# install script, how to detect installed esps


nisen

Recommended Posts

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

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 by Alexx378
Link to comment
Share on other sites

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 by nisen
Link to comment
Share on other sites

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 by Alexx378
Link to comment
Share on other sites

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

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...