Date: 06 8, 2001 3:37:23 PM

# Compiling Admin Mod Scripts 101

The point of this section is to let anyone create their own version of the Admin Mod script. This handy little program is open-source, meaning that the authors only want groveling and absolute submission from you. Unlike Bill Gates, they believe you should keep your money so that you can actually do something with your nerdy, pointless, pathetic lives.

:0)

Okay - enough of that - back to the topic at hand... You may also want to check out the section called A Beginner's Guide to Scripting in this document for more information about the scripting language works from a programmer's point of view.

This section assumes you know something about file extensions and how to properly view them on your computer. Nothing personal, but if you don't know how to do this, you probably shouldn't be running a server and chances are you don't have one running yet. Go do some learning and come back once you're ready.

#### DOWNLOADING ADMIN MOD PLUGINS

There are really three ways to download plugins:

- From the plugin page of the Admin Mod web site

- From the Admin Mod forums

- From the website of the plugin author

In any case, the task is simple to perform. From the plugin page, right-click (for Windows) on the Download link, and choose "Save Target As."

Go to the Adminmod\scripting\myscripts folder. (It is a folder that was created when you extracted Admin Mod from the zip file.) Make sure that the "Save as type" is set to Winzip (or whatever similar archive software you use) or "All files" if you are prompted. Press save and watch the file download. The result should be a file in the "myscripts" folder that ends with ".zip". The script is in the.zip file and has a ".sma" ending, there may also be a readme.txt and other files for the plugin, it is advised that you read the instructions carefully if they are provided.

If you download the script from the forum, the file will either be in the zip format, or in a .txt extension. If the first case presents itself, unzip the CONTENTS of the zip file into the Adminmod\scripting\myscripts folder. Otherwise, right click on the link, and do as mentioned above.

#### A BASIC COMPILING TUTORIAL

First of all, the scripts that you write or make changes to are plain text files with a file name "extension" of ".sma". The "extension" part of a filename is the three letters after the period at the end of the file name.

Compiling is the process of changing coding language into assembly line language, or a language that the computer can understand and use. When you compile your *.sma file, you will that the output will be a *.amx file. The *.amx file is the compiled plugin file that Admin Mod uses. There is no way to retrieve the original script from a compiled file, so do not delete your *.sma file. Keep it around just in case you might need it or want to make changes in the future.

Compiling files is really very simple. The Admin Mod v2.50 release offers unprecedented ease of use. Everything is already set up for you.

To compile your own script (or add-on scripts that you've downloaded), simply place your new .sma file in the Adminmod\scripting\myscripts directory. Note that your file name must end with. sma for all this to work, so if it ends with something like .txt or the like, you will need to rename it.

Run the compile_all.bat in your "myscripts directory" - This nifty program looks for scripts you have dropped in the "myscripts" folder (again, it expects *.sma files) and compiles them.

It then places the compiled plugins that resulted from the compiling process in the "mybinaries" folder. So, after compiling, just look in the "mybinaries" folder for your compiled plugin files, which will have the same name, except that they will end with ".amx" - which denotes the file is a compiled binary version of your script.

You now need to copy all the .amx files you just compiled into the <mod>/addons/adminmod/scripts folder (<mod> being cstrike, tfc, or any other modification you are hosting). Unless you copy them here, your game server cannot use them.

The final step in making the plugin files work is adding their locations to the plugin.ini file. This file was created when you first installed Admin Mod. Find the file in the <mod>/addons/adminmod/config directory (i.e. half-life\cstrike\addons\adminmod\config or half-life\tfc\addons\adminmod\config).

Open the plugin.ini file and add the location of the plugins you want to add. Usually you can just add the plugin to the bottom of the list of plugins already in your plugin.ini file. The format used to specify a plugin is:

addons/adminmod/scripts/plugin_nameofplugin.amx

For example, if I downloaded the plugin_coffee.sma file, the file name after I compiled it would be "plugin_coffee.amx" to add that file to your plugins, simply add addons/adminmod/scripts/plugin_coffee.amx

#### ERRORS AND WARNINGS DURING COMPILING

Disregard any "Warnings" in the text that is displayed on the console screen during compiling sessions, as they are simply warnings.

However, if you get "errors" during compiling, you are in trouble. The compiling process will not produce a valid *.amx file when it encounters errors (or if it does, the .amx file will have a file size of 0 bytes). So, in order to come up with a working plugin, you have to go and find the errors in your code and fix them.

Remember that errors can occur due to faults in lines that come both before and after the line number indicated by the compiler. The line number indicated in an error message is simply the one where the compiler realized it could not make sense of what was going on. The problem that the compiler choked on could have occurred somewhere else in the script, but as the compiler read the code it did not recognize the error until it ran across something else that didn't work. The most common errors are spelling, loose/missing/extra braces, and undefined variables.

Lately there have been many reports of compilation errors reporting a missing ";" such as this example:

plugin_xxxxxx.sma(91) Error [1]: expected token: ";", but found "xxxxx"

To rectify this error, open plugin_xxxx.sma into your favorite editor and go to line corresponding to the number between parenthesis. In this case, scroll down to line 91. Look for the first line of code (non-blank) preceding (before) the line the compiler reported. If there is a missing ";" at the end of that line, add it, save the change you made and recompile. The errors should be gone.

In the code used to make Admin Mod plugins, one loose brace (braces are the { and } characters) can create a great deal of errors, so after every error you correct, recompile and see if that solved the problem. Keep on searching for mistakes until the compiling process returns a valid *.amx file.

Then have fun!

See also: A Beginner's Guide to Scripting