Teamspeak

Hier findest Du einige Modifikationen und erweiterte Mods und Serverviewer rund um Teamspeak 2 & 3.

Teamspeak 2: Modifizierter PerlMod

Einige Änderungen von mir am PerlMod von ScP.

Modifikationen:

  • Auto Admin Channel --> In diesem Channel erhält man SA Rechte (Passwort wäre angebracht).
  • Kick Channel --> Man fliegt raus, wenn man kein SA hat.
  • Auto Registration Channel --> In diesem Channel erhält man automatisch Registrierungsrechte, kann auch mit Sticky setzen des Channels als Zwangsregistrierung genutzt werden.
  • SA's bekommen mehr Informationen, auch wird weiter ins Logfile geschrieben. (Login, IP, usw.)
  • SA's und Logeinträge beinhalten den Loginnamen eines Players nur, wenn dieser registriert ist.
  • Bestrafung "move" wird automatisch durch "kick" ersetzt, wenn es sonst eine Loopmessage geben würde.
  • Channel muss nur dann in die cfg geschrieben werden, wenn die Bestrafung "move" ist.
  • cfg File umgeschrieben, mehr Erklärung drin.
  • Manch Code optimiert / umgeschrieben / neugeschrieben.
  • Bantime ist nun per cfg einstellbar.
  • Nachrichten können nun mit Variablen (z.B. für Playernamen) angegeben werden, eine Liste der Vars ist am Ende des cfg Files.

Installation:

Archiv entpacken, Ordner in TS 2 Installation uploaden und Multi Startscript ausführen (nach Serverstart).

Danke ausserdem an Haufe (für manch Hilfe & Idee) und mcmax (für einige Ideen)!

Viel Spass damit.

ts2perlmod.pl

Code eingefügt. Hier klicken zum Ein- / Ausblenden
#!/usr/bin/perl

# ts2perlmod.pl - TS2PerlMod GNU/GPL-Edition
# This script runs in an infinite loop and performs various actions on your TeamSpeak server
# Written 2006 by Sven Paulsen

use strict;
use warnings;
use diagnostics;

use lib "packages";

require "./packages/lib-ts2perlmod.pl";

use Data::Dumper;
use TeamSpeak2::TCPquery;

use constant SCRIPT => {
  name    => "TS2 PerlMod GNU/GPL-Edition",
  version => "0.9.19 ext",
  config  => "8767.ini",
  pidfile => "ts2perlmod.pid",
  daemon  => 0,
};

&init();

# read the scripts configuration file
my %config = &readConfig();

# open the scripts logfile
my $log;
$log = &openLog($config{"LOG"}{"File"}) if($config{"LOG"}{"Enabled"});
&log($log, SCRIPT->{name}." started.");

# connect to server and create a new TeamSpeak2::TCPquery object
my $ts2 = TeamSpeak2::TCPquery->new(&trim($config{"CONNECTION"}{"ServerAddress"}),&trim($config{"CONNECTION"}{"ServerTCPPort"})) || &abort("Could not establish connection to server: ".$config{"CONNECTION"}{"ServerAddress"});
&printColored("ok", "Connected to server: ".$config{"CONNECTION"}{"ServerAddress"});

# disable debugging
$ts2->toggleDebug();

# check serverversion
my $version = $ts2->getServerversion();
if($version->{release} < 21) {
  &printColored("**", "The server is running an outdated version: ".$version->{version});
}

# select virtual server
$ts2->selectServer(&trim($config{"CONNECTION"}{"ServerUDPPort"})) || &abort("Could not select virtual server on port: ".$config{"CONNECTION"}{"ServerUDPPort"});
&printColored("ok", "Selected virtual server on port: ".$config{"CONNECTION"}{"ServerUDPPort"});

# authenticate as superadmin
$ts2->loginSuperadmin(&trim($config{"LOGIN"}{"Username"}),&trim($config{"LOGIN"}{"Password"})) || &abort("Could not authenticate as user: ".$config{"LOGIN"}{"Username"});
&printColored("ok", "Authenticated as user: ".$config{"LOGIN"}{"Username"});

