Actions

Map Listing

From Rabbi Blog

Apparently I've been playing with Perl for since at least 2004. I found this thread recently.


Been in a funk this past week, so I wanted to try something different to get my mind elsewhere. Here it is, very hack and probably full of holes. Written and run under ActivePerl for Win, but should be immediately fit for Linux use. Works for me, your mileage may vary. Feel free to use, hack, rewrite or ignore at your leisure.

What does it do?

Logs into your cstrike server, assumes that your path from logging into the server is then to cd cstrike\maps to get to your bsp files. Then reads the contents, spits them out into a text file which you can then paste into a forum post. It contains the formatting and url links to a google search with mapname.zip+download for the viewer, like so:

P&B Map List

as_courthouse as_ghetto as_oilrig as_tundra bl_shotgun cs_52sevilla cs_52villabacho cs_747 cs_arcticbase cs_assault cs_assault_upc cs_assault2k cs_backalley cs_beirut cs_bikini cs_boxoffice2k cs_bro cs_bwinter cs_club42 cs_deagle5 cs_docks cs_duke2k cs_estate cs_havana cs_italy cs_militia cs_office cs_place4 cs_rio cs_shipjack cs_siege cs_siege_apc cs_snowflake cs_thunder cs_tire cs_trkstp cs_wildwest_assault cs_winter_assault cs_wpndepot de_52andalusia de_52casco de_52castello de_52costadelsol de_52lagranja de_52leon de_52mangana de_52puente de_52spania de_airstrip de_aztec de_aztec3 de_bahrain de_burscheid de_cbble de_centurion de_chateau de_clan1_mill de_clan2_fire de_daft de_dawn de_deadlock de_deep6 de_dust de_dust2 de_dustbunnies de_frankzoo de_frostbound de_gijoe de_gijoe2 de_heat de_herrenberg de_inferno de_keller de_keller_2k de_luxor de_maya de_motel_x de_museum de_night de_nuke de_osaka_beta1 de_outrage de_piranesi de_predator de_prodigy de_prodigy2k de_railroad de_rats de_ratsxl de_rock de_rotterdam de_scud_2k1 de_silentoperation de_simpsons de_storm de_storm2 de_survivor de_torn de_tot de_train de_vegas de_vertigo de_winterdust de_winternuke dm_sgarena es_trinity fy_pumpalley mindmaze scoutzknivez slap_pistols speedball2k1 treefort1

Total maps: 112

Original Code

#!/usr/bin/perl

use Net::FTP;

$host="ip";
$username="username";
$password="pass";
$servername="Your Server Here";

$remotedir1="/cstrike/maps";

my $ftp = Net::FTP->new("$host") or die "Can't connect: [email protected]\n";
$ftp->login($username, $password) or die "Couldn't login\n";
$ftp->cwd("$remotedir1")  or die "Couldn't change directory to $remotedir1\n";
$PWD=$ftp->pwd;

$out="$servername_mapslist.txt";

open OUT, ">$out" or die "Cannot open $out for write :$!";
print OUT "[b]$servername Map List[/b]\n\n";

print"$PWD\n";
$ftp->type('I');

$LOGDOESNOTEXIST=3;

my @LOGFiles = $ftp->ls(); 

$total=0;
$zip="zip";
$tempname="";
$URLend="[/url]";
$download="+download";

foreach $LOGfile (@LOGFiles) 
{
    $tempname=$LOGfile;
    chop $tempname;
    chop $tempname;
    chop $tempname;
    chop $tempname;
    if ($LOGfile=~"bsp")
      {
      if ($LOGfile!~"ztmp")
        {
        print OUT "[url=http://www.google.com/search?hl=en&ie=UTF-8&q=$tempname.$zip$download]$tempname$URLend";
        $counter++;
         $total++;
        }
      }
    if ($counter<6)
      {
      print OUT " ";
      }
    if ($counter==6)
      {
      print OUT "\n";
      $counter=0;
      }
    } 

print OUT "\n\nTotal maps: $total\n\n";

FPSBANANA EDITION

