Jump to content

Unload/Reload Callback [Solved]


Anarchiyx3

Recommended Posts

Hey guys,

I would like to extend my plugin "Be A Prison Guard". I need a callback, when LSPDFR Reload/Unload my Assembly. 

I tried to solve it with Finally(), but it didnt work.

Any ideas?

 

 

//Edit: All right, have found a solution!

Best regards,

Anarchiyx3

Edited by Anarchiyx3

Yeeeah

Link to comment
Share on other sites

What kind of operation do you want to perform on unloading?

With non-static class you might use a destructor:

http://www.dotnetperls.com/destructor

StaticFinalizer is useful with static classes and it does work when used properly.

Link to comment
Share on other sites

54 minutes ago, Anarchiyx3 said:

//Edit: All right, have found a solution!

Might be worth posting here for others that are interested.

My YouTube: Click here. 

My Discord Server - https://discord.gg/0taiZvBSiw5qGAXU

Useful post? Let me and others know by clicking the Like button.
Check out my many script modifications! 
Having issues? LSPDFR Troubleshooter by Albo1125.

Link to comment
Share on other sites

This works for me:

 

private static StaticFinalizer sf;

public override void Initialize()
{
	sf = new StaticFinalizer(delegate {
   		CleanYourScript();
    });
}

public static void CleanYourScript()
{
	//Do your stuff here
	Game.LogTrivial("Be A Prison Guard has been cleaned");
}

 

Edited by Anarchiyx3

Yeeeah

Link to comment
Share on other sites

You might simplify the code this way:

private static StaticFinalizer sf;

public override void Initialize()
{
	sf = new StaticFinalizer(CleanYourScript);
}

public static void CleanYourScript()
{
	//Do your stuff here
	Game.LogTrivial("Be A Prison Guard has been cleaned");
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...