Jump to content
  • 0

Dual Client kick at same map


Question

Posted

Hi,

i am looking for a script where i can set the maps where dual client get kicked. I want to add this to WoE Maps so Player can play with dual client but if they want to enter WoE maps they get kicked.

Recommended Posts

Posted

Old version

prontera,0,0,0 script sniper 111,{
OnPCLoadMapEvent:
	query_sql("SELECT DISTINCT `account_id` FROM `char` WHERE `account_id` IN (SELECT `account_id` FROM `login` WHERE `last_ip` = (SELECT `last_ip` FROM `login` WHERE `account_id`="+getcharid(3)+")) AND `last_map` = '"+strnpcinfo(4)+"' AND `online` <> 0;",.a);
	if(getarraysize(.a)-1) {
		dispbottom "Duel accounts not allowed in WOE.";
		warp "geffen",0,0;
	}
	end;
OnInit:
	setmapflag strnpcinfo(4),mf_loadevent;
}

 
Give me a second and I'll test it. I'm not really sure how fast SQL updates as far as maps are concerned we might have to just return the account ids and surf them with getmapxy or add a delay if it doesn't take forever... I wouldn't recommand this if you have a massive server.

 

Old Version 2

aldeg_cas01,0,0,0	script	dck#aldeg_cas01	111,{
OnPCLoadMapEvent:
	set .@charmap$, strcharinfo(3);
	if(.@charmap$!=.npcmap$) end;
	set .@len, query_sql("SELECT DISTINCT `account_id` FROM `char` WHERE `account_id` IN (SELECT `account_id` FROM `login` WHERE `last_ip` = (SELECT `last_ip` FROM `login` WHERE `account_id`="+getcharid(3)+")) AND `online` <> 0;",.@a);
	if(.@len-1) {
		for(set(.@d,0);.@d<.@len;set(.@d,.@d+1)) {
			getmapxy(.@map$,.@x,.@y,0,rid2name(.@a[.@d]));
			if(.@map$==.@charmap$&&rid2name(.@a[.@d])!=strcharinfo(0)) {
				dispbottom "Duel accounts not allowed in WOE.";
				warp "geffen",0,0;
			}
		}
	}
	end;
	
OnInit:
	set        .npcmap$,	strnpcinfo(4);
	setmapflag .npcmap$,	mf_loadevent ;
}

