diff options
Diffstat (limited to 'src/plugins/sample.c')
-rw-r--r-- | src/plugins/sample.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/plugins/sample.c b/src/plugins/sample.c index 8fba2f4df..b1ff4b39f 100644 --- a/src/plugins/sample.c +++ b/src/plugins/sample.c @@ -29,6 +29,7 @@ #include "map/pc.h" #include "map/script.h" +#include "plugins/HPMHooking.h" #include "common/HPMDataCheck.h" /* should always be the last Hercules file included! (if you don't make it last, it'll intentionally break compile time) */ #include <stdio.h> @@ -113,20 +114,23 @@ void sample_packet0f3(int fd) { } int my_pc_dropitem_storage;/* storage var */ /* my custom prehook for pc_dropitem, checks if amount of item being dropped is higher than 1 and if so cap it to 1 and store the value of how much it was */ -int my_pc_dropitem_pre(struct map_session_data *sd,int *n,int *amount) { +int my_pc_dropitem_pre(struct map_session_data **sd, int *n, int *amount) +{ my_pc_dropitem_storage = 0; - if( *amount > 1 ) { + if (*amount > 1) { my_pc_dropitem_storage = *amount; *amount = 1; } return 0; } /* postHook receive retVal as the first param, allows posthook to act accordingly to whatever the original was going to return */ -int my_pc_dropitem_post(int retVal, struct map_session_data *sd,int *n,int *amount) { - if( retVal != 1 ) return retVal;/* we don't do anything if pc_dropitem didn't return 1 (success) */ - if( my_pc_dropitem_storage ) {/* signs whether pre-hook did this */ +int my_pc_dropitem_post(int retVal, struct map_session_data *sd, int n, int amount) +{ + if (retVal != 1) + return retVal;/* we don't do anything if pc_dropitem didn't return 1 (success) */ + if (my_pc_dropitem_storage) {/* signs whether pre-hook did this */ char output[99]; - safesnprintf(output,99,"[ Warning ] you can only drop 1 item at a time, capped from %d to 1",my_pc_dropitem_storage); + safesnprintf(output, 99, "[ Warning ] you can only drop 1 item at a time, capped from %d to 1", my_pc_dropitem_storage); clif->messagecolor_self(sd->fd, COLOR_RED, output); } return 1; @@ -199,13 +203,13 @@ HPExport void plugin_init (void) { /* in this sample we add a PreHook to pc->dropitem */ /* to identify whether the item being dropped is on amount higher than 1 */ /* if so, it stores the amount on a variable (my_pc_dropitem_storage) and changes the amount to 1 */ - addHookPre("pc->dropitem",my_pc_dropitem_pre); + addHookPre(pc, dropitem, my_pc_dropitem_pre); /* in this sample we add a PostHook to pc->dropitem */ /* if the original pc->dropitem was successful and the amount stored on my_pc_dropitem_storage is higher than 1, */ /* our posthook will display a message to the user about the cap */ /* - by checking whether it was successful (retVal value) it allows for the originals conditions to take place */ - addHookPost("pc->dropitem",my_pc_dropitem_post); + addHookPost(pc, dropitem, my_pc_dropitem_post); } } /* triggered when server starts loading, before any server-specific data is set */ |