View Single Post
  #1  
Old 03-17-2020, 10:53 AM
Shodai82
Sarnak
 
Join Date: May 2015
Posts: 43
Default Example - Alternate IP Restriction Approach

On UltimateEQ I've had max ip set to 3 for a long time now. While it works mostly as expected, the way the logic is implemented in the eqemu source (as far as I understand it), when a player logs out/disconnects/leaves the world, there is often a lag time that will not allow you to log in another character. This usually presents itself as "You have been disconnected" when trying to log in during this scenario. To work around this I implemented the following in global_player, event_enterzone (after updating max ips to -1 in the rules table):


HTML Code:
    if($zoneid != 344 && $zoneid != 151) { #exempt zones
    	if (!$client->GetGM()) {
    		my @exemptAccounts = ("###");

    		if (!grep{$_ eq $client->AccountName()} @exemptAccounts) {
			    my @clist = $entity_list->GetClientList();
			    my $ipCount = 0;
			    my @playerNames = ();

				foreach my $n (@clist) {
					if ($n->GetIP() == $client->GetIP()) {
						$ipCount = $ipCount + 1;
						push @playerNames, $n->GetCleanName();
					}
				}

				if ($ipCount > 3) {
					$client->WorldKick();
					foreach my $playerName (@playerNames) {
						my $currentClient = $entity_list->GetClientByName($playerName);
						$currentClient->Message(5, "Your client count exceeded the maximum amount per ip address (3). The client was disconnected.");
					}
				}
			}
		}
	}
Hopefully this is helpful for some. There are some enhancements you could do, such as querying the world instead of the current zones entity_list, but for my purposes (preventing mass zergs of players on content), it works quite well.
Reply With Quote