Jump to content
  • 0
Sign in to follow this  
REKT

@sameip command for rathena

Question

7 answers to this question

Recommended Posts

  • 0

yea that script ... sql query not optimized

reference -> https://www.eathena.ws/board/index.php?s=&showtopic=271842&view=findpost&p=1489957

erm ... its not that complex actually, just like this

select `char`.name, login.account_id, last_ip from login left join `char` on login.account_id = `char`.account_id where online = 1 order by last_ip,account_id;
.

.

curious, you want the plugin version or the script version ?

and you want to display all online character or just specific map ?

Share this post


Link to post
Share on other sites
  • 0

 

yea that script ... sql query not optimized

reference -> https://www.eathena.ws/board/index.php?s=&showtopic=271842&view=findpost&p=1489957

erm ... its not that complex actually, just like this

select `char`.name, login.account_id, last_ip from login left join `char` on login.account_id = `char`.account_id where online = 1 order by last_ip,account_id;
.

.

curious, you want the plugin version or the script version ?

and you want to display all online character or just specific map ?

 

 

How i wish, rAthena has a Plugin- System :D

Share this post


Link to post
Share on other sites
  • 0

rathena also have srccustomatcommand.inc ...

I think I can write this one,

if just write in atcommand.inc, the format with hercules shouldn't be that far off

Edited by AnnieRuru

Share this post


Link to post
Share on other sites
  • 0

script version ... should be faster than GMOcean's version because I only list online players, but his query will list all login table

search all online players and only list if they have 2 same ip or above

.

-	script	kjdshfksfj	FAKE_NPC,{OnInit:	bindatcmd "sameip", strnpcinfo(0)+"::Onaaa";	end;Onaaa:	freeloop true;	.@nb = query_sql( "select `char`.name, char_id, last_ip from login left join `char` on login.account_id = `char`.account_id where online = 1", .@name$, .@cid, .@ip$ );	for ( .@i = 0; .@i < .@nb; ++.@i ) {		for ( .@j = 0; .@j < .@ip_list; ++.@j )			if ( .@b_ip$[.@j] == .@ip$[.@i] )				break;		if ( .@j == .@ip_list ) {			.@b_ip$[.@j] = .@ip$[.@i];			++.@ip_list;		}		setd ".@b_ip"+ .@j +"_name$["+ .@b_ip_size[.@j] +"]", .@name$[.@i];		setd ".@b_ip"+ .@j +"_cid$["+ .@b_ip_size[.@j] +"]", .@cid[.@i] +"";		++.@b_ip_size[.@j];	}	dispbottom "===== SAME IP Searching =====";	for ( .@i = 0; .@i < .@ip_list; ++.@i ) {		if ( .@b_ip_size[.@i] > 1 ) {			dispbottom "  == The IP ["+ .@b_ip$[.@i] +"] has "+ .@b_ip_size[.@i] +" players.";			for ( .@j = 0; .@j < .@b_ip_size[.@i]; ++.@j ) {				getmapxy .@map$, .@x, .@y, 0, getd( ".@b_ip"+ .@i +"_name$["+ .@j +"]");				dispbottom "    = "+( .@j +1 )+". ("+ getd( ".@b_ip"+ .@i +"_cid$["+ .@j +"]" ) +") "+ getd( ".@b_ip"+ .@i +"_name$["+ .@j +"]") +" -> "+ .@map$ +" "+ .@x +" "+ .@y;			}			++.@result;		}	}	dispbottom ">>> "+ .@result +" results found.";	end;}
.

now tackle the source version

in theory, source code should be faster than script

Edited by AnnieRuru

Share this post


Link to post
Share on other sites
  • 0

eh ? I thought just change ++.@i into .@i++ will work for rathena already ?

because I saw you did it before on other topic