#!/usr/bin/perl

use Net::FTP;

$host="123.123.123.123";
$username="user";
$password="pass";
$servername="ServerName";

$remotedir1="/cssource/cstrike/maps";

my $ftp = Net::FTP->new("$host") or die "Can't connect: [email protected]\n";
$ftp->login($username, $password) or die "Couldn't login\n";
$ftp->cwd("$remotedir1") or die "Couldn't change directory to $remotedir1\n";
$PWD=$ftp->pwd;

$out="$servername_mapslist.txt";

open OUT, ">$out" or die "Cannot open $out for write :$!";
print OUT "[b]$servername Map List[/b]\n\n";
print OUT "[URL=http://www.rabbibob.com/index.php?title=Map_Listing]RabbiBob.com[/url]\n\n";

print"$PWD\n";
$ftp->type('I');

$LOGDOESNOTEXIST=3;

my @LOGFiles = $ftp->ls();

$total=0;
$zip="";
$tempname="";
$URLend="[/url]";
$download="+download+fpsbanana";
#$trash = pop(@LOGFiles);
#print "$trash removed from LOGFiles array as it is still in use if the server is running\n\n";

foreach $LOGfile (@LOGFiles)
{
         $tempname=$LOGfile;
         chop $tempname;
         chop $tempname;
         chop $tempname;
         chop $tempname;
         if ($LOGfile=~"bsp")
                   {
                   if ($LOGfile!~"ztmp")
                   {
                   print OUT "[url=http://www.google.com/search?hl=en&ie=UTF-8&q=$tempname$zip$download]$tempname$URLend";
                   $counter++;
                    $total++;
                   }
                   }
         if ($counter<6)
                   {
                   print OUT " ";
                   }
         if ($counter==6)
                   {
                   print OUT "\n";
                   $counter=0;
                   }
         }

print OUT "\n\nTotal maps: $total\n\n";

ManiMod Edition

#!/usr/bin/perl

use Net::FTP;

$host="<URL or IP>";
$username="<username>";
$password="<password>";
$servername="Pizza & Beer CS:Source";

$remotedir1="/<yourserver>/cstrike/maps";

my $ftp = Net::FTP->new("$host") or die "Can't connect: [email protected]\n";
$ftp->login($username, $password) or die "Couldn't login\n";
$ftp->cwd("$remotedir1") or die "Couldn't change directory to $remotedir1\n";
$PWD=$ftp->pwd;

$out="forummapslist.txt";
$mani="votemaplist.txt";
$mani2="maplist.txt";

open mani, ">$mani" or die "Cannot open $out for write :$!";
open mani2, ">$mani2" or die "Cannot open $out for write :$!";
open OUT, ">$out" or die "Cannot open $out for write :$!";
print OUT "[b]$servername [URL=http://www.rabbibob.com/index.php?title=Map_Listing]Map List[/url][/b]\n\n";
print"$PWD\n";
$ftp->type('I');

$LOGDOESNOTEXIST=3;

my @LOGFiles = $ftp->ls();

$total=0;
$zip="";
$tempname="";
$URLend="[/url]";
$download="+download+fpsbanana";
#$trash = pop(@LOGFiles);
#print "$trash removed from LOGFiles array as it is still in use if the server is running\n\n";

foreach $LOGfile (@LOGFiles)
{
         $tempname=$LOGfile;
         chop $tempname;
         chop $tempname;
         chop $tempname;
         chop $tempname;
         if ($LOGfile=~"bsp")
                   {
                   if ($LOGfile!~"ztmp")
                   {
                   print OUT "[url=http://www.google.com/search?hl=en&ie=UTF-8&q=$tempname$zip$download]$tempname$URLend";
                   print mani "$tempname\n";
                   print mani2 "$tempname\n";
                   $counter++;
                    $total++;
                   }
                   }
         if ($counter<6)
                   {
                   print OUT " ";
                   }
         if ($counter==6)
                   {
                   print OUT "\n";
                   $counter=0;
                   }
         }

print OUT "\n\nTotal maps: $total\n\n";