#!/usr/bin/perl use KKrcon; # these actions will be trigged on # NOTE: Don't trig on 'say' or 'hltrig', you'll get horrible repeat effects! %actions = ( # "connected", 1, "entered", 1, "joined", 1, "killed", 1, "triggered", 1, # "disconnected", 1, "attacked",1 ); $rcon = new KKrcon( Host => "127.0.0.1", Port => 27015, Password => "XXX", Type => "new" ); while ( ) { if ( not scalar @ARGV ) { print $_; } if ( /L .*? - .*?: Secure: (\".*?\"|.*?) was detected cheating/ ) { # split player names into parts if ( $1 =~ /^\"?(.*?)<(\d+)><(\d+)><(\w*)>\"?/ ) { $subject = $1; $wonid = $3; } $command = "admin_command hltrig_cheat \"$subject\\$wonid\""; if ( scalar @ARGV ) { print "$command\n"; } else { print $rcon->execute($command); if (my $error = $rcon->error()) { print "HLTrig error: $error\n"; } } } elsif ( /L .*? - .*?: (\".+?\"|.+?) (\w+)( \"(.+?)\"|)(.+?\"(.+?)\"|)(.*)/ ) { if ( defined $actions{$2} ) { $subject = $1; $action = $2; $object = $4; $item = $6; $rest = $7; #print "1:$1 2:$2 3:$3 4:$4 5:$5 6:$6\n"; # split player names into parts if ( $subject =~ /^(.*?)<(\d+)><(\d+)><(\w*)>/ ) { $subject = $1; } if ( $object =~ /^(.*?)<(\d+)><(\d+)><(\w*)>/ ) { $object = $1; } # strip off all quotes $subject =~ s/\"//g; $action =~ s/\"//g; $object =~ s/\"//g; if ($item ne "") { $object .= "\\$item"; } if ($rest =~ /\(damage \"(\d+)\"\) \(damage_armor \"(\d+)\"\)/) { $damage = $1; $darmor = $2; $object .= "\\$damage\\$darmor"; } $command = "admin_command hltrig \"$subject\\$action\\$object\""; if ( scalar @ARGV ) { print "$command\n"; } else { print $rcon->execute($command); if (my $error = $rcon->error()) { print "HLTrig error: $error\n"; } } } } } print "HLTrig exited\n";