-	script	kjdshfksfj	FAKE_NPC,{OnInit:	bindatcmd "sameip", strnpcinfo(0)+"::Onaaa";	end;Onaaa:	freeloop true;	.@nb = query_sql( "select `char`.name, char_id, last_ip from login left join `char` on login.account_id = `char`.account_id where online = 1", .@name$, .@cid, .@ip$ );	for ( .@i = 0; .@i < .@nb; .@i++ ) {		for ( .@j = 0; .@j < .@ip_list; .@j++ )			if ( .@b_ip$[.@j] == .@ip$[.@i] )				break;		if ( .@j == .@ip_list ) {			.@b_ip$[.@j] = .@ip$[.@i];			.@ip_list++;		}		setd ".@b_ip"+ .@j +"_name$["+ .@b_ip_size[.@j] +"]", .@name$[.@i];		setd ".@b_ip"+ .@j +"_cid$["+ .@b_ip_size[.@j] +"]", .@cid[.@i] +"";		.@b_ip_size[.@j]++;	}	dispbottom "===== SAME IP Searching =====";	for ( .@i = 0; .@i < .@ip_list; .@i++ ) {		if ( .@b_ip_size[.@i] > 1 ) {			dispbottom "  == The IP ["+ .@b_ip$[.@i] +"] has "+ .@b_ip_size[.@i] +" players.";			for ( .@j = 0; .@j < .@b_ip_size[.@i]; .@j++ ) {				getmapxy .@map$, .@x, .@y, 0, getd( ".@b_ip"+ .@i +"_name$["+ .@j +"]");				dispbottom "    = "+( .@j +1 )+". ("+ getd( ".@b_ip"+ .@i +"_cid$["+ .@j +"]" ) +") "+ getd( ".@b_ip"+ .@i +"_name$["+ .@j +"]") +" -> "+ .@map$ +" "+ .@x +" "+ .@y;			}			.@result++;		}	}	dispbottom ">>> "+ .@result +" results found.";	end;}
post-4102-0-90569400-1449987461_thumb.jpg

 

btw the source version ... I got problem with it ... map-server keep crashing when it initialize 2 dimension array

I guess have to learn how to use struct ...

Share this post


Link to post
Share on other sites
  • 0

sorry, bump

//===== Hercules Script ======================================//= @sameip//===== By: ==================================================//= AnnieRuru//===== Current Version: =====================================//= 0.2//===== Compatible With: ===================================== //= Hercules 2015-12-19//===== Description: =========================================//= list all players with same ip address//===== Topic ================================================//= http://herc.ws/board/topic/11445-sameip-command-for-rathena///===== Additional Comments: =================================  //= it always list all players online, unable to limit to a single map currently//============================================================-	script	kjdshfksfj	FAKE_NPC,{OnInit:	bindatcmd "sameip", strnpcinfo(0)+"::Onaaa";	end;Onaaa:	freeloop true;	.@nb = query_sql( "select name, char_id, account_id as aaa, ( select last_ip from login where account_id = aaa ) from `char` where online = 1", .@name$, .@aid, .@cid, .@ip$ );	for ( .@i = 0; .@i < .@nb; ++.@i ) {		for ( .@j = 0; .@j < .@ip_list; ++.@j )			if ( .@b_ip$[.@j] == .@ip$[.@i] )				break;		if ( .@j == .@ip_list ) {			.@b_ip$[.@j] = .@ip$[.@i];			++.@ip_list;		}		setd ".@b_ip"+ .@j +"_name$["+ .@b_ip_size[.@j] +"]", .@name$[.@i];		setd ".@b_ip"+ .@j +"_cid$["+ .@b_ip_size[.@j] +"]", .@cid[.@i] +"";		++.@b_ip_size[.@j];	}	dispbottom "===== SAME IP Searching =====";	for ( .@i = 0; .@i < .@ip_list; ++.@i ) {		if ( .@b_ip_size[.@i] > 1 ) {			dispbottom "  == The IP ["+ .@b_ip$[.@i] +"] has "+ .@b_ip_size[.@i] +" players.";			for ( .@j = 0; .@j < .@b_ip_size[.@i]; ++.@j ) {				getmapxy .@map$, .@x, .@y, 0, getd( ".@b_ip"+ .@i +"_name$["+ .@j +"]");				dispbottom "    = "+( .@j +1 )+". ("+ getd( ".@b_ip"+ .@i +"_cid$["+ .@j +"]" ) +") "+ getd( ".@b_ip"+ .@i +"_name$["+ .@j +"]") +" -> "+ .@map$ +" "+ .@x +" "+ .@y;			}			++.@result;		}	}	dispbottom ">>> "+ .@result +" results found.";	end;}
use this one, I totally forgot about about table joining will cause the query run slower

when I was cleaning up my old scripts, I relearn this trick

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.