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-21-2012 , 13:15   [SM] Plugin load/unload management
Reply With Quote #1

These are a few stocks that a plugin can use to unload/reload itself.

PHP Code:
stock ReloadMyself() {
    
decl String:filename[256];
    
GetPluginFilename(INVALID_HANDLEfilenamesizeof(filename));
    
ServerCommand("sm plugins reload %s"filename);
}

stock UnloadMyself() {
    
decl String:filename[256];
    
GetPluginFilename(INVALID_HANDLEfilenamesizeof(filename));
    
ServerCommand("sm plugins unload %s"filename);

__________________

Last edited by Dr. McKay; 06-21-2012 at 13:18.
Dr. McKay is offline
Starbish
AlliedModders Donor
Join Date: Oct 2011
Location: South Korea
Old 06-21-2012 , 13:38   Re: [SM] Plugin load/unload management
Reply With Quote #2

nice
__________________
Starbish is offline
minimoney1
SourceMod Donor
Join Date: Dec 2010
Old 06-21-2012 , 13:56   Re: [SM] Plugin load/unload management
Reply With Quote #3

Could even support other plugins by doing this:
Code:
stock ReloadPlugin(Handle:plugin = INVALID_HANDLE) {     decl String:filename[256];     GetPluginFilename(plugin, filename, sizeof(filename));     ServerCommand("sm plugins reload %s", filename); } stock UnloadPlugin(Handle:plugin = INVALID_HANDLE) {     decl String:filename[256];     GetPluginFilename(plugin, filename, sizeof(filename));     ServerCommand("sm plugins unload %s", filename); }
But I don't know who would want to reload other plugins by their handles...
Edit: Ooops typo, thanks 11530

Last edited by minimoney1; 06-22-2012 at 06:51.
minimoney1 is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 06-22-2012 , 07:05   Re: [SM] Plugin load/unload management
Reply With Quote #4

Quote:
Originally Posted by Dr. McKay View Post
These are a few stocks that a plugin can use to unload/reload itself
The question is just, why would someone do this ? Yes, this is a serious question.
__________________
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
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 , 09:46   Re: [SM] Plugin load/unload management
Reply With Quote #5

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 #6

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 #7

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 #8

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
disawar1
AlliedModders Donor
Join Date: Aug 2011
Location: Russian
Old 08-07-2012 , 05:52   Re: [SM] Plugin load/unload management
Reply With Quote #9

This is very useful Plugin Manager
__________________
disawar1 is offline
Reply


Thread Tools
Display Modes

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