amxx模块开发官方文档阅读理解1-Introduction
条评论Introduction
Before writing an AMX Mod X module, you should have a good understanding of C and pointers.
模块开发需要熟练掌握C语言和指针。
AMX Mod X modules are significantly more advanced than normal AMX Mod modules. Here are a few main differences:
- API - AMX Mod X API is both backwards and forwards compatible. The actual attach interface and function prototypes will never change, what will change is what functions are available.
API的调用方式在不同版本中都是相同的,不同的是,在新版本中可能会弃用一些API,也可能会新增一些API,但都不会改变API的调用方式和参数类型。
- Metamod - AMX Mod X modules do not attach to Metamod. They attach to a Metamod abstraction layer called FakeMeta - the functionality, however, is the same.
AMXX模块不会直接调用Metamod,而是会先调用FakeMeta(Metamod的抽象层)
- M/SDK - AMX Mod modules are built by manually writing interfaces and including a module header. With AMX Mod X, you simply add an MDK to your project. This MDK includes the memory manager, struct headers, core include references, configuration details, and .def alignment procedures (so you don’t need to make a .def file).
MDK可以理解为Module SDK,专门用于模块开发的SDK,包括2个源码文件(amxxmodule.cpp和amxxmodule.h,这2个文件是不需要修改的,只需要在模块项目中包含
.h文件即可)和1个配置文件(moduleconfig.h,可以配置模块的基本信息,以及模块的功能),也就是说在开发模块时,把amxxmodule.h和moduleconfig.h加入到项目中即可(在新版本中,amxxmodule.h会自动加载项目文件中的moduleconfig.h文件,所以,在你的代码中只需要把amxxmodule.h文件include进来就可以了,而你的moduleconfig.h文件只需要放置在模块项目的根目录下即可)。
- AMX Mod X API uses an important function which will return a function pointer from the core based on the request:
void *ReqFuncPtr(cost char *name);
This lets the module retrieve any internally exported function from the AMX Mod X core, so you don’t have to recompile the module every time a new function is added to a struct.相对AMX而言,AMXX可以通过ReqFuncPtr来获取AMXX的核心库dll/so文件的函数指针,在代码结构上,我们只需要完成自己module模块的开发和编译即可,不需要重新编译AMXX的核心代码。
To begin, add “amxxmodule.cpp” and “amxxmodule.h” to your project. You will never need to edit these.
Add “moduleconfig.h”. This will let you configure your module. There are a few important sections you should familiarize yourself with. Module Info: Edit the entries to personalize your module. Do not edit __DATE__, this is a macro.
在moduleconfig.h中配置你的模块信息和功能,在这里可以配置是否开启Metamod,也可以在这里配置OnAmxx****等这些Hook回调函数。
Now you’re ready to go onto the next section to see how a basic module works.
Note - you can get these files from AMX Mod X CVS or by downloading the source code.
总结
- amxx模块开发需要用到C语言,以及指针
- 创建模块项目时,需要把moduleconfig.h放在模块项目目录(就是看哪个文件include了amxxmodule.h的,就跟哪个文件放在同一个目录下即可)
- moduleconfig.h可以配置模块的一些基本信息,也可以配置一些模块的Hook回调函数