Using Textpad to Author Plugins

By using a text editor that supports syntax highlighting and the execution of compiler tools, you can greatly reduce the time it takes you to write and debug plugins. Textpad is not the only product capable of doing this - Ultra edit & Programmers File Editor are two others that spring to mind. However, textpad has a very clean and easy to use GUI, and the shareware nagging is minimal if you don't register it.

Downloading Textpad

Textpad is a shareware text editor, available for download at www.textpad.com. It has a no-brainer installation program.

You should then download the Admin Mod syntax definitions file and save this in the folder "Program files\Textpad 4\System".

Step 1: Create an new document class

Run textpad, and select "New document class..." from the Configure menu, and complete the wizard as follows:

Step 2: Set the class properties

Choose "Properties" from the Configure menu, and select the Admin Mod document class. Then enable the following options:

Step 3: Set the colours

Click on colours option in the tree, and set the keywords colours. You are of course free to pick your own colour scheme, but the following will match the examples in this guide:

Keywords 1Blue
Keywords 2Maroon
Keywords 3Navy
Keywords 4Blue
Keywords 5Fuchsia
Keywords 6Fuchsia

Step 4: Set tabulation

Click on the tabulation option in the tree, and both the default tab spacing and indent size to 2. Indenting code by 8 characters will soon have it going of the right hand side of your screen.

Step 5: Integrating the Small compiler

Scroll to the bottom of the preferences tree, and click on Tools then choose to add a DOS program. Enter the full path to your compile.bat file followed by $file as the program name - e.g.

C:\Games\Half-life\Admin\scripting\myscripts\compile.bat $File

Now press Apply and a new entry will appear in the tree as a child of tools. Expand tools and click on the new entry. Now set:

Compiling Plugins With Textpad

Load an sma file into the editor. It should be syntax highlighted if you have setup the document class correctly.

To compile, select compile.bat from the tools menu, or press the keyboard shortcut shown in that menu. The output of the compiler is shown as new document in the editor.

If any errors have occurred, you can double click on the error message to go to the offending line of source code. You can then press the F4 key to cycle though all the other lines on which errors occurred. Each error message is displayed in the status bar as you do this.

Modifying Compile.bat

As a final step, you can change compile.bat to output the compiled AMX file directly to your Admin Mod scripts folder instead of to mybinaries.

Change the line :

..\compiler\sc -i..\include -e%1_error.txt -o..\mybinaries\%~n1.amx %1
To (changing the path to your Admin Mod scripts folder as appropriate):
..\compiler\sc -i..\include -e%1_error.txt -oC:\Games\Half-Life\cstrike\addons\adminmod\scripts\%~n1.amx %1