Adding new Commands to EQ2Emu
Posted: Mon Feb 21, 2011 11:34 am
This involved editing the C++ code, and following our coding standards (should you choose to submit your work for integration into the base code). Please keep this in mind when submitting code changes.
That should tell the world to allow you to type /bogus at a command line, and see the resulting message you created in code.
Next step is to create the `commands` entry in your world to handle the new slash command. Go to your `commands` table using your favorite MySQL editor and insert a new record for the command 'bogus'.Open Commands.h. Go through the code til you find the defines for COMMAND_*
Example:Note that our Command Handlers have a numerical, logical order to them. Let's keep it that way. If you are adding a command to an existing system, try and insert your command handler in an available ID grouped with other similar handlers. If no available (sequential) ID, then it's okay to add a new one to the bottom of the pile, using the next highest available ID.Code: Select all
#define COMMAND_SPAWN 1
We'll use adding a whole new ID as an example. At the end of the COMMAND_* defines, note what the last ID is. As of this writing, it was 279. We'll insert a new (bogus) command at the end.Save Commands.hCode: Select all
#define COMMAND_BOGUS 280
Open Commands.cpp, and search through the current switch for a logical place to insert your code - usually at the end for new commands. Since right now this is simply to get code in place to handle the right-click / create commands, the code is generic:Save Commands.cpp and compile! If you have no errors, your code is fine.Code: Select all
case COMMAND_BOGUS: { client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You just created a BOGUS command!"); break;
Code: Select all
INSERT INTO `commands`(`id`,`type`,`command`,`subcommand`,`handler`,`required_status`) VALUES ( NULL,'0','bogus','','280','0');"You just created a BOGUS command!"