//===== Hercules Plugin ======================================
//= rodex-bank-npc
//===== By: ==================================================
//= Christian / epicRO
//===== Current Version: =====================================
//= 1.0
//===== Compatible With: ===================================== 
//= Hercules 2016-12-18
//===== Description: =========================================
//= disables usage of rodex and bank deposit while npc dialog
//===== Additional Comments: =================================  
//= spcial thanks to 4114/herc.ws for your time and info
//============================================================

 


#include "common/hercules.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "common/utils.h"
#include "common/memmgr.h"
#include "common/strlib.h"

#include "map/clif.h"
#include "map/pc.h"

#include "plugins/HPMHooking.h"
#include "common/HPMDataCheck.h"

 

HPExport struct hplugin_info pinfo = {

        "rodex-bank-npc", // Plugin name
        SERVER_TYPE_MAP,// Which server types this plugin works with?
        "1.0",                 // Plugin version
        HPM_VERSION,    // HPM Version (don't change, macro is automatically updated)

};
 

void clif_DisableActing_pre(int *fdPtr, struct map_session_data **sdPtr){
	
	int fd = *fdPtr;
	struct map_session_data *sd = *sdPtr;
	
	if ((pc_cant_act2(sd)) || (sd->state.vending) || (sd->npc_id) || (pc_istrading(sd)) || (sd->chat_id != 0) || !map->list[sd->bl.m].flag.town ) {
		clif->messagecolor_self(fd, 0xFF0000, "This action is disabled while acting, vending, trading, chatting, talking to NPC or if you are not in Town.");
		hookStop();
		return;
	}
}


HPExport void plugin_init(void) {
	//addHookPre(clif, pBankDeposit, clif_DisableActing_pre);
	addHookPre(clif, pRodexOpenWriteMail, clif_DisableActing_pre);
	addHookPre(clif, pRodexReadMail, clif_DisableActing_pre);	
	addHookPre(clif, pBankCheck, clif_DisableActing_pre);
}

HPExport void server_online(void)
{
	ShowInfo("'%s' Plugin by Christian/epicRO. Version '%s'\n", pinfo.name, pinfo.version);
}