AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   Plugin-autoreload (https://forums.alliedmods.net/showthread.php?t=106320)

Timiditas 10-13-2009 19:26

Plugin-autoreload
 
1 Attachment(s)
Thought I'd share this. Simple, trivial plugin but makes life easier while developing/debugging an SM plugin.

When the attached plugin is loaded, it creates a list of all files and timestamps in addons/sourcemod/plugins (ignoring if they are loaded or not) , excluding itself.
Every 2 seconds, it checks if one of the timestamps has changed and fires "sm plugins reload %s" on the respective plugin.

berni 10-14-2009 04:30

Re: Plugin-autoreload
 
That's a neat idea :)
I could imagine making an extension for this, to replace the timer with something that watches the folder and reloads plugins instantly :)
That should become part of sourcemod then.

Matheus28 10-15-2009 10:49

Re: Plugin-autoreload
 
Nice work!
Thanks you.

DarthNinja 11-26-2009 15:02

Re: Plugin-autoreload
 
Wow, I wish I'd found this sooner :up:
+rep

pvtschlag 11-26-2009 22:48

Re: Plugin-autoreload
 
I recently started with SourcePawn and quickly found it annoying to compile, upload, and reload when debugging. Your plugin looks useful, but since it seems I'm not the only person who finds the process tedious I would like to share a small batch file I put together that makes my life so much easier.

You can just drag a .sp file ontop of this batch file and it will do the rest. However, I have Notepad++ with SourcePawn highlighting setup to run it when I hit Ctrl + F7. This makes debugging/testing painless.

It even has a bit of error checking so it stops the process if the plugin fails to compile which lets you see the error messages returned by the SourcePawn compiler.

You can get the clircon tool that is used to reload the plugin from this thread.

Code:

REM USEAGE <thisfile>.bat "Path\to\plugin.sp"

@echo off

REM START OF CONFIG

REM This is the path to the directory that contains spcomp.exe
set spcomppath="C:\path\to\spcomp\"

REM This is the FTP Address to connect to
set ftpaddr=127.0.0.1

REM This is the FTP User to login as
set ftpuser=ftpuser

REM This is the password for the FTP user
set ftppass=ftppass

REM This is the path on the plugin should be uploaded to on the FTP
set ftppath="/path/to/sourcemod/plugins/"

REM This is the path to the directory that contains clircon.exe
set clirconpath="C:\path\to\clircon"

REM This is the address to the server you want to reload the plugin on
set rconaddr=127.0.0.1

REM This is the port for the server
set rconport=27015

REM This is the RCON password to use for the server
set rconpass=rconpass

REM END OF CONFIG

REM Compile the plugin
cd %spcomppath%
spcomp %1

REM If the plugin failed to compile skip the rest of the script and go to the final pause
if not exist %~n1.smx goto end

REM Create a file with a list of FTP commands
echo user %ftpuser%> ftpcmd.dat
echo %ftppass%>> ftpcmd.dat
echo cd %ftppath%>> ftpcmd.dat
echo bin>> ftpcmd.dat
echo put %~n1.smx>> ftpcmd.dat
echo quit>> ftpcmd.dat

REM Connect to the FTP server and execute the saved commands
ftp -n -s:ftpcmd.dat %ftpaddr%

REM Cleanup temporary FTP command file
del ftpcmd.dat

REM Cleanup compiled version of plugin
del %~n1.smx

REM Execute rcon commands to reload the plugin
REM I don't use reload here because it will not work if the plugin is not already load
cd %clirconpath%
clircon -P"%rconpass%" -a%rconaddr% -p%rconport% sm plugins unload %~n1
clircon -P"%rconpass%" -a%rconaddr% -p%rconport% sm plugins load %~n1

:end
REM Pause to read output
pause


Dr. Greg House 01-04-2014 16:30

Re: Plugin-autoreload
 
Quote:

Originally Posted by berni (Post 961440)
That's a neat idea :)
I could imagine making an extension for this, to replace the timer with something that watches the folder and reloads plugins instantly :)
That should become part of sourcemod then.

SM already does this onmapchange. Maybe you won't have to "reinvent the wheel" (get it? :P) after all.

Mitchell 01-04-2014 17:20

Re: Plugin-autoreload
 
Quote:

Originally Posted by Dr. Greg House (Post 2081149)
SM already does this onmapchange. Maybe you won't have to "reinvent the wheel" (get it? :P) after all.

This is a necropost, lol.
He is saying that when ever a plugin is edited and uploaded the extension will notice it and reload it instantly with out map change or putting in any commands.

Dr. Greg House 01-06-2014 22:38

Re: Plugin-autoreload
 
Quote:

Originally Posted by Mitchell (Post 2081167)
This is a necropost, lol.[...]

Oh dammit I didn't notice. -.-
I'm sorry.


All times are GMT -4. The time now is 03:26.

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