Jump to content
Sign in to follow this  
Ridley

Function to check for players with same IP on same map

Recommended Posts

This function will check for players with the same IP on the same map.

In the sample, if it finds a player with the same IP on said map, you get warped back to prontera and kicked.

Note: Don't use it recklessly or else you spam your mapserver and might kill it.

function	script	char_same_unique_id	{
	.@my_map$ = getarg(0);
	// get array of char names who are online from the same IP
	query_sql "SELECT `char`.`name` FROM `char` LEFT JOIN login ON `char`.account_id=login.account_id " +
	          "WHERE last_ip=(SELECT last_ip FROM login WHERE account_id="+playerattached()+") AND online AND `char`.account_id!=" + playerattached(), .@name$;
	// check each char, and see if they are on the map
	for (.@i = 0; .@i < getarraysize(.@name$); .@i++) {
		getmapxy .@map$, .@x, .@y, 0, .@name$[.@i];
		if (.@map$ == .@my_map$)
			return 1; // another char from this IP is already on that map
	}
	return 0; // no other chars from this IP are on that map
}

///////////////////////
// Example for usage //
///////////////////////

-	script	OnPCLoadMapEvent	FAKE_NPC,{
OnInit:
	setarray(.nodualmaps$[0], "schg_cas06", "schg_cas07", "schg_cas08", "arug_cas06", "arug_cas07", "arug_cas08", "bat_b03");
	end;

OnPCLoadMapEvent:
	getmapxy(.@map$, .@x, .@y, 0);
	// -- BG Maps ---------------------------------
	for (.@i = 0; .@i < getarraysize(.nodualmaps$); ++.@i) {
		if (.@map$ == .nodualmaps$[.@i]) {
			if (callfunc("char_same_unique_id", .nodualmaps$[.@i])) {
				dispbottom("No dual clienting in BG please.");
				warp("prontera",156,184);
				atcommand("@kick " + strcharinfo(PC_NAME));
			}
		}
	}
}

 

char_same_unique_id.txt

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
Reply to this topic...

×   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.