[1] | 1 | // Sample Athena plugin |
---|
| 2 | |
---|
| 3 | #include <stdio.h> |
---|
| 4 | #include <string.h> |
---|
| 5 | #include "../common/plugin.h" |
---|
| 6 | |
---|
| 7 | ////// Plugin information //////// |
---|
| 8 | // |
---|
| 9 | PLUGIN_INFO = { |
---|
| 10 | // change only the following area |
---|
| 11 | "Test", // Plugin name |
---|
| 12 | PLUGIN_ALL, // Which servers is this plugin for |
---|
| 13 | "0.1", // Plugin version |
---|
| 14 | PLUGIN_VERSION, // Minimum plugin engine version to run |
---|
| 15 | "A sample plugin" // Short description of plugin |
---|
| 16 | }; |
---|
| 17 | |
---|
| 18 | ////// Plugin event list ////////// |
---|
| 19 | // Format: <plugin function>,<event name> |
---|
| 20 | // All registered functions to a event gets executed |
---|
| 21 | // (In descending order) when its called. |
---|
| 22 | // Multiple functions can be called by multiple events too, |
---|
| 23 | // So it's up to your creativity ^^ |
---|
| 24 | // |
---|
| 25 | PLUGIN_EVENTS_TABLE = { |
---|
| 26 | // change only the following area |
---|
| 27 | { "test_me", "Plugin_Test" }, // when the plugin is tested for compatibility |
---|
| 28 | { "do_init", "Plugin_Init" }, // when plugins are loaded |
---|
| 29 | { "do_final", "Plugin_Final" }, // when plugins are unloaded |
---|
| 30 | { "some_function", "some_event" }, |
---|
| 31 | { "some_function", "another_event" }, |
---|
| 32 | { NULL, NULL } |
---|
| 33 | }; |
---|
| 34 | |
---|
| 35 | ///// Variables ///// |
---|
| 36 | char *server_type; |
---|
| 37 | char *server_name; |
---|
| 38 | |
---|
| 39 | //////// Plugin functions ////////// |
---|
| 40 | int do_init () |
---|
| 41 | { |
---|
| 42 | // import symbols from the server |
---|
| 43 | IMPORT_SYMBOL(server_type, 0); |
---|
| 44 | IMPORT_SYMBOL(server_name, 1); |
---|
| 45 | |
---|
| 46 | printf ("Server type is "); |
---|
| 47 | switch (*server_type) { |
---|
| 48 | case PLUGIN_LOGIN: printf ("Login\n"); break; |
---|
| 49 | case PLUGIN_CHAR: printf ("Char\n"); break; |
---|
| 50 | case PLUGIN_MAP: printf ("Map\n"); break; |
---|
| 51 | } |
---|
| 52 | printf ("Filename is %s\n", server_name); |
---|
| 53 | |
---|
| 54 | return 1; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | int do_final () |
---|
| 58 | { |
---|
| 59 | printf ("Bye world\n"); |
---|
| 60 | |
---|
| 61 | return 1; |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | int some_function () |
---|
| 65 | { |
---|
| 66 | printf ("Some function\n"); |
---|
| 67 | return 0; |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | // return 1 if the testing passes, otherwise 0 |
---|
| 71 | // (where the plugin will be deactivated) |
---|
| 72 | int test_me () |
---|
| 73 | { |
---|
| 74 | if (1 + 1 == 2) |
---|
| 75 | return 1; |
---|
| 76 | return 0; |
---|
| 77 | } |
---|