Jump to content
  • 0

Run this script on multiple maps and allows max. 2 clients/IPs?


HristDead

Question


  • Group:  Members
  • Topic Count:  66
  • Topics Per Day:  0.02
  • Content Count:  167
  • Reputation:   2
  • Joined:  08/01/12
  • Last Seen:  

I found this script and wanted to request a few additions...

 

1) How to make it works per multiple maps? ex. prtg_cas01 and aldeg_cas01? (Currently only works on 1 map)

2) How to make it so that the accepted/whitelist IP can only open a max of two clients in these maps? (Currently allows unlimit clients)

 

I have asked for a solution on other forums, but their solution it didnt work. D:

 

Can rAthena please help?

 

-    script    WoE_IP_Kick    -1,{
OnInit:
    setmapflag "prtg_cas01", mf_loadevent;
    set .whitelist$, "xx.xx.xx.xx | xx.xx.xx.xx";
    end;
 
// Trigger when a player enters a map with "loadevent" mapflag.
OnPCLoadMapEvent:
 
    // Only run for map "prtg_cas01".
if (strcharinfo(3) != "prtg_cas01") end;
    
    set .@my_ip$, getcharip();
    if ( compare( .@my_ip$, .whitelist$ ) ) end;
 
    // Get list of accounts with attached character's IP address.
    set .@size, query_sql("SELECT `account_id` FROM `login` WHERE `last_ip` = '"+ .@my_ip$ +"'",.@aid);
 
    // Passed check if only the attached player is returned.
    if (.@size < 2) end;
 
    // Check all online characters using the IP address if they are on a Battlegrounds map.
    set .@self, getcharid(3);
    for(set .@i,0; .@i<.@size; set .@i,.@i+1) {
        if (.@aid[.@i] == .@self)
            continue;
        if (attachrid(.@aid[.@i])) {
            if (compare(strcharinfo(3),"prtg_cas01")) {
                set .@name$, strcharinfo(0);
                attachrid(.@self);
                message strcharinfo(0),"Character "+.@name$+" is already present in this map with your IP. Kicking....";
                sleep2 2000;
    atcommand "@kick "+strcharinfo(0);
                end;
            }
        }
    }
 
    // Passed check.
    end;
}
Edited by HristDead
Link to comment
Share on other sites

10 answers to this question

Recommended Posts


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  


- script WoE_IP_Kick -1,{

OnInit:

setmapflag "prtg_cas01", mf_loadevent;

setmapflag "prtg_cas02", mf_loadevent;

setmapflag "prtg_cas03", mf_loadevent;

set .map_list$, "prtg_cas01 | prtg_cas02 | prtg_cas03";

set .whitelist$, "127.0.0.1 | xx.xx.xx.xx";

end;

// Trigger when a player enters a map with "loadevent" mapflag.

OnPCLoadMapEvent:

// Only run for map in the list.

if ( compare( .map_list$,strcharinfo(3) ) == 0 ) end;

set .@my_ip$, getcharip();

if ( compare( .whitelist$,.@my_ip$ ) )

.@right = 2;

else

.@right = 1;

// Get list of name online with attached character's IP address.

set .@size, query_sql("SELECT `char`.`name` FROM `login` join `char` on `char`.account_id = login.account_id WHERE online = 1 and `last_ip` = '"+ .@my_ip$ +"' and `char`.`account_id` != "+ getcharid(3), .@name$ );

// Passed check if only the attached player is returned.

if ( .@size < .@right ) end;

setd ".@count_"+ strcharinfo(3), 1;

// Check all online characters using the IP address if they are on a Battlegrounds map.

for( ; .@i<.@size; set .@i,.@i+1) {

getmapxy .@map$, .@x, .@y, 0, .@name$[.@i];

if ( compare( .map_list$,.@map$ ) ) {

setd ".@count_"+ .@map$, getd( ".@count_"+ .@map$ ) +1;

setd ".@name_"+ .@map$ +"$", getd( ".@name_"+ .@map$ +"$" ) + .@name$[.@i] + ( ( getd( ".@name_"+ .@map$ +"$" ) == "" && .@right == 2 ) ? "," : "" );

if ( getd( ".@count_"+ .@map$ ) == .@right +1 ) {

message strcharinfo(0),"Characters "+ getd( ".@name_"+ .@map$ +"$" ) +" already present in a map with your IP. Kicking....";

sleep2 2000;

atcommand "@kick "+ strcharinfo(0);

end;

}

}

}

// Passed check.

end;

}

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  


