Before start we suggest you to read Documentation about modular structure to understand the way AzerothCore works.
Create a folder inside modules/ directory
Now you can develop add anything to the main project, such as some scripts or even an entire library
Note: we suggest to use the directory structure standards of AzerothCore to better organize your modules and be familiar with main project.
Before continue, we suggest you to follow our guide on how to create a script for AzerothCore
After you’ve created your script you’ve to create a .cpp file to handle the script loading.
For example ( Assuming you’ve created an src folder ):
my_custom_loader.cpp
// From SC
void AddMyCustomScripts();
// Add all
// cf. the naming convention in 4.0.0-dev.6: https://github.com/azerothcore/azerothcore-wotlk/blob/master/doc/changelog/master.md#how-to-upgrade-11
// additionally replace all '-' in the module folder name with '_' here
void Addmod_my_customScripts()
{
AddMyCustomScripts();
}
NOTE: AddMyCustomScripts is composed by:
Add (Prefix)
MyCustom (An unique name identifier for your script to avoid function collisions)
Scripts ( Suffix )
if you need to add a custom configuration file to your module that will be installed with server, the steps are very simple.
.conf.dist in folder ./confModules can now own a complete database without any core-side registration.
The usual flow is:
ModuleDatabasePoolSetConnectionInfo(...)DatabaseScript::OnModuleDatabasesLoading()ModuleDBUpdater::Create(...), ModuleDBUpdater::Populate(...) and ModuleDBUpdater::Update(...)PrepareStatements() after the schema is readyOnModuleDatabasesKeepAlive() and close it with OnModuleDatabasesClosing()class MyModuleDatabasePool : public ModuleDatabasePool
{
protected:
MySQLConnection* CreateConnection(MySQLConnectionInfo& info) override
{
return new MyModuleDatabaseConnection(info);
}
};
class MyModuleDatabaseScript : public DatabaseScript
{
public:
MyModuleDatabaseScript() : DatabaseScript("MyModuleDatabaseScript") { }
bool OnModuleDatabasesLoading() override
{
std::string const modulePath = ResolveModulePath();
_pool.SetConnectionInfo("127.0.0.1;3306;acore;acore;mod_my_module", 1);
if (_pool.Open() != 0)
return false;
if (!ModuleDBUpdater::Create(_pool))
return false;
DBUpdaterInfo const info
{
"MyModule",
modulePath,
modulePath + "/data/sql/base/",
"mymodule"
};
if (!ModuleDBUpdater::Populate(_pool, info) || !ModuleDBUpdater::Update(_pool, info))
return false;
return _pool.PrepareStatements();
}
void OnModuleDatabasesKeepAlive() override
{
_pool.KeepAlive();
}
void OnModuleDatabasesClosing() override
{
_pool.Close();
}
private:
std::string ResolveModulePath() const;
MyModuleDatabasePool _pool;
};
Keep the SQL files inside your module repository and point DBUpdaterInfo to them. In the example above, ResolveModulePath() stands for whichever mechanism your module already uses to locate its own source tree. The updater follows the same base/update workflow used by the core databases, so your module can create, populate and update its own schema during startup.
Publish your module to our catalogue: https://www.azerothcore.org/catalogue.html#/how-to