Jump to content

TCAdmin to Qstat


ECF

Recommended Posts

Sorry Gary for deleting your thread. I was trying to delete the first post that had the bad info in it, and accidentally deleted the thread.

 

 

Thank goodness for browser caches :) Here is the code you just posted.

 

#!/usr/bin/perl

# This should be enhanced enough to open $file, and clean it up (remove invalid entries)
# You can't use character subs in the @row[0] because it only matches that row
# Need to write it, then clean it up, ie: egrep -v ^TC5783714187363 
# Written by: "Monk" (gary@velocity-servers.net)

use DBI;

my $file = "servers.txt";

# Delete $file is it exists
if (-e $file) { unlink($file); }

# Connect to our database.
$dbh = DBI->connect('dbi:mysql:username:1.2.3.4','username','password')
       or die "Couldn't connect to database: $DBI::errstr\n";

$sql = "SELECT GAME_ID,SERVER_IP,SERVER_PORT from tc_services ORDER by GAME_ID";

$sth = $dbh->prepare($sql)
       or die "Couldn't prepare query '$sql': $DBI::errstr\n";

$sth->execute || 
          die "Could not execute SQL statement ... maybe invalid?";

#print "Fetching data\n";

# Convert output to qstat type. You have to be sure you have the proper 
# gametypes in qstat.cfg otherwise you may not be able to use these.
# XXX: We should have a better way of doing
while (@row=$sth->fetchrow_array)
{
       @row[0] =~ s/\bTC4875210400327\b/HLSHB/i;
       @row[0] =~ s/\bTC8644464364564\b/BF2/i;
       @row[0] =~ s/\bTC6878144563415\b/CODUO/i; 
       @row[0] =~ s/\bTC2364114757686\b/DODS/i;
       @row[0] =~ s/\bTC6040600434168\b/COD2S/i;
       @row[0] =~ s/\bTC5502614372407\b/Q4S/i;
       @row[0] =~ s/\bTC3055405514836\b/HLSP/i;

       @row[0] =~ s/\b1\b/RWS/i; 
       @row[0] =~ s/\b2\b/COD/i;
       @row[0] =~ s/\b3\b/CODUO/i;
       @row[0] =~ s/\b4\b/MAQS/i;
       @row[0] =~ s/\b6\b/A2S/i;
       @row[0] =~ s/\b7\b/HLCZ/i;
       @row[0] =~ s/\b8\b/HLNS/i;
       @row[0] =~ s/\b9\b/HLDOD/i;
       @row[0] =~ s/\b10\b/CSS/i;
       @row[0] =~ s/\b12\b/SOF2S/i;
       @row[0] =~ s/\b16\b/JK3S/i;
       @row[0] =~ s/\b17\b/JK3S/i;
       @row[0] =~ s/\b18\b/Q3S/i;
       @row[0] =~ s/\b19\b/UT2004S/i;
       @row[0] =~ s/\b26\b/A2S/i;
       @row[0] =~ s/\b27\b/HLSAD/i;
       @row[0] =~ s/\b28\b/HLSAMX/i;
       @row[0] =~ s/\b29\b/HLTV/i;
       #print "Writing @row[0] @row[1]:@row[2] to $file\n";
       #print "@row[0] @row[1]:@row[2]\n";
       open(DAT,">>$file") || die("Cannot Open File");

}

# Close file handler.
close(DAT);

# Disconnect from database.
$dbh->disconnect();

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Terms of Use