- script WoE_IP_Kick -1,{

OnInit:

setmapflag "prtg_cas01", mf_loadevent;

setmapflag "prtg_cas02", mf_loadevent;

setmapflag "prtg_cas03", mf_loadevent;

set .map_list$, "prtg_cas01 | prtg_cas02 | prtg_cas03";

set .whitelist$, "xx.xx.xx.xx | xx.xx.xx.xx";

end;

// Trigger when a player enters a map with "loadevent" mapflag.

OnPCLoadMapEvent:

// Only run for map "prtg_cas01".

if ( compare( .map_list$,strcharinfo(3) ) == 0 ) end;

set .@my_ip$, getcharip();

if ( compare( .@my_ip$, .whitelist$ ) ) end;

// Get list of accounts with attached character's IP address.

set .@size, query_sql("SELECT `char`.`name` FROM `login` join `char` on `char`.account_id = login.account_id WHERE online = 1 and `last_ip` = '"+ .@my_ip$ +"' and `char`.`account_id` != "+ getcharid(3), .@name$ );

// Passed check if only the attached player is returned.

if ( .@size == 0 ) end;

// Check all online characters using the IP address if they are on a Battlegrounds map.

for( ; .@i<.@size; set .@i,.@i+1) {

getmapxy .@map$, .@x, .@y, 0, .@name$[.@i];

if ( compare( .map_list$,.@map$ ) ) {

message strcharinfo(0),"Character "+.@name$[.@i]+" is already present in a map with your IP. Kicking....";

sleep2 2000;

atcommand "@kick "+ strcharinfo(0);

end;

}

}

// Passed check.

end;

}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  66
  • Topics Per Day:  0.02
  • Content Count:  167
  • Reputation:   2
  • Joined:  08/01/12
  • Last Seen:  

Hi Capuche,

 

I tried that but it kicks my second client. I want the second client to be allowed for the whitelisted IPs, but have the third client kicked.

(So two players in the same household can play together)

Edited by HristDead
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

-	script	WoE_IP_Kick	-1,{
OnInit:
	setmapflag "prtg_cas01", mf_loadevent;
	setmapflag "prtg_cas02", mf_loadevent;
	setmapflag "prtg_cas03", mf_loadevent;

	set .map_list$, "prtg_cas01 | prtg_cas02 | prtg_cas03";
	set .whitelist$, "xx.xx.xx.xx | xx.xx.xx.xx";
	end;
 
// Trigger when a player enters a map with "loadevent" mapflag.
OnPCLoadMapEvent:
 
	// Only run for map "prtg_cas01".
	if ( compare( .map_list$,strcharinfo(3) ) == 0 ) end;
	
	set .@my_ip$, getcharip();
	if ( compare( .@my_ip$, .whitelist$ ) ) end;
 
	// Get list of accounts with attached character's IP address.
	set .@size, query_sql("SELECT `char`.`name` FROM `login` join `char` on `char`.account_id = login.account_id WHERE online = 1 and `last_ip` = '"+ .@my_ip$ +"' and `char`.`account_id` != "+ getcharid(3), .@name$ );
 
	// Passed check if only the attached player is returned.
	if ( .@size < 2 ) end;
	.@count++;

	// Check all online characters using the IP address if they are on a Battlegrounds map.
	for( ; .@i<.@size; set .@i,.@i+1) {
		getmapxy .@map$, .@x, .@y, 0, .@name$[.@i];
		if ( compare( .map_list$,.@map$ ) ) {
			.@count++;
			.@name_on_map$ = .@name_on_map$ + .@name$[.@i] + ( .@name_on_map$ == "" ? "," : "" );
			if ( .@count > 2 ) {
				message strcharinfo(0),"Characters "+ .@name_on_map$ +" is already present in a map with your IP. Kicking....";
				sleep2 2000;
				atcommand "@kick "+ strcharinfo(0);
				end;
			}
		}
	}
 
	// Passed check.
	end;
}

