DModule/Coding
From DevDracoBlue
DModule-Docs • Download • Projects • Coding Style • API • Values • Defines • Modules • Tutorial • Commandline
Contents |
Limits
For easier understanding and secure compiling of your sourcecode, you shall stay within the following limits.
- Modulenames 1 to 10 characters, only a..z0..9
- Eventnames 1 to 15 characters, only A..Za..z0..9
- Valuenames 1 to 15 characters, only A..Za..z0..9
How to documentate the code
Example
/** * Calculate the size of a given string * @param string st The string, of which you want to know the size * @ingroup core * @return int */ strlen(const st[])
Groups
If you can't find a fitting group, don't add one.
- core
- All core functionality
- vehicle
- Work with/on vehicles
- player
- Work with/on players
- object
- Work with/on objects
- enviroment
- Environment like weather and stuff
How DModule works
You will read how to write a sample module with DModule. We will name it printtest. Also we will use default english language and we will work under project test. First of all we must create new folder in modules directory (modules or modules.test if it's private project module) named printtest.
Required files
In every module we must create 3 files:
- printtest.dmodule.inc
- The main file containing module script, we will fully cover it in API section. The file in our example contains:
printtest_EverySecond() {
print(gettext(0,PRINTTEST_TEXT))
}
- printtest.depends.txt
- The list of dependencies (simply the list of modules which this module requires), in this example:
dcore
- printtest.english.lng
- The language file, all the messages the player can receive should be stored here - important only if you are preparing multilingual project, but even if only using single language, good practice is to keep it here. In this example:
PRINTTEST_TEXT="Hello2"
Before it will be ready to compile you must declare that you will use printtest module - to do this edit settings.cfg
Description
When you will try to compile this project it will:
- check settings.cfg file, fetch modules listed there - it will find printtest module
- search in modules\, modules.c\, modules.d\ or in any other directory you've set in settings.cfg, it will find one in modules\
- will load printtest.dmodule.inc and add it to gamemode script
- it will find gettext() function - means it will search in printtest.english.lng row named PRINTTEST_TEXT and insert in that place message text
- it will parse printtest.depends.txt file, and do every step listed in here, but instead of searching for printtest it will look for dmodule
- it will compile everything into one *.amx file
Now you can go into projects directory and run server.exe located in there