gefg_cas01,0,0,0	duplicate(dck#aldeg_cas01)	dck#gefg_cas01	111
payg_cas01,0,0,0	duplicate(dck#aldeg_cas01)	dck#payg_cas01	111
prtg_cas01,0,0,0	duplicate(dck#aldeg_cas01)	dck#prtg_cas01	111

This is working from what I can tell. Just set this npc on one of the maps you want and dupilcate it to the others it will do the rest. This probably goes without saying but this script will only work on SQL servers.

Edit: You may also change strnpcinfo(4) like:

set .npcmap$, strnpcinfo(2);

Will make the script compatiable with eAthena.

 

Old Version 3

rAthena Only:

-	script	dualclientkicker	-1,{
OnPCLoadMapEvent:
	set .@charmap$, strcharinfo(3);
	query_sql("SELECT FIND_IN_SET('"+.@charmap$+"', '"+.maps$+"');",.@q);
	if(.@charmap$!=.tmp$[(.@q-1)]) end;
	set .@len, query_sql("SELECT DISTINCT `account_id` FROM `char` WHERE `account_id` IN (SELECT `account_id` FROM `login` WHERE `last_ip` = (SELECT `last_ip` FROM `login` WHERE `account_id`="+getcharid(3)+")) AND `online` <> 0;",.@a);
	if(.@len-1) {
		for(set(.@d,0);.@d<.@len;set(.@d,.@d+1)) {
			getmapxy(.@map$,.@x,.@y,0,rid2name(.@a[.@d]));
			if(.tmp$[(.@q-1)]==.@map$&&rid2name(.@a[.@d])!=strcharinfo(0)) {
				dispbottom "Duel accounts not allowed in WOE.";
				warp "geffen",0,0;
			}
		}
	}
	end;
	
OnInit:
	set        .maps$  ,	"aldeg_cas01,gefg_cas01,payg_cas01,prtg_cas01";
	explode(   .tmp$   ,    .maps$, ",")                                  ;
	set        .lens   ,	getarraysize(.tmp$)                           ;
	for(set .a,0;.a<.lens;set .a,.a+1)
		setmapflag .tmp$[.a],	mf_loadevent ;
}

Just add you maps to the .maps$ string.

 

 

Universal:

-	script	dualclientkicker	-1,{
OnPCLoadMapEvent:
	set .@charmap$, strcharinfo(3);
	for(set(.@q,0);.@q<.lens;set(.@q,.@q+1))
		if(.@charmap$==.maps$[.@q]) break;
		else end;
	if(.@charmap$!=.maps$[.@q]) end;
	set .@len, query_sql("SELECT DISTINCT `account_id` FROM `char` WHERE `account_id` IN (SELECT `account_id` FROM `login` WHERE `last_ip` = (SELECT `last_ip` FROM `login` WHERE `account_id`="+getcharid(3)+")) AND `online` <> 0;",.@a);
	if(.@len-1) {
		for(set(.@d,0);.@d<.@len;set(.@d,.@d+1)) {
			getmapxy(.@map$,.@x,.@y,0,rid2name(.@a[.@d]));
			if(.maps$[.@q]==.@map$&&rid2name(.@a[.@d])!=strcharinfo(0)) {
				dispbottom "Duel accounts not allowed in WOE.";
				warp "geffen",0,0;
			}
		}
	}
	end;
	
OnInit:
	setarray   .maps$  ,	"aldeg_cas01", "gefg_cas01", "payg_cas01", "prtg_cas01";
	set        .lens   ,	getarraysize(.maps$)                                   ;
	for(set(.a,0);.a<.lens;set(.a,.a+1))
		setmapflag .maps$[.a],	mf_loadevent ;
}

Just add you maps to the .maps$ array.

 

Universal v4:

-	script	dualclientkicker	-1,{
OnPCLoadMapEvent:
	set .@charmap$, strcharinfo(3);
	if(!compare(.tmp$,.@charmap$)) end;
	//set .@len, query_sql("SELECT DISTINCT `account_id` FROM `char` WHERE `account_id` IN (SELECT `account_id` FROM `login` WHERE `last_ip` = (SELECT `last_ip` FROM `login` WHERE `account_id`="+getcharid(3)+")) AND `online` <> 0;",.@a);
	set .@len, query_sql("select account_id from `char` right join login on login.account_id = `char`.account_id where `char`.online = 1 and login.last_ip = '"+ getcharip() +"'",.@a ); //Annieruru Addition.
	if(.@len-1) {
		for(set(.@d,0);.@d<.@len;set(.@d,.@d+1)) {
			getmapxy(.@map$,.@x,.@y,0,rid2name(.@a[.@d]));
			if(.@charmap$==.@map$&&rid2name(.@a[.@d])!=strcharinfo(0)) {
				dispbottom "Duel accounts not allowed in WOE.";
				warp "geffen",0,0;
			}
		}
	}
	end;
	
OnInit:
	setarray   .maps$  ,	"aldeg_cas01", "gefg_cas01", "payg_cas01", "prtg_cas01";
	set        .lens   ,	getarraysize(.maps$)                                   ;
	for(set(.a,0);.a<.lens;set(.a,.a+1)) {
		setmapflag .maps$[.a],	mf_loadevent ;
		set .tmp$  ,.tmp$+.maps$[.a]+",";
	}
}
  • Upvote 2
  • 1
Posted

When I use Old version 3, rAthena only. it appear this bug in putty, hopefully someone will be able to fix it.

 

[Warning]: script:getelementofarray: index out of range (-1)
[Debug]: Data: variable name='.tmp$' index=0
[Debug]: Source (NPC): dualclientkicker (invisible/not on a map)
 
following is my script...
 
-	script	dualclientkicker	-1,{
OnPCLoadMapEvent:
set .@charmap$, strcharinfo(3);
query_sql("SELECT FIND_IN_SET('"+.@charmap$+"', '"+.maps$+"');",.@q);
if(.@charmap$!=.tmp$[(.@q-1)]) end;
set .@len, query_sql("SELECT DISTINCT `account_id` FROM `char` WHERE `account_id` IN (SELECT `account_id` FROM `login` WHERE `last_ip` = (SELECT `last_ip` FROM `login` WHERE `account_id`="+getcharid(3)+")) AND `online` <> 0;",.@a);
if(.@len-1) {
for(set(.@d,0);.@d<.@len;set(.@d,.@d+1)) {
getmapxy(.@map$,.@x,.@y,0,rid2name(.@a[.@d]));
if(.tmp$[(.@q-1)]==.@map$&&rid2name(.@a[.@d])!=strcharinfo(0)) {
dispbottom "Dual accounts not allowed in HERE.";
warp "prontera",156,178;
}
}
}
end;
 
OnInit:
set .maps$ ,"bat_a01,bat_room,guild_vs3,prtg_cas05";
explode(.tmp$,.maps$,",") ;
set .lens , getarraysize(.tmp$);
for(set .a,0;.a<.lens;set .a,.a+1)
setmapflag .tmp$[.a], mf_loadevent;
} 
  • 0
Posted
On 7/26/2013 at 11:01 PM, Skorm said:

-	script	dualclientkicker2	-1,{
OnPCLoginEvent:
	set .@len, query_sql("SELECT DISTINCT `account_id` FROM `char` WHERE `account_id` IN "+
		"(SELECT `account_id` FROM `login` WHERE `last_mac` = "+
		"(SELECT `last_mac` FROM `login` WHERE `account_id`="+getcharid(3)+")) AND `online` <> 0;",.@a);
	sleep2 1000;
	if(.@len>.max)
		atcommand "@kick "+strcharinfo(0);
	end;
	
OnInit:
	set .max, 2; //Max Connections.
}

 

Use whatever script you want mine worked when I tested it. -.-

Hi @Skorm  Just wanted to ask if you could make this check for IP && Mac address cause sometimes in rare cases my players having the same Mac address but different IP.
I'm no good at SQL scripting so i was wondering if how can i make it check for both ip and mac before kicking the player. thanks

  • 0
Posted
On 4/17/2014 at 6:33 AM, fallen0519 said:
[Warning]: script:getelementofarray: index out of range (-1)
[Debug]: Data: variable name='.tmp$' index=0
[Debug]: Source (NPC): dualclientkicker (invisible/not on a map)

same problem

Posted

or like this?

-	script	dual_client	-,{
OnInit:
	setarray .@map$, "alberta","geffen";	// yours maps no dual
	.@size = getarraysize( .@map$ );
	for ( .@i = 0; .@i < .@size; .@i++ )
		if ( !getmapflag( .@map$[.@i], mf_loadevent ) )
			setmapflag .@map$[.@i], mf_loadevent;
	.map_list$ = implode( .@map$, "|" );
	.@count = query_sql( "select `login`.`last_ip`, `char`.`name`, `char`.`char_id` from `login` left join `char` on `char`.`account_id`=`login`.`account_id` where `char`.`online`=1", .@last_ip$, .@name$, .@char_id );
	for ( .@i = 0; .@i < .@count; .@i++ ) {
		getmapxy .@map$, .@x, .@y, 0, .@name$[.@i];
		if ( !compare( .map_list$, .@map$ ) ) continue;
		.@size = 0;
		.@variable$ = ".ip_"+ .@last_ip$[.@i] +"$";
		if ( getd( .@variable$ ) != "" ) {
			.@size = getarraysize( getd( .@variable$ ) );
			for ( .@j = 0; .@j < .@size; .@j++ ) {
				getmapxy .@map2$, .@x, .@y, 0, getd( .@variable$ +"["+ .@j +"]" );
				if ( .@map$ == .@map2$ ) {
					warpchar "prontera",150,150, .@char_id[.@i];
					message .@name$[.@i], "No dual account on this map.";
					break;
				}
			}
		}
		if ( .@j == .@size )
			setd .@variable$ +"["+ .@size +"]", .@name$[.@i];
	}
	end;
OnPCLoadMapEvent:
	if ( !compare( .map_list$, strcharinfo(3) ) ) end;
	.@map$ = strcharinfo(3);
	.@myname$ = strcharinfo(0);
	.@variable$ = ".ip_"+ getcharip() +"$";
	.@size = getarraysize( getd( .@variable$ ) );
	for ( .@j = 0; .@j < .@size; .@j++ ) {
		if ( .@myname$ == getd( .@variable$ +"["+ .@j +"]" ) ) {
			.@is_in = 1;
			continue;
		}
		getmapxy .@map2$, .@x, .@y, 0, getd( .@variable$ +"["+ .@j +"]" );
		.@compare = compare( .map_list$, .@map2$ );
		if ( !.@compare ) {
			.@tmp$ = .@variable$ +"["+ .@j +"]";
			deletearray getd( .@tmp$ ), 1;
			.@size--;
		}
		else if ( .@map$ == .@map2$ ) {
			warpchar "prontera",150,150, getcharid(0);
			message .@myname$, "No dual account on this map.";
			end;
		}
	}
	if ( !.@is_in )
		setd .@variable$ +"["+ .@size +"]", .@myname$;
	end;
}

Posted

hi I understand that this one is IP based and if people are on the same shop , one of them will be able to stay in the map? but is there anyway that it can only check the connection per PC? 

I have a Harmony in my client but the setting "Max connections per PC" does not seem to work, that's why I am looking into using this script.

 

Thanks for your help in advance.

Posted (edited)

hi I understand that this one is IP based and if people are on the same shop , one of them will be able to stay in the map? but is there anyway that it can only check the connection per PC? 

I have a Harmony in my client but the setting "Max connections per PC" does not seem to work, that's why I am looking into using this script.

 

Thanks for your help in advance.

 

Edit--
Edited by Skorm
Posted (edited)

oh thank you!



Hi I have tried this and does not appear to be working. =( I am not sure what the problem is.

 

Can someone change the SQL query instead of reading the last IP to be the MAC ID instead? 

I am trying to use this:

 

-	script	dual_client	-,{
OnInit:
	setarray .@map$, "alberta","geffen";	// yours maps no dual
	.@size = getarraysize( .@map$ );
	for ( .@i = 0; .@i < .@size; .@i++ )
		if ( !getmapflag( .@map$[.@i], mf_loadevent ) )
			setmapflag .@map$[.@i], mf_loadevent;
	.map_list$ = implode( .@map$, "|" );
	.@count = query_sql( "select `login`.`last_ip`, `char`.`name`, `char`.`char_id` from `login` left join `char` on `char`.`account_id`=`login`.`account_id` where `char`.`online`=1", .@last_ip$, .@name$, .@char_id );
	for ( .@i = 0; .@i < .@count; .@i++ ) {
		getmapxy .@map$, .@x, .@y, 0, .@name$[.@i];
		if ( !compare( .map_list$, .@map$ ) ) continue;
		.@size = 0;
		.@variable$ = ".ip_"+ .@last_ip$[.@i] +"$";
		if ( getd( .@variable$ ) != "" ) {
			.@size = getarraysize( getd( .@variable$ ) );
			for ( .@j = 0; .@j < .@size; .@j++ ) {
				getmapxy .@map2$, .@x, .@y, 0, getd( .@variable$ +"["+ .@j +"]" );
				if ( .@map$ == .@map2$ ) {
					warpchar "prontera",150,150, .@char_id[.@i];
					message .@name$[.@i], "No dual account on this map.";
					break;
				}
			}

Thank you.

Edited by Freya Jorgenson
Posted
-	script	dualclientkicker2	-1,{
OnPCLoginEvent:
	set .@len, query_sql("SELECT DISTINCT `account_id` FROM `char` WHERE `account_id` IN "+
		"(SELECT `account_id` FROM `login` WHERE `last_mac` = "+
		"(SELECT `last_mac` FROM `login` WHERE `account_id`="+getcharid(3)+")) AND `online` <> 0;",.@a);
	sleep2 1000;
	if(.@len>.max)
		atcommand "@kick "+strcharinfo(0);
	end;
	
OnInit:
	set .max, 2; //Max Connections.
}

 

Use whatever script you want mine worked when I tested it. -.-

Posted

@skorm I have db error - unknown column 'last_mac' in 'where_clause'

 

It only works for Harmony clients because it keeps mac address.

 

If you want it to work for other clients... change all instances of

last_mac

to

last_ip
Posted
-	script	dualclientkicker2	-1,{
OnPCLoginEvent:
	set .@len, query_sql("SELECT DISTINCT `account_id` FROM `char` WHERE `account_id` IN "+
		"(SELECT `account_id` FROM `login` WHERE `last_mac` = "+
		"(SELECT `last_mac` FROM `login` WHERE `account_id`="+getcharid(3)+")) AND `online` <> 0;",.@a);
	sleep2 1000;
	if(.@len>.max)
		atcommand "@kick "+strcharinfo(0);
	end;
	
OnInit:
	set .max, 2; //Max Connections.
}

 

Use whatever script you want mine worked when I tested it. -.-

 

@Skorm, this script will kick dual client only? Not same ip address (Cyber Cafe). I have used Universal V4 and it'll kick same ip address.

Posted

 

-	script	dualclientkicker2	-1,{
OnPCLoginEvent:
	set .@len, query_sql("SELECT DISTINCT `account_id` FROM `char` WHERE `account_id` IN "+
		"(SELECT `account_id` FROM `login` WHERE `last_mac` = "+
		"(SELECT `last_mac` FROM `login` WHERE `account_id`="+getcharid(3)+")) AND `online` <> 0;",.@a);
	sleep2 1000;
	if(.@len>.max)
		atcommand "@kick "+strcharinfo(0);
	end;
	
OnInit:
	set .max, 2; //Max Connections.
}

 

Use whatever script you want mine worked when I tested it. -.-

 

@Skorm, this script will kick dual client only? Not same ip address (Cyber Cafe). I have used Universal V4 and it'll kick same ip address.

 

The version you selected identifies with the mac address but you need Harmony in order to run it.

Posted

The version you selected identifies with the mac address but you need Harmony in order to run it.

 

I see, but I don't have Harmony. Is there any possible way? Or you already did post the script?

Posted

Can i request?
I want all the ID's too be killed not kicked out.
If the 2 same IP chars get's into a map which is same IP restricted, i want them both to get killed(log'd out from the server).
Thank you.

Posted

Can i request?

I want all the ID's too be killed not kicked out.

If the 2 same IP chars get's into a map which is same IP restricted, i want them both to get killed(log'd out from the server).

Thank you.

Done.. :)

 

-	script	dualclientkicker	-1,{
OnPCLoadMapEvent:
	set .@charmap$, strcharinfo(3);
	if(!compare(.tmp$,.@charmap$)) end;
	set .@len, query_sql("SELECT DISTINCT `account_id` FROM `char` WHERE `account_id` IN (SELECT `account_id` FROM `login` WHERE `last_ip` = (SELECT `last_ip` FROM `login` WHERE `account_id`="+getcharid(3)+")) AND `online` <> 0;",.@a);
	if(.@len-1) {
		for(set(.@d,0);.@d<.@len;set(.@d,.@d+1)) {
			getmapxy(.@map$,.@x,.@y,0,rid2name(.@a[.@d]));
			if(.@charmap$==.@map$&&rid2name(.@a[.@d])!=strcharinfo(0)) {
				dispbottom "Duel accounts not allowed in WOE.";
				unitskilluseid getcharid(3),"NPC_SELFDESTRUCTION",1;
			}
		}
	}
	end;
	
OnInit:
	setarray   .maps$  ,	"aldeg_cas01", "gefg_cas01", "payg_cas01", "prtg_cas01";
	set        .lens   ,	getarraysize(.maps$)                                   ;
	for(set(.a,0);.a<.lens;set(.a,.a+1)) {
		setmapflag .maps$[.a],	mf_loadevent ;
		set .tmp$  ,.tmp$+.maps$[.a]+",";
	}
}
Posted (edited)

@Lit Troll

Still the Char's are not logging out from the server when they are in the same map.

I think you dint understand my request.

What do you mean by this?

I want all the ID's too be killed not kicked out.

From my above post i used (If you want the char to be killed):

unitskilluseid getcharid(3),"NPC_SELFDESTRUCTION",1;

If you wanted the char to be kicked not killed change above to:

atcommand "@kick " + strcharinfo(0); 

It will kick the last player who joined the woe with same ip(This is not advisable when players are playing on internet cafe.)

Idk yet how to kick both of them, because there's no command that can be used atm(in my own knowledge, if im not mistaking).

Edited by Lil Troll
Posted

think I better bump this topic rather than post in other member's topic

the answered sql query is quite unoptimized

I'll avoid using IN command because it always execute very slow

using JOIN statement is much faster than IN here because the account_id column has been indexed

http://stackoverflow.com/questions/4771183/sql-fixed-value-in-vs-inner-join-performance

http://stackoverflow.com/questions/12172931/mysql-performance-use-in-or-join

this query should be faster

.@len = query_sql("select account_id from `char` right join login on login.account_id = `char`.account_id where `char`.online = 1 and login.last_ip = '"+ getcharip() +"'" )
http://rathena.org/board/topic/73169-player-checker-npc/?p=150983 <-- just some info about an indexed table

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...