I assume you want to kick the third player regardless the maps of the others (prontera, geffen in the map list ; 1st player in prontera, 2nd geffen, 3rd geffen kicked)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  66
  • Topics Per Day:  0.02
  • Content Count:  167
  • Reputation:   2
  • Joined:  08/01/12
  • Last Seen:  

No, only for the maps in the oninit if possible.

 

I want players in the same household to be able to play WoE and BG together, but still to make it so that they can not open unlimited clients (2 max.) on these maps to avoid an unfair advantage.

 

Also that script seems to work fine! thank you :D

Edited by HristDead
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

-	script	WoE_IP_Kick	-1,{
OnInit:
	setmapflag "prtg_cas01", mf_loadevent;
	setmapflag "prtg_cas02", mf_loadevent;
	setmapflag "prtg_cas03", mf_loadevent;

	set .map_list$, "prtg_cas01 | prtg_cas02 | prtg_cas03";
	set .whitelist$, "xx.xx.xx.xx | xx.xx.xx.xx";
	end;
 
// Trigger when a player enters a map with "loadevent" mapflag.
OnPCLoadMapEvent:
 
	// Only run for map in the list.
	if ( compare( .map_list$,strcharinfo(3) ) == 0 ) end;
	
	set .@my_ip$, getcharip();
	if ( compare( .@my_ip$, .whitelist$ ) ) end;
 
	// Get list of name online with attached character's IP address.
	set .@size, query_sql("SELECT `char`.`name` FROM `login` join `char` on `char`.account_id = login.account_id WHERE online = 1 and `last_ip` = '"+ .@my_ip$ +"' and `char`.`account_id` != "+ getcharid(3), .@name$ );
 
	// Passed check if only the attached player is returned.
	if ( .@size < 2 ) end;
	setd ".@count_"+ strcharinfo(3), 1;

	// Check all online characters using the IP address if they are on a Battlegrounds map.
	for( ; .@i<.@size; set .@i,.@i+1) {
		getmapxy .@map$, .@x, .@y, 0, .@name$[.@i];
		if ( compare( .map_list$,.@map$ ) ) {
			if ( getd( ".@count_"+ .@map$ ) == 2 ) {
				message strcharinfo(0),"Characters "+ getd( ".@name_"+ .@map$ +"$" ) +" are already present in a map with your IP. Kicking....";
				sleep2 2000;
				atcommand "@kick "+ strcharinfo(0);
				end;
			}
			setd ".@count_"+ .@map$, getd( ".@count_"+ .@map$ );
			setd ".@name_"+ .@map$ +"$", getd( ".@name_"+ .@map$ +"$" ) + .@name$[.@i] + ( getd( ".@name_"+ .@map$ +"$" ) == "" ? "," : "" );
		}
	}
 
	// Passed check.
	end;
}

A map in the list allows 2 characters with the same ip (ip in the list) on the same map

The others players (others ip) can play with more than 3 clients btw (a bit weird?)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  66
  • Topics Per Day:  0.02
  • Content Count:  167
  • Reputation:   2
  • Joined:  08/01/12
  • Last Seen:  

-	script	WoE_IP_Kick	-1,{
OnInit:
	setmapflag "prtg_cas01", mf_loadevent;
	setmapflag "prtg_cas02", mf_loadevent;
	setmapflag "prtg_cas03", mf_loadevent;

	set .map_list$, "prtg_cas01 | prtg_cas02 | prtg_cas03";
	set .whitelist$, "xx.xx.xx.xx | xx.xx.xx.xx";
	end;
 
// Trigger when a player enters a map with "loadevent" mapflag.
OnPCLoadMapEvent:
 
	// Only run for map in the list.
	if ( compare( .map_list$,strcharinfo(3) ) == 0 ) end;
	
	set .@my_ip$, getcharip();
	if ( compare( .@my_ip$, .whitelist$ ) ) end;
 
	// Get list of name online with attached character's IP address.
	set .@size, query_sql("SELECT `char`.`name` FROM `login` join `char` on `char`.account_id = login.account_id WHERE online = 1 and `last_ip` = '"+ .@my_ip$ +"' and `char`.`account_id` != "+ getcharid(3), .@name$ );
 
	// Passed check if only the attached player is returned.
	if ( .@size < 2 ) end;
	setd ".@count_"+ strcharinfo(3), 1;

	// Check all online characters using the IP address if they are on a Battlegrounds map.
	for( ; .@i<.@size; set .@i,.@i+1) {
		getmapxy .@map$, .@x, .@y, 0, .@name$[.@i];
		if ( compare( .map_list$,.@map$ ) ) {
			if ( getd( ".@count_"+ .@map$ ) == 2 ) {
				message strcharinfo(0),"Characters "+ getd( ".@name_"+ .@map$ +"$" ) +" are already present in a map with your IP. Kicking....";
				sleep2 2000;
				atcommand "@kick "+ strcharinfo(0);
				end;
			}
			setd ".@count_"+ .@map$, getd( ".@count_"+ .@map$ );
			setd ".@name_"+ .@map$ +"$", getd( ".@name_"+ .@map$ +"$" ) + .@name$[.@i] + ( getd( ".@name_"+ .@map$ +"$" ) == "" ? "," : "" );
		}
	}
 
	// Passed check.
	end;
}

