diff options
author | shennetsind <ind@henn.et> | 2013-05-02 17:14:01 -0300 |
---|---|---|
committer | shennetsind <ind@henn.et> | 2013-05-02 17:14:01 -0300 |
commit | a2c45a8db6d724b98ab41fe9e75e1f7ea7523d5d (patch) | |
tree | 710a44f94cceff2f0198211d21ddfbe99b66f02c /src/plugins/sample.c | |
parent | 219a4f5267b33349649f952266532a132a48c2a3 (diff) | |
download | hercules-a2c45a8db6d724b98ab41fe9e75e1f7ea7523d5d.tar.gz hercules-a2c45a8db6d724b98ab41fe9e75e1f7ea7523d5d.tar.bz2 hercules-a2c45a8db6d724b98ab41fe9e75e1f7ea7523d5d.tar.xz hercules-a2c45a8db6d724b98ab41fe9e75e1f7ea7523d5d.zip |
Introducing Hercules Plugin Mananger
http://hercules.ws/board/topic/549-introducing-hercules-plugin-manager/
Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/plugins/sample.c')
-rw-r--r-- | src/plugins/sample.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/plugins/sample.c b/src/plugins/sample.c new file mode 100644 index 000000000..8e6b8fc86 --- /dev/null +++ b/src/plugins/sample.c @@ -0,0 +1,74 @@ +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Sample Hercules Plugin + +#include <stdio.h> +#include <string.h> +#include "../common/HPMi.h" +#include "../map/script.h" +#include "../map/pc.h" + +HPExport struct hplugin_info pinfo = { + "Sample", // Plugin name + SERVER_TYPE_MAP,// Which server types this plugin works with? + "0.1", // Plugin version + HPM_VERSION, // HPM Version (don't change, macro is automatically updated) +}; +ACMD(sample) {//@sample command - 5 params: const int fd, struct map_session_data* sd, const char* command, const char* message, struct AtCommandInfo *info + printf("I'm being run! message -> '%s' by %s\n",message,sd->status.name); + return true; +} +BUILDIN(sample) {//script command 'sample(num);' - 1 param: struct script_state* st + int arg = script_getnum(st,2); + ShowInfo("I'm being run! arg -> '%d'\n",arg); + return true; +} +CPCMD(sample) {//console command 'sample' - 1 param: char *line + ShowInfo("I'm being run! arg -> '%s'\n",line?line:"NONE"); +} +struct script_interface *script;/* used by script commands */ +/* run when server starts */ +HPExport void plugin_init (void) { + char *server_type; + char *server_name; + + //get the symbols from the server + server_type = GET_SYMBOL("SERVER_TYPE"); + server_name = GET_SYMBOL("SERVER_NAME"); + + script = GET_SYMBOL("script"); + + if( !(script = GET_SYMBOL("script")) ) { + ShowError("Failed to load script interface var!\n"); + } + + ShowInfo ("Server type is "); + + switch (*server_type) { + case SERVER_TYPE_LOGIN: printf ("Login Server\n"); break; + case SERVER_TYPE_CHAR: printf ("Char Server\n"); break; + case SERVER_TYPE_MAP: printf ("Map Server\n"); break; + } + + ShowInfo ("I'm being run from the '%s' filename\n", server_name); + + if( HPMi->addCommand != NULL ) {//link our '@sample' command + HPMi->addCommand("sample",ACMD_A(sample)); + } + + if( HPMi->addScript != NULL ) {//link our 'sample' script command + HPMi->addScript("sample","i",BUILDIN_A(sample)); + } + + if( HPMi->addCPCommand != NULL ) {//link our 'sample' console command + HPMi->addCPCommand("this:is:a:sample",CPCMD_A(sample)); + } +} +/* run when server is ready (online) */ +HPExport void server_online (void) { + +} +/* run when server is shutting down */ +HPExport void plugin_final (void) { + ShowInfo ("%s says ~Bye world\n",pinfo.name); +}
\ No newline at end of file |