# Compiling scripts by hand

You can compile your script at the command line simply enough, assuming you are comfortable working at the command line and that you have a basic knowledge of directory traversal in text mode.

Start in the "myscripts" directory of your Admin Mod installation, and compile using sc (or sc.exe) with the command:

..\compiler\sc -i..\include xxx.sma

where xxx.sma is replaced with your script name.

Note: This is for Win32, for Linux replace all backslashes ( “ \ “ ) with forward slashes ( “ / ” )

You might see either warnings or errors, or both, displayed. Warnings are okay – one of the more common is a warning that your indentation is “loose” – Okay, so you’re a little sloppy, not that big of a deal. However, errors are a problem – they indicate that there is a flaw that is keeping the compiler from successfully parsing and compiling your script. The key thing to look for is for the compiler to show you no errors. If you see the message “Compilation aborted” at the end of it’s output, it did not work. If you get nothing but warnings and maybe even a message that says, “Done,” you have a compiled script that is ready to test in the server environment.

A note about working with the compiler output:

Small Compiler errors and warnings contain some useful information that can help you in determining what is wrong with your script when it generates them. The first item on an error or warning line is the name of the file you are compiling, followed by a number in parentheses, such as “(217)” – This is the line number where the compiler encountered the problem, which is useful information if you are trying to find out where the problem might be.

Keep in mind that a list of 20 errors on 20 lines might just be dependant upon one problematic line in the script. For example, if I accidentally typed three curly-brackets ( {{{ ) in a row instead of the proper single curly bracket, I might get errors on multiple lines according to the compiler. So, I would choose to go to the first listed line with an error and look there, make my fix, and then recompile and see what happens.

Remember: recompile often to check to see where you’re at, and always make periodic backups of files, so that you can go back to an older version of your script when your brain gets so mushy from vapor lock that you can’t remember what changes you’ve made.

If all goes well, the compiler produces a file called yourscriptname.amx, which will be located in the same directory as your original yourscriptname.sma file. Now copy the .amx to the /dlls directory for your mod (i.e. half-life\cstrike\dll) and fire up the server and test. Rinse and repeat until you get the desired results.

NOTE - Linux and windows .amx files ARE DIFFERENT, You MUST recompile for each platform. It’s the same source code file, just slightly different binaries.

More on Manual Compiling …

Isn’t there an easier way to do these compiling things? What’s all this dot-dot-slash stuff??? Sheez!

The simple answer is, “Yes.” You could copy all of the files from the \include directory, along with the sc.exe and your .sma files, into a new directory and run it from there, thus negating the need to do all the dot-dot-slash stuff. But you’re learning here, and if you’re going to be doing this sort of stuff it helps to understand what’s going on, and so here’s some information about the dot-dot-slash concept for those who are command-line challenged:

The dots and slashes are part of how we communicate with the computer to tell it where we want to go, or where we want it to go to find something on the drive. Here is an attempt to illustrate what those things mean:

. | (a single dot) | This refers to the directory you are in now
.. | (two dots) | This tells the computer to look in the “parent” directory
../mydirectory | (dot-dot-slash-dir_name) | Tells the computer to go to the parent directory (one level above) and then look for a directory called “mydirectory” and go there.
../mydirectory/cool.exe | (dot-dot-slash-dir_name-slash-program_name) | Tells the computer to go to the parent directory (one level above) and then look for a directory called “mydirectory” and go there, and run the program called “cool.exe”