A map in the list allows 2 characters with the same ip (ip in the list) on the same map

The others players (others ip) can play with more than 3 clients btw (a bit weird?)

 

 

Aah, it doesnt seem to work the way I am looking for after all. >.<

 

What I am looking for is...

Player IP/accounts which arent listed in the IP whitelist can open ONLY ONE client in mentioned maps.

Player IP/accounts that are listed can open ONLY TWO clients in mentioned maps.

 

Is that possible, sir Capuche?

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  


- script WoE_IP_Kick -1,{

OnInit:

setmapflag "prtg_cas01", mf_loadevent;

setmapflag "prtg_cas02", mf_loadevent;

setmapflag "prtg_cas03", mf_loadevent;

set .map_list$, "prtg_cas01 | prtg_cas02 | prtg_cas03";

set .whitelist$, "xx.xx.xx.xx | xx.xx.xx.xx";

end;

// Trigger when a player enters a map with "loadevent" mapflag.

OnPCLoadMapEvent:

// Only run for map in the list.

if ( compare( .map_list$,strcharinfo(3) ) == 0 ) end;

set .@my_ip$, getcharip();

if ( compare( .@my_ip$, .whitelist$ ) )

.@right = 2;

else

.@right = 1;

// Get list of name online with attached character's IP address.

set .@size, query_sql("SELECT `char`.`name` FROM `login` join `char` on `char`.account_id = login.account_id WHERE online = 1 and `last_ip` = '"+ .@my_ip$ +"' and `char`.`account_id` != "+ getcharid(3), .@name$ );

// Passed check if only the attached player is returned.

if ( .@size < .@right ) end;

setd ".@count_"+ strcharinfo(3), 1;

// Check all online characters using the IP address if they are on a Battlegrounds map.

for( ; .@i<.@size; set .@i,.@i+1) {

getmapxy .@map$, .@x, .@y, 0, .@name$[.@i];

if ( compare( .map_list$,.@map$ ) ) {

if ( getd( ".@count_"+ .@map$ ) == .@right ) {

message strcharinfo(0),"Characters "+ getd( ".@name_"+ .@map$ +"$" ) +" are already present in a map with your IP. Kicking....";

sleep2 2000;

atcommand "@kick "+ strcharinfo(0);

end;

}

setd ".@count_"+ .@map$, getd( ".@count_"+ .@map$ );

setd ".@name_"+ .@map$ +"$", getd( ".@name_"+ .@map$ +"$" ) + .@name$[.@i] + ( ( getd( ".@name_"+ .@map$ +"$" ) == "" && .@right == 2 ) ? "," : "" );

}

}

// Passed check.

end;

}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  66
  • Topics Per Day:  0.02
  • Content Count:  167
  • Reputation:   2
  • Joined:  08/01/12
  • Last Seen:  

