Hello guys! Today I'm going to show you how to make your own configuration setting in the worldserver.conf file. It is pretty simple.
First, let's go off of what you need:
Microsoft Visual Studio 2010, 2012 or greater
Knowledge on how to edit existing code
The files we will be editing is:
What we need to do is think of what we want. I guess I'll go with a basic value that can be changed to give an item to a player.
Go to your worldserver.conf file and we'll edit that first.
At the very bottom of my worldserver.conf file, I added:
# Player item on login or when needed
# Description: This is an itemId that will be given to a player when needed
Item.RandomItemId = 90000
Pretty basic! Alright, now we need to get this sucker loading when the server goes up. Open your World.h file.
Search for WorldIntConfigs enumerator. Once found, above "INT_CONFIG_VALUE_COUNT" at the very bottom of the enumerator add:
Great! Now go to your World.cpp file and search for:
Once found, we need to add our custom setting in there. This is what we need to use for 'WorldIntConfigs' enumerator:
/// Initialize config values
void World::LoadConfigSettings(bool reload)
Very simple. Alright, at the very bottom above:
// call ScriptMgr if we're reloading the configuration
Really self explanatory. The "Item.RandomItemId" is our setting name and the "90000" is our default value if a value isn't given in the configuration file.
m_int_configs[CONFIG_RANDOM_ITEM_ID] = sConfigMgr->GetIntDefault("Item.RandomItemId", 90000);
Great! It is pretty much finished! Let's run a test script, shall we?
Change the item Id in the config to 0 and see if it still sets itself to the default value.
Item.RandomItemId = 0
And it works:
One more test! Set the itemId to a randomId. Testing code:
TC_LOG_ERROR(LOG_FILTER_SERVER_LOADING, "ItemId is %u!", sWorld->getIntConfig(CONFIG_RANDOM_ITEM_ID));
Item.RandomItemId = 89
I hope you enjoyed this tutorial! :D