View Single Post
Author Message
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 03-13-2020 , 12:46   [DEV] Autoreload plugins
Reply With Quote #1

Description:
By default, SourceMod reloads plugin on map change only (in case its file modification time is changed).
This plugin does the same every 2 seconds (adjustable).
*New features:
- Notify in chat about reloading, loading, unloading.
- Show plugin load status in chat
- Can load newly added plugins (you must set it in ConVars!!!)
- Can reload plugin even if the previous time it is failed
- Can reload translation files cache (when some plugin is changed)
- Scan in subfolders (recursively)
- Ensure plugin is really loaded in case it was fault due to attempt to reload it in middle-time of file uploading
- ConVars allowing to select delay (shorter, to track changes faster - for dev., or vice versa, longer delay to decrease CPU load - for production server)
- Ability to show part of error log in chat when plugin failed to load
- More optimized.
Commands:
PHP Code:
// Forcibly check plugin files for newly updated and reload if any
sm_pluginsreload 
Settings (ConVars):
Located at: cfg/sourcemod/sm_autoreload.cfg
PHP Code:
// Enable this plugin? (1 - Yes, 0 - No)
sm_autoreload_enable "1"

// * Delay between updates (in sec.). Set 0 to disable timer at all.
sm_autoreload_delay "2.0"

// ** Do we need to check for new plugin files appearing? (1 - Yes, 0 - No).
sm_autoreload_track_new "0"

// Where to show info about the reloaded plugin? (0 - Nowhere, 1 - Server, 2 - Chat, 4 - Console. Sum them to combine several options)
sm_autoreload_show_info "3"

// How many lines of error log to display when the plugin is failed to load? (0 - to disable)
sm_autoreload_error_lines "4"

// Display chat message to admins only defined by these admin flags (leave empty - to display for all users)
sm_autoreload_msg_flag "" 
*Notice 1: I would suggest setting like 5.0 - 10.0 sec. delay for production server where you don't need so quick plugin check.
**Notice 2: track new files cause more disk operations since the entire folder has re-read each time. Leave disabled to improve performance.
Forwards:
Spoiler


Using:
Place smx in "plugins" folder.
Credits:
- Timiditas - author of idea and original plugin
- SilverShot - testing, give me some ideas and forcing me find solutions ^^
- Marttt - reload translation cache suggestion
Full changelog:


// TODO:
- Integrity check.
- Adding dynamically loaded/unloaded plugins to tracking list. Also, need help in issue #1482.


Donate
Donates are very appreciated and welcomed for further inspiration, make me happy, and make next updates came out more often:
- Patreon (Paypal)
- BitCoin
- Ю.Money
Attached Files
File Type: zip ReloadPlugins.zip (20.7 KB, 362 views)
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 10-06-2022 at 12:40.
Dragokas is offline