-	script	WoE_IP_Kick	-1,{
OnInit:
	setmapflag "prtg_cas01", mf_loadevent;
	setmapflag "prtg_cas02", mf_loadevent;
	setmapflag "prtg_cas03", mf_loadevent;

	set .map_list$, "prtg_cas01 | prtg_cas02 | prtg_cas03";
	set .whitelist$, "xx.xx.xx.xx | xx.xx.xx.xx";
	end;
 
// Trigger when a player enters a map with "loadevent" mapflag.
OnPCLoadMapEvent:
 
	// Only run for map in the list.
	if ( compare( .map_list$,strcharinfo(3) ) == 0 ) end;
	
	set .@my_ip$, getcharip();
	if ( compare( .@my_ip$, .whitelist$ ) )
		.@right = 2;
	else
		.@right = 1;
 
	// Get list of name online with attached character's IP address.
	set .@size, query_sql("SELECT `char`.`name` FROM `login` join `char` on `char`.account_id = login.account_id WHERE online = 1 and `last_ip` = '"+ .@my_ip$ +"' and `char`.`account_id` != "+ getcharid(3), .@name$ );
 
	// Passed check if only the attached player is returned.
	if ( .@size < .@right ) end;
	setd ".@count_"+ strcharinfo(3), 1;

	// Check all online characters using the IP address if they are on a Battlegrounds map.
	for( ; .@i<.@size; set .@i,.@i+1) {
		getmapxy .@map$, .@x, .@y, 0, .@name$[.@i];
		if ( compare( .map_list$,.@map$ ) ) {
			if ( getd( ".@count_"+ .@map$ ) == .@right ) {
				message strcharinfo(0),"Characters "+ getd( ".@name_"+ .@map$ +"$" ) +" are already present in a map with your IP. Kicking....";
				sleep2 2000;
				atcommand "@kick "+ strcharinfo(0);
				end;
			}
			setd ".@count_"+ .@map$, getd( ".@count_"+ .@map$ );
			setd ".@name_"+ .@map$ +"$", getd( ".@name_"+ .@map$ +"$" ) + .@name$[.@i] + ( ( getd( ".@name_"+ .@map$ +"$" ) == "" && .@right == 2 ) ? "," : "" );
		}
	}
 
	// Passed check.
	end;
}

 

Tried this but it also kicks the second client of the player that uses an whitelist IP, while i want whitelist IPs to allow 2 clients.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  66
  • Topics Per Day:  0.02
  • Content Count:  167
  • Reputation:   2
  • Joined:  08/01/12
  • Last Seen:  

-	script	WoE_IP_Kick	-1,{
OnInit:
	setmapflag "prtg_cas01", mf_loadevent;
	setmapflag "prtg_cas02", mf_loadevent;
	setmapflag "prtg_cas03", mf_loadevent;

	set .map_list$, "prtg_cas01 | prtg_cas02 | prtg_cas03";
	set .whitelist$, "127.0.0.1 | xx.xx.xx.xx";
	end;
 
// Trigger when a player enters a map with "loadevent" mapflag.
OnPCLoadMapEvent:
 
	// Only run for map in the list.
	if ( compare( .map_list$,strcharinfo(3) ) == 0 ) end;
	
	set .@my_ip$, getcharip();
	if ( compare( .whitelist$,.@my_ip$ ) )
		.@right = 2;
	else
		.@right = 1;
 
	// Get list of name online with attached character's IP address.
	set .@size, query_sql("SELECT `char`.`name` FROM `login` join `char` on `char`.account_id = login.account_id WHERE online = 1 and `last_ip` = '"+ .@my_ip$ +"' and `char`.`account_id` != "+ getcharid(3), .@name$ );
 
	// Passed check if only the attached player is returned.
	if ( .@size < .@right ) end;
	setd ".@count_"+ strcharinfo(3), 1;

	// Check all online characters using the IP address if they are on a Battlegrounds map.
	for( ; .@i<.@size; set .@i,.@i+1) {
		getmapxy .@map$, .@x, .@y, 0, .@name$[.@i];
		if ( compare( .map_list$,.@map$ ) ) {
			setd ".@count_"+ .@map$, getd( ".@count_"+ .@map$ ) +1;
			setd ".@name_"+ .@map$ +"$", getd( ".@name_"+ .@map$ +"$" ) + .@name$[.@i] + ( ( getd( ".@name_"+ .@map$ +"$" ) == "" && .@right == 2 ) ? "," : "" );
			if ( getd( ".@count_"+ .@map$ ) == .@right +1 ) {
				message strcharinfo(0),"Characters "+ getd( ".@name_"+ .@map$ +"$" ) +" already present in a map with your IP. Kicking....";
				sleep2 2000;
				atcommand "@kick "+ strcharinfo(0);
				end;
			}
		}
	}
 
	// Passed check.
	end;
}

 

Thank you, this one works! :)

Link to comment
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.   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.

×
×
  • Create New...