Jump to content
  • 0
Sign in to follow this  
Christian [epicRO]

R> Hardcode Changes > Plugin (No RoDex / Bank while Acting)

Question

R> Hardcode Changes > Plugin (No RoDex / Bank while Acting)

Dear Herc.ws Com,

I'd like to ask you for a plugin. I don't understand how to convert my Hardcode Source-Changes into a simple plugin.

src/map/clif.c (void clif_parse_BankDeposit)
 

 	const struct packet_banking_deposit_req *p = RP2PTR(fd);
 	int money; 
+	if ((pc_cant_act2(sd)) || (sd->state.vending) || (sd->npc_id) || (pc_istrading(sd)) || (sd->chat_id != 0)) {
+		clif->messagecolor_self(fd, 0xFF0000, "You are not able to deposit while acting.");
+		return;
+	}


src/map/rodex.c (int rodex_send_mail)

 	nullpo_retr(RODEX_SEND_MAIL_FATAL_ERROR, body);
 	nullpo_retr(RODEX_SEND_MAIL_FATAL_ERROR, title);

+	if ((pc_cant_act2(sd)) || (sd->state.vending) || (sd->npc_id) || (pc_istrading(sd)) || (sd->chat_id != 0)) {
+		rodex->clean(sd, 1);
+		return RODEX_SEND_MAIL_ITEM_ERROR;
+	}
 	if (zeny < 0) {
 		rodex->clean(sd, 1);


I think the title explains everthing.

This simple Source Change disables using of Client Side RoDex and Bank while NPC Dialog to prevent Item Dupe like in Puchuchartan (divide pure enchanted stones -> Send RoDex after you've accepted the deal with an input of 1~9.

My first move was to add a countitem() check on every case (it works) but you never mind that this might be the last known bug / exploit. So I've decided to disable RoDex and Bank while the Player is acting.

It would be nice if one of you could merge this source edit into a simple plugin.

Thank you very much.

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0

You sure this exploit even works? Rodex have double check on items what it should send.

Share this post


Link to post
Share on other sites
  • 0

Yup. Worked well.

RoDex send the item. It's the problem. You can send while you are in npc dialog. For some reasons the herc Puchuchartan is not written well. So within the npc is missing a check.

Generally special on this npc its a scripting mistake. Because delitem is after getitem. This is why the server always displayed "Could not delete item xy from char xy."

Share this post


Link to post
Share on other sites
  • 0

Ah, you mean issue in npc script?

Most of this issues cant be fixed by changing server sources, but only by fixing scripts.

But still probably need configuration options for prevent this.

 

Can you create issue in github bugtracker about npc exploit?

 

Share this post


Link to post
Share on other sites
  • 0

About plugin. Need add prehook to this two functions. And block normal functions if conditions true.

Share this post


Link to post
Share on other sites
  • 0

@plugin
Am I right that I have to copy the whole functions to add them into a plugin and tell the plugin.c that the server should ignore the standard function if - what kind of conditions - ?

Is there some better guide for plugins instead of this one? http://herc.ws/wiki/Hercules_Plugin_Manager

@bugtracker
Issue will be placed in some minutes.

Share this post


Link to post
Share on other sites
  • 0

no, need copy only extrac condition check. And if condition true, just before return, call hookStop().

This call will prevent calling default function and any post hooks. I will show example only with pre hook function, without registration code.

void clif_parse_BankDepositPre(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)) {
		clif->messagecolor_self(fd, 0xFF0000, "You are not able to deposit while acting.");
		hookStop();
		return;
	}
}

 

Share this post


Link to post
Share on other sites
  • 0

At first: Thank you for your time. Time is the most good we humans have and is non-reproducable.

I tried out with my own "rodex-bank-npc.c" in src/plugins/ and edited the Makefile.in as well.
After "make plugins" in console I am getting the following errors:

        CC      rodex-bank-npc.c
In file included from rodex-bank-npc.c:30:0:
../plugins/HPMHooking.h:49:3: error: expected declaration specifiers or ‘...’ before ‘(’ token
   (void)((HPMHOOK_pre_ ## ifname ## _ ## funcname)0 == (hook)), \
   ^
rodex-bank-npc.c:57:2: note: in expansion of macro ‘addHookPre’
  addHookPre(clif, clif_parse_BankDeposit, clif_parse_BankDeposit_pre);
  ^
../plugins/HPMHooking.h:50:3: error: expected declaration specifiers or ‘...’ before ‘HPMi’
   HPMi->hooking->AddHook(HOOK_TYPE_PRE, #ifname "->" #funcname, (hook), HPMi->pid) \
   ^
rodex-bank-npc.c:57:2: note: in expansion of macro ‘addHookPre’
  addHookPre(clif, clif_parse_BankDeposit, clif_parse_BankDeposit_pre);
  ^
rodex-bank-npc.c:58:1: error: expected identifier or ‘(’ before ‘}’ token
 }
 ^
Makefile:105: recipe for target '../../plugins/rodex-bank-npc.so' failed


This is my file:

//===== 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_parse_BankDeposit_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)) {
		clif->messagecolor_self(fd, 0xFF0000, "You are not able to deposit while acting.");
		hookStop();
		return;
	}
}

HPExport void plugin_init(void)
	addHookPre(clif, clif_parse_BankDeposit, clif_parse_BankDeposit_pre);
}

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

 

Share this post


Link to post
Share on other sites
  • 0

 

first issue. Change this:

HPExport void plugin_init(void)

to

HPExport void plugin_init(void) {

Change:

addHookPre(clif, clif_parse_BankDeposit, clif_parse_BankDeposit_pre);

to

addHookPre(clif, pBankDeposit, clif_parse_BankDeposit_pre);

 

Also you may not change make file.

For build plugin need run:

make plugin.pluginname

Example for your plugin:

make plugin.rodex-bank-npc

 

Share this post


Link to post
Share on other sites
  • 0

Works well. Thank you very much. Now the penny has droped.

 

//===== 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)) {
		clif->messagecolor_self(fd, 0xFF0000, "This action is disabled while acting.");
		ShowError("[Plugin %s] : player %s tried to send mail/zeny while acting.\n", pinfo.name,sd->status.name);
		hookStop();
		return;
	}
}



HPExport void plugin_init(void) {
	addHookPre(clif, pBankDeposit, clif_DisableActing_pre);
	addHookPre(clif, pRodexSendMail, clif_DisableActing_pre);
}

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

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.