Difference between revisions of "Installing New Modules"

From ASSS Wiki
Jump to: navigation, search
m (minor formatting adjustment. someone might want to learn wiki and reformat it.)
Line 1: Line 1:
When you want to add more functionality to your server you can install new custom modules. Differences in server versions often mean something will break in a module, compiling from source can  help fix this.
+
apple cows
 
 
== C modules ==
 
 
 
=== Using the ASSS Makefile ===
 
The Makefile distributed with ASSS is designed to allow adding new code to it easily. This is probably the easiest way to get a new module compiling, because all the correct compiler flags are supplied for you.
 
 
 
Create a directory for your module as a subdirectory of <tt>src</tt>, the directory containing all the ASSS code.
 
<pre>
 
$ cd asss-1.3.5/src
 
$ mkdir mymod
 
</pre>
 
 
 
Create a <tt>mymod.mk</tt> file within that directory that looks like this:
 
<pre>
 
mymod/mymod.$(SO): mymod/mymod.o
 
</pre>
 
 
 
All <tt>*.mk</tt> files (let's call them "Makefile fragments") in any subdirectories will be included by the big Makefile automatically. Two fragments come in the contrib directory in the ASSS package, which you might want to look at as examples.
 
 
 
Note that we use a Makefile variable, <tt>$(SO)</tt>, instead of typing <tt>.so</tt> directly. That's so that the same Makefile works on windows, where modules have to be named <tt>mymod.dll</tt> instead of <tt>mymod.so</tt>. Also note that all the filenames have to be prefixed with the directory they're in. That's because make considers all files relative to the directory it runs in.
 
 
 
Now compile your module and copy it into your bin directory:
 
<pre>
 
$ make mymod/mymod.so
 
... compiler output ...
 
$ install mymod/mymod.so ../bin
 
</pre>
 
 
 
Note that you have to specify the target name manually; it won't get built or copy by default if you just type <tt>make</tt>. If you do want your custom module to get built and copied automatically, along with the rest of ASSS, when you type just <tt>make</tt>, add this line at the top of the Makefile fragment:
 
<pre>
 
ALL_STUFF += mymod/mymod.$(SO)
 
</pre>
 
 
 
Also note that you can list more than one <tt>.o</tt> file on the line. All will be compiled into the same shared library.
 
 
 
The module specifier for this new module will be <tt>mymod:mymod</tt>, for use in modules.conf or with ?insmod.
 
 
 
=== Using a custom Makefile ===
 
Sometimes you might want to create your own Makefile, if you need to use custom compilation options, or a different source file layout. Here is a very basic one (they can get very long).
 
<pre>
 
# simple makefile
 
 
 
OUTFILE = somefile.so
 
MODULES = autoturret.o
 
 
 
CC = gcc -std=gnu99 -pipe
 
CFLAGS = -s -O2 -Wall
 
 
 
all: ${OUTFILE}
 
 
 
${OUTFILE}: ${MODULES}
 
${CC} -fPIC -shared -o ${OUTFILE} ${MODULES}
 
 
 
install: ${OUTFILE}
 
install ${OUTFILE} ../bin/${OUTFILE}
 
 
 
clean:
 
rm -f ${OUTFILE} ${MODULES}
 
</pre>
 
You can change the name of the resulting file with ''OUTFILE'' and add more modules on the ''MODULES'' line. Note: the indentation must be a tab and not a bunch of spaces.
 
 
 
To use a makefile one would type something like this:
 
<pre>
 
$ make -f some.mk
 
$ make -f some.mk install
 
</pre>
 
The ''-f'' switch tells make to use ''some.mk'' instead of the default which is 'Makefile'. Also two commands are used so you can spot any errors during compilation.
 
 
 
=== With Dev C++ ===
 
This tutorial uses [http://www.bloodshed.net/dev/devcpp.html Dev C++ 4.9.9.2] ASSS 1.4.0 and Smong's [http://toktok.sscentral.com/ss-asss.html nomysql] module. Although it should work with all modules and a recent version of Dev C++.
 
 
 
==== Step 1 ====
 
[[Image:devcpp-140-step1.png|right]]
 
Load up Dev C++ and go to ''File'', ''New'', ''Project''.
 
<br><br><br><br>
 
<br><br>
 
 
 
==== Step 2 ====
 
[[Image:devcpp-140-step2.png|left]]
 
Choose the DLL project and give the project a descriptive name. Note: the name of the project will also be the name of the final .dll file, more about that later. Make sure to select ''C Project''.
 
<br><br><br><br>
 
<br><br><br><br>
 
<br><br><br><br>
 
 
 
==== Step 3 ====
 
[[Image:devcpp-140-step3.png|right]]
 
'''A)''' The DLL project comes with some template files. Remove them by right clicking on their tab and selecting close.
 
 
 
'''B)''' Click the icon of a document with a plus sign on it. This will open a dialog that lets you add files to the project. Here you can add the module's source files. For nomysql this is just nomysql.c. Also add util.c from from asss/src/main. You can download the ASSS source code from [http://sscx.net/asss sscx.net/asss].
 
<br><br>
 
 
 
==== Step 4 ====
 
[[Image:devcpp-140-step4.png|left]]
 
Before compiling some include and library paths must be setup. Go to ''Project'', ''Project Options'' from the menu bar.
 
<br><br><br><br>
 
<br><br><br>
 
 
 
==== Step 5 ====
 
[[Image:devcpp-140-step5.png|right]]
 
First add pthread.dll by going to the ''Parameters'' tab and clicking on ''Add Library or Object''.
 
<br><br><br><br>
 
<br><br><br><br>
 
<br><br><br><br>
 
<br><br><br><br>
 
 
 
==== Step 6 ====
 
[[Image:devcpp-140-step6.png|left]]
 
You need to change the file type filter in the open file dialog to ''All Files (*.*)''. Then select pthread.dll (actual name may vary).
 
<br><br><br><br>
 
<br><br><br><br>
 
<br><br><br><br>
 
<br>
 
 
 
==== Step 7 ====
 
[[Image:devcpp-140-step7.png|right]]
 
Now add the following include directories:
 
* asss/src
 
* asss/src/include
 
* asss/windeps
 
These are needed so the compiler can find all the .h files that the module source requires.
 
<br><br><br><br>
 
<br><br><br><br>
 
<br><br><br><br>
 
 
 
==== Step 8 ====
 
[[Image:devcpp-140-step8.png|left]]
 
This part is optional. You may want to change the name of the output .dll file and you can do so from the ''Build Options'' tab. The default name for the output .dll file is the name you gave the project when you created it.
 
<br><br><br><br>
 
<br><br><br><br>
 
<br><br><br><br>
 
<br><br><br>
 
 
 
==== Step 9 ====
 
[[Image:devcpp-140-step9.png|right]]
 
Now click the compile button. It looks like four colored squares.
 
<br><br><br>
 
 
 
 
 
==== Step 10 ====
 
[[Image:devcpp-140-step10.png|left]]
 
If all goes well you should see this dialog. Congratulations on compiling your first module!
 
<br><br><br><br>
 
<br><br><br><br>
 
<br><br><br><br>
 
 
 
=== With MSVC ===
 
-write me-
 
 
 
=== By hand ===
 
You may need to execute the commands to compile from source, and then move the resulting .so file to the bin directory using install if running ASSS on Linux. If you are running ASSS on Windows and are updating a module you should shutdown the server before copying the .dll file to the bin directory.
 
 
 
== Python modules ==
 
No compiling is necessary. Move the .py file to the bin directory. There may be 'softcoded' settings within the .py file, so examine any comments near the top of the file for instructions.
 
 
 
== Configuring ==
 
It is a good idea to examine any documents that came with the module. There may be comments at the top of the source code and if you are unsure you can do a search on the file for 'cfg->Get', which will return all customisable settings this module reads.
 
<pre>
 
$ grep 'cfg->Get' src/module.c
 
$ grep 'cfg.Get' bin/module.py
 
</pre>
 
I suggest putting module settings in their own .conf file and include this from your [[arena.conf]].
 
 
 
There may also be commands that you must set the permissions for. You can add new commands to the group files found in conf/groupdef.dir. Prefix cmd_ to the command to allow users to send the command publicly and privcmd_ for team and private targets.
 
 
 
Finally you must load the module. Either add an entry to conf/modules.conf or use ?insmod. Some modules are arena specific, in which case you must also add it to your arena.conf Modules:AttachModules setting or use ?attmod.
 
 
 
If you have any questions left chances are they have already been answered at the [[Module General Faq|Module FAQ]].
 
 
 
[[Category:Module]]
 
[[Category:Guides]]
 

Revision as of 03:23, 30 November 2005

apple cows