# check the scripts settings
my %settings = %{&checkFeatureSettings($ts2,\%config)};
&log($log, "Initialization sequence completed.");

&daemonize();

# declare some vars, arrays and hashes to store various information
my $sent_stats = 0;
my $last_stats = time();
my $last_advert = time();
my $last_serverset = time();
my $last_config_reload = time();
my %new_players;
my %nicks_not_checked;
my %exploits_not_checked;
my %set_sticky;
my %old_channel;
my %old_channels;
my %connections;

# create TeamSpeak2::TCPquery::Server object
my $server = $ts2->getServer($config{"CONNECTION"}{"ServerUDPPort"});

eval {

  # enter the main loop
  while(1) {
  
    # get the servers playerlist
    my @playerlist = $ts2->getPlayerlist();
  
    # get the servers channellist
    my @channellist = $ts2->getChannellist();
  
    # update TeamSpeak2::TCPquery::Server object
    $server->getServerinfo();
  
    # get the servers playerlist
    foreach my $player (@playerlist) {
    
      # create a new TeamSpeak2::TCPquery::Channel object
      my $channel = $player->getChannel();
      next if(!$channel);
    
      # check if current player is protected
      my $protected = &checkProtection($player->{loginname},@{$settings{protectuser}{content}}) if($config{"PROTECTED-USERS"}{"Enabled"});
	  
      # check if current player is protected Admin
      my $protected_admin = &checkSAProtection($player->{loginname},@{$settings{protectadmins}{content}}) if($config{"PROTECTED-ADMINS"}{"Enabled"});
	   
      # extended welcome message
      if($config{"WELCOME-MESSAGE"}{"Enabled"}) {
        if($player->{logintime} <= $settings{repeat} && !exists($new_players{$player->{p_id}})) {
          $new_players{$player->{p_id}} = time();
          my @message = &parseMessage($player,$channel,$server,$version,@{$settings{welcome}{content}});
          $player->sendMessage(@message);
          if(!$player->{pprivs}->{registered}) {
		    &log($log, "[WELCOME-MESSAGE] Sent welcome message to player ".$player->{nick}." ".$player->getFlags()." with IP: ".$player->{ip});
		  }
          elsif($player->{pprivs}->{registered}) {
		    &log($log, "[WELCOME-MESSAGE] Sent welcome message to player ".$player->{nick}." [".$player->{loginname}."] ".$player->getFlags()." with IP: ".$player->{ip});
		  }
          foreach my $player2 (@playerlist) {
            if($player2->{p_id} != $player->{p_id} && $player2->{pprivs}->{serveradmin} && !$player->{pprivs}->{registered}) {
              $player2->sendMessage($player->{nick}." ".$player->getFlags()." joined with IP: ".$player->{ip});
            }
            elsif($player2->{p_id} != $player->{p_id} && $player2->{pprivs}->{serveradmin} && $player->{pprivs}->{registered}) {
              $player2->sendMessage($player->{nick}." [".$player->{loginname}."] ".$player->getFlags()." joined with IP: ".$player->{ip});
            }
          }
		}
      }
    
      # sticky channel
      if($config{"STICKY-CHANNEL"}{"Enabled"}) {
        if(exists($set_sticky{$player->{p_id}}) && $player->{c_id} != $settings{sticky}{channel}->{id}) {
          delete $set_sticky{$player->{p_id}};
          $player->setSticky(0);
		  my @message = &parseMessage($player,$channel,$server,$version,@{$settings{sticky}{message1}});
          $player->sendMessage(@message);
          if(!$player->{pprivs}->{registered}) {
            &log($log, "[STICKY-CHANNEL] Released player ".$player->{nick}." ".$player->getFlags()." from channel ".$settings{sticky}{channel}->{name});
          }
          elsif($player->{pprivs}->{registered}) {
            &log($log, "[STICKY-CHANNEL] Released player ".$player->{nick}." [".$player->{loginname}."] ".$player->getFlags()." from channel ".$settings{sticky}{channel}->{name}.".");
          }
          foreach my $player2 (@playerlist) {
            if($player2->{pprivs}->{serveradmin} && !$player->{pprivs}->{registered}) {
              $player2->sendMessage($player->{nick}." ".$player->getFlags()." get free.");
            }
            elsif($player2->{pprivs}->{serveradmin} && $player->{pprivs}->{registered}) {
              $player2->sendMessage($player->{nick}." [".$player->{loginname}."] ".$player->getFlags()." get free.");
            }
		  }
		}
        if($player->{c_id} == $settings{sticky}{channel}->{id} && !$player->{pprivs}->{sticky} && !$player->{pprivs}->{serveradmin}) {
          $set_sticky{$player->{p_id}} = 1 if(!exists($set_sticky{$player->{p_id}}));
          $player->setSticky(1);
		  my @message = &parseMessage($player,$channel,$server,$version,@{$settings{sticky}{message2}});
          $player->sendMessage(@message);
          if(!$player->{pprivs}->{registered}) {
            &log($log, "[STICKY-CHANNEL] Stuck player ".$player->{nick}." ".$player->getFlags()." to channel ".$settings{sticky}{channel}->{name});
          }
          elsif($player->{pprivs}->{registered}) {
            &log($log, "[STICKY-CHANNEL] Stuck player ".$player->{nick}." [".$player->{loginname}."] ".$player->getFlags()." to channel ".$settings{sticky}{channel}->{name}.".");
          }
          foreach my $player2 (@playerlist) {
            if($player2->{pprivs}->{serveradmin} && !$player->{pprivs}->{registered}) {
              $player2->sendMessage($player->{nick}." ".$player->getFlags()." set sticky.");
            }
            elsif($player2->{pprivs}->{serveradmin} && $player->{pprivs}->{registered}) {
              $player2->sendMessage($player->{nick}." [".$player->{loginname}."] ".$player->getFlags()." set sticky.");
            }
		  }
        }
      }
	  
      # auto registration channel
      if($config{"REGISTER-CHANNEL"}{"Enabled"}) {
	    if($player->{c_id} != $settings{register}{channel}->{id}){
	      $old_channel{$player->{p_id}} = $player->{c_id} ;
		}
        if(!$player->{pprivs}->{registered} && !$player->{pprivs}->{allowed_reg}) {
          if($config{"REGISTER-CHANNEL"}{"Automove"}) {
            if($player->move($settings{register}{channel}->{id})) {
              $player->setSticky(1) if($config{"REGISTER-CHANNEL"}{"Sticky"});
			}
		  }
          if($player->{c_id} == $settings{register}{channel}->{id} && !$player->{pprivs}->{registered}) {
            $ts2->execute("sppriv " . $player->{p_id} . " privilege_canregister 1");
		    my @message1 = &parseMessage($player,$channel,$server,$version,@{$settings{register}{message1}});
            $player->sendMessage(@message1);
		    my @message2 = &parseMessage($player,$channel,$server,$version,@{$settings{register}{message2}});
            $player->sendMessage(@message2);
		  }
		} 
		elsif(!$player->{pprivs}->{serveradmin} && $player->{pprivs}->{registered} && $player->{c_id} == $settings{register}{channel}->{id} && $player->{c_id} != $settings{sticky}{channel}->{id}) {
		  $player->setSticky(0) if($config{"REGISTER-CHANNEL"}{"Sticky"});
          $player->move($old_channel{$player->{p_id}}) if($old_channel{$player->{p_id}});
		  &log($log, "[REGISTER-CHANNEL] ".$player->{nick}." ".$player->getFlags()." is now registered. Loginname: ".$player->{loginname});
          foreach my $player2 (@playerlist) {
            if($player2->{pprivs}->{serveradmin}) {
              $player2->sendMessage($player->{nick}." ".$player->getFlags()." is now registered. Loginname: ".$player->{loginname});
            }
		  }
		}
	  }
	  
	  # admin channel
	  if($config{"ADMIN-CHANNEL"}{"Enabled"} && !$settings{protectadmins}{safromlist}) {
		if(!$player->{pprivs}->{serveradmin} && $player->{c_id} == $settings{admin}{channel}->{id}) {
		  $player->setServeradmin(1);
          my @message = &parseMessage($player,$channel,$server,$version,@{$settings{admin}{content}});
          $player->sendMessage(@message);
		  &log($log, "[ADMIN-CHANNEL] ".$player->{nick}." [".$player->{loginname}."] ".$player->getFlags()." is now Serveradmin.");
          foreach my $player2 (@playerlist) {
            if($player2->{p_id} != $player->{p_id} && $player2->{pprivs}->{serveradmin}) {
              $player2->sendMessage($player->{nick}." [".$player->{loginname}."] ".$player->getFlags()." is now Serveradmin.");
            }
		  }
		}
	  }
	  
	  # protected admin
	  if($config{"PROTECTED-ADMINS"}{"Enabled"}) {
	    if(!$player->{pprivs}->{serveradmin} && $protected_admin){
		  $player->setServeradmin(1);
          my @message1 = &parseMessage($player,$channel,$server,$version,@{$settings{protectadmins}{message1}});
          $player->sendMessage(@message1);
		  &log($log, "[PROTECTED-ADMINS] Granted SA privileges to ".$player->{nick}." [".$player->{loginname}."] ".$player->getFlags());
          foreach my $player2 (@playerlist) {
            if($player2->{p_id} != $player->{p_id} && $player2->{pprivs}->{serveradmin}) {
              $player2->sendMessage("Granted SA privileges to ".$player->{nick}." [".$player->{loginname}."] ".$player->getFlags().". Reason: Protected Admin");
            }
		  }
        }
		elsif($settings{"protectadmins"}{"safromlist"} && $player->{pprivs}->{serveradmin} && !$protected_admin && !$protected){
		  $player->setServeradmin(0);
          my @message2 = &parseMessage($player,$channel,$server,$version,@{$settings{protectadmins}{message2}});
          $player->sendMessage(@message2);
		  &log($log, "[PROTECTED-ADMINS] Revoked SA privileges from ".$player->{nick}." [".$player->{loginname}."] ".$player->getFlags());
          foreach my $player2 (@playerlist) {
            if($player2->{p_id} != $player->{p_id} && $player2->{pprivs}->{serveradmin}) {
              $player2->sendMessage("Revoked SA privileges from ".$player->{nick}." [".$player->{loginname}."] ".$player->getFlags().". Reason: No protected Admin");
            }
		  }
		}
	  }
	  
	  # kick channel
	  if($config{"KICK-CHANNEL"}{"Enabled"} && !$protected) {
		if(!$player->{pprivs}->{serveradmin} && $player->{c_id} == $settings{kick}{channel}->{id}) {
          my @message = &parseMessage($player,$channel,$server,$version,@{$settings{kick}{content}});
          $player->sendMessage(@message);			
		  &punish($player,$settings{kick});
		  if($settings{"kick"}{"punishment"} eq "move") {
		    $ts2->execute("kick " . $player->{p_id});
		  }
		  foreach my $player2 (@playerlist) {
		    if($player2->{pprivs}->{serveradmin} && !$player->{pprivs}->{registered}){
			  $player2->sendMessage($player->{nick}." ".$player->getFlags()." have a bad day ;-)");
			}
		    elsif($player2->{pprivs}->{serveradmin} && $player->{pprivs}->{registered}){
			  $player2->sendMessage($player->{nick}." [".$player->{loginname}."] ".$player->getFlags()." have a bad day ;-)");
			}
	      }
		}
	  }  
    
      # warn idlers
      if($config{"WARN-IDLERS"}{"Enabled"} && !$protected) {
        if($player->{idletime} >= $settings{warnidler}{idletime} && $player->{idletime} <= ($settings{warnidler}{idletime} + $settings{repeat})) {
          my @message = &parseMessage($player,$channel,$server,$version,@{$settings{warnidler}{content}});
          $player->sendMessage(@message);
          if(!$player->{pprivs}->{registered}) {
            &log($log, "[WARN-IDLERS] Warned player ".$player->{nick}." ".$player->getFlags()." after ".formatTime($player->{idletime}).".");
          }
          elsif($player->{pprivs}->{registered}) {
            &log($log, "[WARN-IDLERS] Warned player ".$player->{nick}." [".$player->{loginname}."] ".$player->getFlags()." after ".formatTime($player->{idletime}).".");
          }
        }
      }
    
      # move idlers
      if($config{"MOVE-IDLERS"}{"Enabled"} && !$protected) {
        if($player->{idletime} >= $settings{moveidler}{idletime} && !$player->{pprivs}->{sticky} && $player->{c_id} != $settings{moveidler}{channel}->{id}) {
          $player->move($settings{moveidler}{channel}->{id});
          my @message = &parseMessage($player,$channel,$server,$version,@{$settings{moveidler}{content}});
          $player->sendMessage(@message);
          if(!$player->{pprivs}->{registered}) {
            &log($log, "[WARN-IDLERS] Moved player ".$player->{nick}." ".$player->getFlags()." after ".formatTime($player->{idletime}).".");
          }
          elsif($player->{pprivs}->{registered}) {
            &log($log, "[WARN-IDLERS] Moved player ".$player->{nick}." [".$player->{loginname}."] ".$player->getFlags()." after ".formatTime($player->{idletime}).".");
          }
        }
      }
	
      # bad nickname
      if($config{"BAD-NICKNAME"}{"Enabled"} && !$protected) {
        if($player->{logintime} <= $settings{repeat} && !exists($nicks_not_checked{$player->{p_id}})) {
          $nicks_not_checked{$player->{p_id}} = time();
        }
        if(exists($nicks_not_checked{$player->{p_id}})) {
          foreach(@{$settings{badnick}{content}}) {
            if(lc($player->{nick}) =~ /$_/i) {
              my @message = &parseMessage($player,$channel,$server,$version,@{$settings{badnick}{content2}});
              $player->sendMessage(@message);
              &punish($player,$settings{badnick});
			  if(!$player->{pprivs}->{registered}) {
				&log($log, "[BAD-NICKNAME] Punished player ".$player->{nick}." ".$player->getFlags()." for a bad nickname.");
			  }
			  elsif($player->{pprivs}->{registered}) {
				&log($log, "[BAD-NICKNAME] Punished player ".$player->{nick}." [".$player->{loginname}."] ".$player->getFlags()." for a bad nickname.");
			  }
              foreach my $player2 (@playerlist) {
                if($player2->{pprivs}->{serveradmin} && !$player->{pprivs}->{registered}) {
                  $player2->sendMessage($player->{nick}." ".$player->getFlags()." punished. Reason: Bad Nick Protection");
                }
                elsif($player2->{pprivs}->{serveradmin} && $player->{pprivs}->{registered}) {
                  $player2->sendMessage($player->{nick}." [".$player->{loginname}."] ".$player->getFlags()." punished. Reason: Bad Nick Protection");
                }
			  }
            }
          }
          delete $nicks_not_checked{$player->{p_id}};
        }
      }
      
      # bad channel
      if($config{"BAD-CHANNEL"}{"Enabled"} && !$protected) {
        if($channel->{flags}->{unregistered}) {
          foreach(@{$settings{badchan}{content}}) {
            if(lc($channel->{name}) =~ /$_/i) {
              my @message = &parseMessage($player,$channel,$server,$version,@{$settings{badchan}{content2}});
              $player->sendMessage(@message);			
              &punish($player,$settings{badchan});
			  if(!$player->{pprivs}->{registered}) {
				&log($log, "[BAD-CHANNEL] Punished player ".$player->{nick}." ".$player->getFlags()." for creating channel ".$channel->{name});
			  }
			  elsif($player->{pprivs}->{registered}) {
				&log($log, "[BAD-CHANNEL] Punished player ".$player->{nick}." [".$player->{loginname}."] ".$player->getFlags()." for creating channel ".$channel->{name});
			  }
			  foreach my $player2 (@playerlist) {
                if($player2->{pprivs}->{serveradmin} && !$player->{pprivs}->{registered}) {
                  $player2->sendMessage($player->{nick}." ".$player->getFlags()." punished. Reason: Bad Channel Protection");
                }
                elsif($player2->{pprivs}->{serveradmin} && $player->{pprivs}->{registered}) {
                  $player2->sendMessage($player->{nick}." [".$player->{loginname}."] ".$player->getFlags()." punished. Reason: Bad Channel Protection");
                }
			  }
            }
          }
        }
      }
	
      # anti rec
      if($config{"ANTI-REC"}{"Enabled"} && !$protected) {
        if($player->{pflags}->{recording}) {
          my @message = &parseMessage($player,$channel,$server,$version,@{$settings{antirec}{content}});
          $player->sendMessage(@message);			
          &punish($player,$settings{antirec});
		  if($settings{"antirec"}{"punishment"} eq "move") {
		    $ts2->execute("kick " . $player->{p_id});
		  }
		  if(!$player->{pprivs}->{registered}) {
			&log($log, "[ANTI-REC] Punished player ".$player->{nick}." ".$player->getFlags()." for recording.");
		  }
		  elsif($player->{pprivs}->{registered}) {
			&log($log, "[ANTI-REC] Punished player ".$player->{nick}." [".$player->{loginname}."] ".$player->getFlags()." for recording.");
		  }
		  foreach my $player2 (@playerlist) {
            if($player2->{pprivs}->{serveradmin} && !$player->{pprivs}->{registered}) {
              $player2->sendMessage($player->{nick}." ".$player->getFlags()." punished. Reason: Record Protection");
            }
            elsif($player2->{pprivs}->{serveradmin} && $player->{pprivs}->{registered}) {
              $player2->sendMessage($player->{nick}." [".$player->{loginname}."] ".$player->getFlags()." punished. Reason: Record Protection");
            }
	      }
        }
      }
    
      # take over protection
      if($config{"TAKE-OVER-PROTECTION"}{"Enabled"}) {
        if($player->{pprivs}->{serveradmin} && !$player->{pprivs}->{registered}) {
          $player->setServeradmin(0);
          my @message = &parseMessage($player,$channel,$server,$version,@{$settings{takeover}{content}});
          $player->sendMessage(@message);			
          &punish($player,$settings{takeover});
		  if($settings{"takeover"}{"punishment"} eq "move") {
		    $ts2->execute("kick " . $player->{p_id});
		  }
          &log($log, "[TAKE-OVER-PROTECTION] Punished player ".$player->{nick}." ".$player->getFlags());
		  foreach my $player2 (@playerlist) {
            if($player2->{p_id} != $player->{p_id} && $player2->{pprivs}->{serveradmin}) {
              $player2->sendMessage($player->{nick}." ".$player->getFlags()." punished. Reason: Take over Protection");
            }
		  }
        }
      }
    
      # auto afk
      if($config{"AUTO-AFK"}{"Enabled"} && !$protected) {
        if($player->{c_id} != $settings{autoafk}{channel}->{id} && $player->{pflags}->{away} && !$player->{pprivs}->{sticky}) {
          if($player->move($settings{autoafk}{channel}->{id})) {
            $old_channels{$player->{p_id}} = $player->{c_id} if(!exists($old_channels{$player->{p_id}}));
          }
        } 
		elsif(!$player->{pflags}->{away} && exists($old_channels{$player->{p_id}})) {
          if($player->{c_id} == $settings{autoafk}{channel}->{id}) {
            $player->move($old_channels{$player->{p_id}});
          }
          delete $old_channels{$player->{p_id}};
        }
      }
    
      # anti flood
      if($config{"ANTI-FLOOD"}{"Enabled"}) {
        if($player->{logintime} <= $settings{repeat}) {
          if(!exists($connections{$player->{ip}})) {
            $connections{$player->{ip}} = [time(), 1];
          } 
		  else {
            my $remaining_connections = $settings{antiflood}{connections}-@{$connections{$player->{ip}}}[1];
            @{$connections{$player->{ip}}}[1]++ if(time()-@{$connections{$player->{ip}}}[0] <= $settings{antiflood}{seconds});
			if(!$remaining_connections) {
              my @message = &parseMessage($player,$channel,$server,$version,@{$settings{antiflood}{content}});
              $player->sendMessage(@message);			
              &punish($player,$settings{antiflood});
			  if($settings{"antiflood"}{"punishment"} eq "move") {
				$ts2->execute("kick " . $player->{p_id});
			  }
              &log($log, "[ANTI-FLOOD] Add IP address ".$player->{ip}." to banlist");
			  foreach my $player2 (@playerlist) {
                if($player2->{pprivs}->{serveradmin}) {
                  $player2->sendMessage($player->{nick}." ".$player->getFlags()." punished. Reason: Flood Protection");
                }
			  }
			}
          }
        }
      }
    
      # stats message
      if($config{"STATS-MESSAGE"}{"Enabled"}) {
        if($last_stats + $settings{stats}{interval} < time()) {
          my @message = &parseMessage($player,$channel,$server,$version,@{$settings{stats}{content}});
          $player->sendMessage(@message);
          $sent_stats = 1;
        }
      }
      
      # bug detection
      if($config{"BUG-DETECTION"}{"Enabled"}) {
        if($player->{logintime} <= $settings{repeat} && !exists($exploits_not_checked{$player->{p_id}})) {
          $exploits_not_checked{$player->{p_id}} = time();
        }
        if(exists($exploits_not_checked{$player->{p_id}})) {
          if(length($player->{nick}) > 29 || !parseRtfString($player->{nick}) || !parseNullbyteString($player->{nick})) {
            my @message = &parseMessage($player,$channel,$server,$version,@{$settings{bugdetection}{content}});
            $player->sendMessage(@message);	
            &punish($player,$settings{bugdetection});
			if($settings{"bugdetection"}{"punishment"} eq "move") {
			  ts2->execute("kick " . $player->{p_id});
			}
            &log($log, "[BUG-DETECTION] Exploit attempt detected while checking nickname of player ".$player->{nick}." ".$player->getFlags());
			foreach my $player2 (@playerlist) {
              if($player2->{pprivs}->{serveradmin}) {
                $player2->sendMessage($player->{nick}." ".$player->getFlags()." punished. Reason: Bug / Exploit Protection");
			  }
			}
          }
          delete $exploits_not_checked{$player->{p_id}};
        }
        if(length($channel->{name}) > 29 || !parseRtfString($channel->{name}) || !parseNullbyteString($channel->{name})) {
          my @message = &parseMessage($player,$channel,$server,$version,@{$settings{bugdetection}{content}});
          $player->sendMessage(@message);	
          &punish($player,$settings{bugdetection});
		  if($settings{"bugdetection"}{"punishment"} eq "move") {
			$ts2->execute("kick " . $player->{p_id});
		  }
          &log($log, "[BUG-DETECTION] Exploit attempt detected while checking channel of player ".$player->{nick}." ".$player->getFlags());
		  foreach my $player2 (@playerlist) {
            if($player2->{pprivs}->{serveradmin}) {
              $player2->sendMessage($player->{nick}." ".$player->getFlags()." punished. Reason: Bug / Exploit Protection");
            }
	      }
        }
      }
    }
	
    # kick idlers
    if($config{"KICK-IDLERS"}{"Enabled"}) {
      my $kicked = $server->kickIdlers($settings{kickidler}{idletime},$settings{kickidler}{targets},$settings{kickidler}{reason});
	  my $x = "player";
      $x = "players" if($kicked > 1);
      &log($log, "[KICK-IDLERS] Kicked ".$kicked." idle ".$x." from server.") if($kicked);
	  foreach my $player2 (@playerlist) {
        if($player2->{pprivs}->{serveradmin} && $kicked) {
          $player2->sendMessage("Kicked ".$kicked." idle ".$x." from server.");
        }
	  }
	}
    
    # update banlist
    if($config{"UPDATE-BANLIST"}{"Enabled"}) {
      foreach($ts2->getBanlist) {
        if($_->{mins} == "0") {
          $ts2->deleteBan($_->{b_id});
          $ts2->addBan($_->{ip}, $settings{banupd}{mins});
          &log($log, "[UPDATE-BANLIST] Converted permanent ban of IP ".$_->{ip}." into a ".$settings{banupd}{mins}." minute timeban.");
		  foreach my $player2 (@playerlist) {
			if($player2->{pprivs}->{serveradmin}) {
			  $player2->sendMessage("Converted permanent ban of IP ".$_->{ip}." into a ".$settings{banupd}{mins}." minute timeban.");
			}
		  }
		}
      }
    }
	
    # advert message
    if($config{"ADVERT-MESSAGE"}{"Enabled"}) {
      if($last_advert + $settings{advert}{interval} < time()) {
        $server->sendMessage(@{$settings{advert}{content}});
        $last_advert = time();
      }
    }
    
    # auto servertype
    if($config{"AUTO-SERVERTYPE"}{"Enabled"}) {
      if($last_serverset + $settings{serverset}{interval} < time()) {
        if($server->{server_currentusers} > $settings{serverset}{clients}) {
          if($server->{server_clan_server}) {
            $server->setModePublic();
            &log($log, "[AUTO-SERVERTYPE] Changed type of server ".$server->{server_name}." (".$server->{server_currentusers}."/".$server->{server_maxusers}.") to public.");
		    foreach my $player (@playerlist) {
              if($player->{pprivs}->{serveradmin}) {
                $player->sendMessage("Changed type of server to public. Current players: ".$server->{server_currentusers}."/".$server->{server_maxusers});
              }
	        }
		  }
        } 
		else {
          if(!$server->{server_clan_server}) {
            $server->setModeClan();
            &log($log, "[AUTO-SERVERTYPE] Changed type of server ".$server->{server_name}." (".$server->{server_currentusers}."/".$server->{server_maxusers}.") to clan.");
		    foreach my $player (@playerlist) {
              if($player->{pprivs}->{serveradmin}) {
                $player->sendMessage("Changed type of server to clan. Current players: ".$server->{server_currentusers}."/".$server->{server_maxusers});
              }
	        }
		  }
        }
        $last_serverset = time();
      }
    }
	
    # reload config
    if($last_config_reload + $settings{reload} < time()) {
      %config = &readConfig();
      %settings = %{&checkFeatureSettings($ts2,\%config)};
      $last_config_reload = time();
    }
	
    # reset stats timer
    if($sent_stats) {
      $last_stats = time();
      $sent_stats = 0;
    }
	
    # delete outdated entries from hashes
    my $first_player = (@playerlist) ? shift(@playerlist) : 0;
    foreach(keys(%new_players)) { delete $new_players{$_} if((time()-$settings{repeat}) > $new_players{$_}); }
    foreach(keys(%set_sticky)) { delete $set_sticky{$_} if($first_player && $_ < $first_player->{p_id}); }
	foreach(keys(%old_channel)) { delete $old_channel{$_} if($first_player && $_ < $first_player->{p_id}); }
	foreach(keys(%old_channels)) { delete $old_channels{$_} if($first_player && $_ < $first_player->{p_id}); }
    foreach(keys(%connections)) { delete $connections{$_} if(time()-@{$connections{$_}}[0] > $settings{antiflood}{seconds}); }
	
    # wait for x seconds
    sleep $settings{repeat};
  }
};

# catch and log critical errors
if($@) {
  &log($log, &trim($@));
}

exit(1);

Zurück