Raised This Month: $ Target: $400
 0% 

[SM] Plugin load/unload management


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 06-22-2012 , 09:46   Re: [SM] Plugin load/unload management
Reply With Quote #1

Quote:
Originally Posted by berni View Post
The question is just, why would someone do this ? Yes, this is a serious question.
I'm using a self-unloader on a game mode that I'm working on. It unloads the plugin if it detects an unsupported map. SourceMod automatically loads it again when the map changes.
__________________
Dr. McKay is offline
Thrawn2
Veteran Member
Join Date: Apr 2009
Old 06-22-2012 , 10:07   Re: [SM] Plugin load/unload management
Reply With Quote #2

Quote:
Originally Posted by Dr. McKay View Post
I'm using a self-unloader on a game mode that I'm working on. It unloads the plugin if it detects an unsupported map. SourceMod automatically loads it again when the map changes.
ouch. don't do something like this, it's an ugly workaround.
Plugins that can only be disabled by unloading them should be unapproved right away IMHO.

Rather add a bUsable variable or sth like that, set it in OnMapStart and check its value everytime your plugin does something.
__________________
einmal mit profis arbeiten. einmal.
Thrawn2 is offline
psychonic

BAFFLED
Join Date: May 2008
Old 06-22-2012 , 10:30   Re: [SM] Plugin load/unload management
Reply With Quote #3

Quote:
Originally Posted by Thrawn2 View Post
ouch. don't do something like this, it's an ugly workaround.
Plugins that can only be disabled by unloading them should be unapproved right away IMHO.

Rather add a bUsable variable or sth like that, set it in OnMapStart and check its value everytime your plugin does something.
QFT
psychonic is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 06-22-2012 , 10:54   Re: [SM] Plugin load/unload management
Reply With Quote #4

or use SetFailState, this pauses the plugin until it is reloaded.

Quote:
Originally Posted by Sourcemod API
Causes the plugin to enter a failed state. An error will be thrown and the plugin will be paused until it is unloaded or reloaded
but the best way is to just add a mapcheck OnMapStart(), yeah.


Quote:
Originally Posted by Dr. McKay View Post
I'm using a self-unloader on a game mode that I'm working on. It unloads the plugin if it detects an unsupported map. SourceMod automatically loads it again when the map changes.
No, sourcemod only does that if it is configured to do so, if someone changes this settings your plugin will simply fail.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0

Last edited by berni; 06-22-2012 at 10:57.
berni is offline
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 06-22-2012 , 10:57   Re: [SM] Plugin load/unload management
Reply With Quote #5

Quote:
Originally Posted by Thrawn2 View Post
ouch. don't do something like this, it's an ugly workaround.
Plugins that can only be disabled by unloading them should be unapproved right away IMHO.

Rather add a bUsable variable or sth like that, set it in OnMapStart and check its value everytime your plugin does something.
Might as well unapprove Prophunt, it does this.
Quote:
Originally Posted by berni View Post
or use SetFailState, this pauses the plugin until it is reloaded.



but the best way is to just add a mapcheck OnMapStart(), yeah.
Why? I don't really want to spew the error logs if no real error occurs.



Quote:
Originally Posted by berni View Post
No, sourcemod only does that if it is configured to do so, if someone changes this settings your plugin will simply fail.
Where's the option to change this?
__________________

Last edited by Dr. McKay; 06-22-2012 at 10:58.
Dr. McKay is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 06-22-2012 , 11:13   Re: [SM] Plugin load/unload management
Reply With Quote #6

Quote:
Originally Posted by Dr. McKay View Post
Why? I don't really want to spew the error logs if no real error occurs.
That really depends on your needs. If the plugin was made for servers only running gungame maps, you want to show the serveradmin the reason why the plugin suddenly dissapears from the plugin list on a capturetheflag map.

At least keep sure that the serveradmin knows why the plugin isn't doing anything.


Quote:
Originally Posted by Dr. McKay View Post
Where's the option to change this?
plugin_settings.cfg
Code:
/**
 *   Each sub-section of "Plugins" should have a title which specifies a plugin filename.
 * Filenames have a wildcard of *.  Appending .smx is not required.
 * If the filename has no explicit path, it will be patched to any sub-path in the plugins folder.
 *
 *   Available properties for plugins are:
 * "pause"			- Whether or not the plugin should load paused - "yes" or "no" (default)
 * "lifetime"		- Lifetime of the plugin.  Options:
 * "mapsync"	 	- Plugins should be reloaded on mapchange if changed (default)
 * "global"	 		- Plugin will never be unloaded or updated
 * "blockload" 		- Plugin will always be blocked from loading.  Implicit (automatic) loads 
 *					  produce no error, but explicit (manual) loads will show an error message.
 *					  (Options are one of "yes" or "no")
 *
 * You can also have an "Options" section declaring options to pass onto the JIT:
 * "profile"	- Bit flags for profiling level.  Add flags together to reach a value.
 *				  WARNING: Profiler is _ALPHA_ software!  Use it at your own risk for 
 *				  development cycles only (not production setups).
 *				  See the wiki article "SourceMod Profiler" for more information.
 *				  1 - Profile natives
 *				  2 - Profile callbacks
 *				  4 - Profile internal plugin function calls
 */
	
"Plugins"
{
	"*"
	{
		"pause"			"no"
		"lifetime"		"mapsync"
		
		"Options"
		{
		}
	}
}
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0

Last edited by berni; 06-22-2012 at 11:15.
berni is offline
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 06-22-2012 , 11:18   Re: [SM] Plugin load/unload management
Reply With Quote #7

Quote:
Originally Posted by berni View Post
That really depends on your needs. If the plugin was made for servers only running gungame maps, you want to show the serveradmin the reason why the plugin suddenly dissapears from the plugin list on a capturetheflag map.

At least keep sure that the serveradmin knows why the plugin isn't doing anything.
Yeah, it does log a message to the regular logs before it unloads itself.

Whatever, I'll just add in a "operate" bool. It'll check itself OnMapStart, along with the enable cvar. Toggling the enable cvar will only take effect on the next mapchange. The way that the plugin manages rounds is pretty weird, and I don't really want to take any risks.
__________________
Dr. McKay is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:33.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode