View Single Post
pvtschlag
Member
Join Date: Nov 2009
Old 11-26-2009 , 22:48   Re: Plugin-autoreload
Reply With Quote #5

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
pvtschlag is offline