Jump to content
  • 0
Sign in to follow this  
Svanhild

One char per gm account

Question

7 answers to this question

Recommended Posts

  • 0

simple patch plugin

#include "common/hercules.h"#include <stdio.h>#include <string.h>#include <stdlib.h>#include "char/char.h"#include "common/nullpo.h"#include "common/HPMDataCheck.h"HPExport struct hplugin_info pinfo = {	"1charpergm", // Plugin name	SERVER_TYPE_CHAR,// Which server types this plugin works with?	"0.1",			// Plugin version	HPM_VERSION,	// HPM Version (don't change, macro is automatically updated)};int char_make_new_char_sql_pre(struct char_session_data* sd, char* name_, int str, int agi, int vit, int int_, int dex, int luk, int slot, int hair_color, int hair_style) {	nullpo_retr(-2, sd);	if ( slot != 0 && sd->group_id > 10 ) { // change 10 to minimum gm level		hookStop();		return -2;	}	return 0;}HPExport void plugin_init (void) {	addHookPre( "chr->make_new_char_sql", char_make_new_char_sql_pre );}
EDIT : change 'char->' into 'chr->'

now it works

 

EDIT2: what have I done LOL

forgot to add slot variable

Edited by AnnieRuru

Share this post


Link to post
Share on other sites
  • 0

Check what I did here on char.c

 

if( sd->group_id > 0 && sd->group_id < 99 ) {		if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT 1 FROM `%s` WHERE `account_id` = '%d'", char_db, sd->account_id) )			Sql_ShowDebug(inter->sql_handle);		if( SQL->NumRows(inter->sql_handle) >= 1 )			return -2; // character account limit exceeded	}// check char slot    if( sd->found_char[slot] != -1 )        return -2; /* character account limit exceeded */

Share this post


Link to post
Share on other sites
  • 0

nonono ... the char_make_new_char_sql function already has a slot variable

so we can make use of that variable for not using sql syntax

 

btw, my mistake for not using slot variable in my previous post, fixed

 src/char/char.c | 8 ++++++++ 1 file changed, 8 insertions(+)diff --git a/src/char/char.c b/src/char/char.cindex 41b13b3..d5849f5 100644--- a/src/char/char.c+++ b/src/char/char.c@@ -1671,6 +1671,9 @@ int char_make_new_char_sql(struct char_session_data* sd, char* name_, int str, i 		return -2; // invalid input #endif +	if ( slot != 0 && sd->group_id > 10 ) { // change 10 to minimum gm level+		return -2;+	} 	// check char slot 	if( sd->found_char[slot] != -1 ) 		return -2; /* character account limit exceeded */@@ -4574,6 +4577,11 @@ void char_parse_char_select(int fd, struct char_session_data* sd, uint32 ipl) 	} #endif +	if ( slot != 0 && sd->group_id > 10 ) {+		chr->creation_failed(fd, -2);+		return;+	}+ 	ARR_FIND(0, ARRAYLENGTH(chr->server), server_id, chr->server[server_id].fd > 0 && VECTOR_LENGTH(chr->server[server_id].maps) > 0); 	/* not available, tell it to wait (client wont close; char select will respawn). 	 * magic response found by Ind thanks to Yommy <3 */
somehow I'm unable to write the char_parse_char_select as plugin ...

I always get error for this line in plugin

int slot = RFIFOB(fd,2);
Edited by AnnieRuru

Share this post


Link to post
Share on other sites
  • 0

yeah, I noticed that and re-written the code earlier and it went fine, but I'll be using your code instead, I trust you for creating reliable codes. Thanks, Annie.

 

EDIT: Tested and it worked.

Edited by Svanhild

Share this post


Link to post
Share on other sites
  • 0

latest revision, patch

Spoiler

 src/char/char.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/char/char.c b/src/char/char.c
index 330b0639f..d61203407 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -1729,6 +1729,9 @@ static int char_make_new_char_sql(struct char_session_data *sd, const char *name
 			return -2; // Char Creation Denied
 	}
 
+	if ( slot != 0 && sd->group_id > 10 )
+		return -2;
+
 	//check other inputs
 #if PACKETVER >= 20120307
 	if(slot < 0 || slot >= sd->char_slots)
@@ -4565,6 +4568,11 @@ static void char_parse_char_select(int fd, struct char_session_data *sd, uint32
 
 	RFIFOSKIP(fd,3);
 
+	if ( slot != 0 && sd->group_id > 10 ) {
+		chr->creation_failed(fd, -4);
+		return;
+	}
+
 #if PACKETVER >= 20110309
 	if( pincode->enabled ){ // hack check
 		struct online_char_data* character;

 

plugin

Spoiler

#include "common/hercules.h"
#include "char/char.h"
#include "common/nullpo.h"
#include "common/socket.h"
#include "plugins/HPMHooking.h"
#include "common/HPMDataCheck.h"

HPExport struct hplugin_info pinfo = {
	"1charpergm",
	SERVER_TYPE_CHAR,
	"0.2a",
	HPM_VERSION,
};

static int char_make_new_char_sql_pre( struct char_session_data **sd, const char **name_, int *str, int *agi, int *vit, int *int_, int *dex, int *luk, int *slot, int *hair_color, int *hair_style, int *starting_job, uint8 *sex) {
	nullpo_retr(-2, *sd);
	if ( *slot != 0 && (*sd)->group_id > 10 ) {	// change 10 to minimum gm level
		hookStop();
		return -2;
	}
	return 0;
}

static void char_parse_char_select_pre( int *fd, struct char_session_data **sd, uint32 *ipl ) {
	int slot = RFIFOB(*fd, 2);
	if ( slot != 0 && (*sd)->group_id > 10 ) {
		RFIFOSKIP(*fd, 3);
		chr->creation_failed(*fd, -4);
		hookStop();
	}
	return;
}

HPExport void plugin_init (void) {
	addHookPre( chr, make_new_char_sql, char_make_new_char_sql_pre );
	addHookPre( chr, parse_char_select, char_parse_char_select_pre );
}

 

the reason for the patch is because this was requested from rAthena forum
https://rathena.org/board/topic/118143-bonus-expansion-pack/?do=findComment&comment=357155

Edited by AnnieRuru

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.