Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 19
  1. #1
    Member
    Join Date
    Sep 2003
    Posts
    199

    Default Add new game

    I am trying to add quake 2 to my CPGS. This is what I have done so far:

    1:/var/cpanel/cpgs/games made q2 directory.
    2: copied the q3 directory files being it is pretty close to q3 files.
    3: modified files in the q2 directory:
    default_server.cfg
    Code:
    seta sv_hostname "cPGS Quake 2"
    seta sv_maxclients 0
    seta g_motd "Quake2 Server"
    seta g_quadfactor 4
    seta g_gametype 0
    seta sv_punkbuster 1
    seta timelimit 15
    seta fraglimit 25
    seta g_weaponrespawn 3
    seta g_inactivity 3000
    seta g_forcerespawn 0
    seta rconpassword "RCONPass"
    set d1 "map q2dm1 ; set nextmap vstr d2"
    set d2 "map q2dm2 ; set nextmap vstr d3"
    set d3 "map q2dm3 ; set nextmap vstr d1"
    vstr d1

    q2.pm
    Code:
    package cPGS::q2;
    
    use strict;
    use IPC::Open2;
    use cPGS::Shared;
    
    our $VERSION="1.0";
    
    my $short = 'q2';
    my $long = 'Quake 2';
    
    sub new {
    	my $class = shift;
    	return bless {}, $class;
    }
    
    sub register_self {
            return(1,__PACKAGE__,$short,"$VERSION",$long);
    }
    
    sub showsimpleconfig {
    	my($self,$s,$srvargs_hashref,$home,$servdir,$user,$game,$srvn,$portdata,$ipdata,$ports_list,$ips_list) = @_;
    	my %srvargs = %{$srvargs_hashref};
    	my $map_list;
    
    	open(CONF,'<'."$home/.gameservers/$servdir\_$srvn/baseq2/server.cfg") or print $s "Could not open config file ($home/.gameservers/$servdir\_$srvn/baseq2/server.cfg) : $!\n";
    	while(<CONF>) {
    		s/(\r|\n|\")//g;
    		next if /^\/\//;
    	        if(/^(?:seta|set)\s+(.*?)\s+(.*)/) {
    			if(defined($srvargs{$1})) { next; }
    			$srvargs{$1}=$2;
    			$srvargs{$1} =~ s/(\s+)?\/\/.*$//;
    	        } else {
    	                next;
    	        }
    	}
    	close(CONF);
    	return(\%srvargs,$map_list,$ports_list,$ips_list);
    }
    
    sub configsave {
    	my($self,$s,$form_hashref,$home,$servdir,$user,$game,$srvn,$maxc) = @_;
    	my %form = %{$form_hashref};
    	my $chg_cnt = 0;
    	my $cfg_file = delete $form{'cfg_file'};
    
    	if( $cfg_file eq 'advconfig') {
    		my @realform = split(/\n/,$form{'conf'});
    		if(open(CONF,'>',"$home/.gameservers/$servdir\_$srvn/baseq2/server.cfg")) {
    			foreach my $line(@realform) {
    				$line =~ s/(\r|\n)//g;
    				if($line =~ m/seta\s+sv_maxclients\s+\"(\d+)\"/) {
    					my $usermax=$1;
    					if($usermax > $maxc) { $usermax = $maxc; }
    					print CONF "seta sv_maxclients $usermax\n";
    				} else {
    					print CONF "$line\n";
    				}
    			}
    			close(CONF);
    			return("Config file saved.");
    		} else {
    			return("Can not open config file: $!");
    		}
    	}
    	return("Unknown config, can not save.");
    }
    
    sub formsave {
    	my($self,$s,$form_hashref,$home,$servdir,$user,$game,$srvn,$maxc) = @_;
    	my %form = %{$form_hashref};
    	my $chg_cnt = 0;
    
    	open(CONF,'<',"$home/.gameservers/$servdir\_$srvn/.launchrc");
    	my @existconf=(<CONF>);
    	close(CONF);
    
    	open(CONFRE,'>',"$home/.gameservers/$servdir\_$srvn/.launchrc");
    
    	foreach my $line(@existconf) {
    		$line =~ s/(\n|\r)//g;
    		next if $line =~ /^\/\//;
    		if($line =~ /^(.*?)\s+(.*)/) {
    			my $var = $1;
    			my $val = $2;
    			if(defined($form{$var})) {
    				print CONFRE "$var $form{$var}\n";
    				if($val ne $form{$var}) { 
    					$chg_cnt++;
    					print $s "<tr><td>$var</td><td>$val</td><td>$form{$var}</td></tr>\n";
    				}
    			} else {
    				print CONFRE "$line\n";
    			}
    		}
    	}
    	close(CONFRE);
    
    	open(CONF,'<',"$home/.gameservers/$servdir\_$srvn/baseq2/server.cfg");
    	my @existconf=(<CONF>);
    	close(CONF);
    
    	open(CONFRED,'>',"$home/.gameservers/$servdir\_$srvn/baseq2/server.cfg");
    
    	foreach my $line(@existconf) {
    		$line =~ s/(\n|\r|\")//g;
    		if($line =~ /^\/\//) {
    			print CONFRED "$line\n";
    		} elsif($line =~ /^(set|seta)\s+(.*?)\s+(.*)/) {
    			my $set = $1;
    			my $var = $2;
    			my $val = $3;
    			if(defined($form{$var})) {
    				if($var eq 'sv_maxclients' && $form{$var} > $maxc) { $form{$var} = $maxc; }
    				print CONFRED "$set $var \"". $form{$var} ."\"\n";
    				if($val ne $form{$var}) { 
    					$chg_cnt++;
    					print $s "<tr><td>$var</td><td>$val</td><td>$form{$var}</td></tr>\n";
    				}
    			} else {
    				print CONFRED "$line\n";
    			}
    		} else {
    			print CONFRED "$line\n";
    		}
    	}
    	close(CONFRED);
    	return($chg_cnt);
    }
    
    sub showconfig {
    	my($self,$s,$query,$home,$servdir,$user,$game,$srvn) = @_;
    
    	if( $query eq 'servercfg' ) {
    		open(CONF,'<',"$home/.gameservers/$servdir\_$srvn/baseq2/server.cfg") or print $s "Could not open config file $home/.gameservers/$servdir\_$srvn/baseq2/server.cfg : $!\n";
    		my @confi=(<CONF>);
    		close(CONF);
    		foreach my $line(@confi) { 
    			print $s "OK: $line";
    		}
    	}
    }
    
    sub get_servdir {
    	return($short);
    }
    
    
    sub isinstalledql {
    	my($self,$s,$user,$game,$srvn,$home,$servdir) = @_;
    	if(-x "$home/.gameservers/$servdir\_$srvn/quake2") { return 0; }
    	else { return 1; }
    }
    
    
    # gather game specific data to send to startserver code in cpgsd
    sub loadlaunchrc {
    	my($self,$user,$game,$srvn,$home)= @_;
    	my(%launchrc);
    	my $gd = &get_servdir;
    
    	open(my $launch_fh,'<',"$home/.gameservers/$gd\_$srvn/.launchrc");
    	my @launch=(<$launch_fh>);
    	close($launch_fh);
    	foreach my $args(@launch) {
    		$args =~ s/(\r|\n)//g;
    		if($args =~ /^net_port(=|\s+)(.*)/i) { $launchrc{'port'}=$2; }
    		elsif($args =~ /^net_ip(=|\s+)(.*)/i) { $launchrc{'ip'}=$2; }
    		elsif($args =~ /^maxplayers(=|\s+)(.*)/i) { $launchrc{'maxplayers'}=$2; }
    	}
    	$launchrc{'extracli'} = ' +set sv_punkbuster 0';
    	open(my $serverset,'<',"$home/.gameservers/$gd\_$srvn/baseq2/server.cfg") or main::msglog("Could not open config file ($home/.gameservers/$gd\_$srvn/baseq2/server.cfg) : $!");
    	my @srvargs = (<$serverset>);
    	close($serverset);
    	foreach my $args(@srvargs) {
    		$args =~ s/\n//g;
    		$args =~ s/\"//g;
    		if($args =~ /^seta\s+sv_punkbuster\s+(.*)/i) { $launchrc{'extracli'} = ' +set sv_punkbuster 1'; }
    	}
    	$launchrc{'ld_library_path'} = "$home/.gameservers/$gd\_$srvn/libs\:/var/cpanel/gameserv_libs";
    	$launchrc{'pbname'} = 'q2a';
    	$launchrc{'fullname'} = $long;
    	$launchrc{'cpgs-divider'} = ' ';
    	return(\%launchrc);
    }
    
    
    sub set_default_configs {
    	my($self,$s,$user,$game,$srvn,$dir,$maxc,$lowport,$defip) = @_;
    	my $pcnt = my @ports = split(/\_/,$lowport);
    	if($pcnt > 1) {
    		$lowport = shift(@ports);
    	}
    	# create default config
    	if( open(DEF,'<','/var/cpanel/cpgs/games/q2/custom_default_server.cfg') || open(DEF,'<','/var/cpanel/cpgs/games/q2/default_server.cfg')) {
    		if(open(DEFC,'>',"$dir/baseq2/server.cfg")) {
    			while(<DEF>) {
    				if(m/^set\s+sv_maxclients/) {
    					print DEFC "set sv_maxclients $maxc\n";
    				} else {
    					print DEFC;
    				}
    			}
    			close(DEFC);
    		} else {
    			main::msglog("Couldn't write to $dir/baseq2/server.cfg : $!");
    			return("Could not open config file $dir/baseq2/server.cfg : $!");
    		}
    		close(DEF);
    	} else {
    		main::msglog("Couldn't open /var/cpanel/cpgs/games/q2/default_server.cfg : $!");
    		return("Could not open default config template: $!");
    	}
    
    	if(open(LAUNCHRC,'>',"$dir/.launchrc")) {
    		print LAUNCHRC "net_port $lowport\n";
    		print LAUNCHRC "net_ip $defip\n";
    		print LAUNCHRC "maxplayers $maxc\n";
    		close(LAUNCHRC);
    	}
    
    	return(0);
    }
    
    sub getserverip {
    	my($self,$s,$user,$game,$srvn,$home,$servdir) = @_;
    
    	open(ARGSF,"<$home/.gameservers/q2\_$srvn/.launchrc") or print $s "Could not open config file ($home/.gameservers/q2\_$srvn/.launchrc) : $! <br>\n";
    	my @srvargs = (<ARGSF>);
    	close(ARGSF);
    	foreach my $args(@srvargs) {
    		$args =~ s/(\r|\n)//g;
    		if($args =~ /^net_ip\s+(.*)/i) { return($1); }
    	}
    	return(1);
    }
    
    sub getStats {
    	my($self,$user,$game,$srvn,$pubip,$verbose,@targets) = @_;
    	my($sip,$players,$map,$gtype,$sname,@reply,$target,%seen,$matched1,%retteam,$pname,$time,$score);
    	my($pkg,$calling_file,$calling_line)=caller;
    
    
    	my($sip,$players,$map,$gtype,$sname,@reply,$target,%seen,$matched1,%retteam,$pname,$time,$score);
    	foreach $target(@targets) {
    		if($target =~ /(\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3})\:(\d+)\s+\((.*)\)/) {
    			my $ip=$1;
    			my $port=$2;
    			if($ip eq '0.0.0.0') { $ip=$pubip; }
    			$target = "$ip\:$port";
    		}
    		if($seen{$target} eq $target) { next; }
    		$seen{$target}=$target;
    
    		@reply="";
    
    		if($verbose == 0) {
    			my @arg = ("-q2s",$target,"-nh","-timeout",$cPGS::Shared::to);
    			my $pid = open2(\*READ,\*WRITE,$cPGS::Shared::qstatpath,@arg); close(WRITE); while(<READ>) { push(@reply,$_); } close(READ);
    			foreach my $ln(@reply) {
    				if($ln =~ m/^(\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}.*)\s+(\d+\/\d+)\s+\d+\/\d+\s+([\w\s]+)\s+(\d+)\s+\/\s+\d+\s+(.*)/) {
    					$sip=$1;
    					$players=$2;
    					$map=$3;
    					$gtype=$4;
    					$sname=$5;
    					$matched1=1;
    				}
    			}
    		} else {
    			my @arg = ("-q2s",$target,"-nh","-P","-timeout",$cPGS::Shared::to);
    			my $pid = open2(\*READ,\*WRITE,$cPGS::Shared::qstatpath,@arg); close(WRITE); while(<READ>) { push(@reply,$_); } close(READ);
    			foreach my $ln(@reply) {
    				if($ln =~ m/^(\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}.*)\s+(\d+\/\d+)\s+\d+\/\d+\s+([\w\s]+)\s+(\d+)\s+\/\s+\d+\s+(.*)/) {
    					$sip=$1;
    					$players=$2;
    					$map=$3;
    					$gtype=$4;
    					$sname=$5;
    					$matched1=1;
    				}
    				elsif($ln =~ /^\s+(\d+)\s+frags\s+(\d+.*ms)\s+(.+)/) {
    					$score=$1;
    					$time=$2;
    					$pname=$3;
    					$pname = $pkg->filter($pname);
    					$retteam{$pname}{'score'}=$score;
    					$retteam{$pname}{'time'}=$time;
    					$retteam{$pname}{'pname'}=$pname;
    				}
    			}
    		}
    		if($matched1 == 1) { 
    			last; 
    		}
    	}
    	return($matched1,$sip,$players,$map,$gtype,$sname,undef,%retteam);
    }
    
    sub showPlayerStats {
    	my($self,$game,$retteam)=@_;
    	print "<table border=0 cellpadding=0 cellspacing=0 width=100\%><tr><th>Player Name</th><th>Score</th><th>Ping</th></tr>";
    	foreach my $key(keys %{$retteam}) { print "<tr><td>$$retteam{$key}{'pname'}</td><td>$$retteam{$key}{'score'}</td><td>$$retteam{$key}{'time'}</td></tr>\n"; }
    	print "</div></table></div>\n";
    }
    
    1;

  2. #2
    Member
    Join Date
    Sep 2003
    Posts
    199

    Default

    server_info
    Code:
    q2|q2.jpg|Quake 2|Dashboard.html|Ctl.html|live_Install.html|450M|2 minutes
    simple_config
    Code:
    Listen IP|||select|||net_ip|||CPGS-IPS
    Listen Port|||select|||net_port|||CPGS-PORTS
    Max Players|||text|||sv_maxclients|||4|||(Up to CPGS-MAXC)
    Server Name|||text|||sv_hostname|||40|||
    Message of the Day|||text|||g_motd|||40|||
    RCON Password|||text|||rconpassword|||40|||
    Quad Factor|||text|||g_quadfactor|||4|||
    Time Limit|||text|||timelimit|||4|||
    Frag Limit|||text|||fraglimit|||4|||
    Weapon Respawn|||text|||g_weaponrespawn|||4|||
    Inactivity Timeout|||text|||g_inactivity|||4|||
    Punkbuster Enabled|||selectyesno|||sv_punkbuster|||
    Force Respawn|||selectyesno|||g_forcerespawn|||
    startup_options
    Code:
    game_exec_bin|||$home/.gameservers/q2_$srvn/quake2|||0
    +set ttycon|||0|||1
    +set vm_game|||2|||2
    +set net_ip|||$ip|||3
    +set net_port|||$port|||4
    +set fs_homepath|||$home/.gameservers/q2_$srvn/|||5
    +set sv_maxclients|||$maxplayers|||6 
    +exec|||server.cfg|||7
    4: Downloaded q2 linux files wget ftp://ftp.idsoftware.com/idstuff/qua...inux2.0.tar.gz then renamed to q2.tar.gz
    5:tar xvfz q2.tar.gz
    6:cd q2
    7: tar czvf ../q2.cpgs ./
    8: copied the q2.cpgs to /home/gameservers/
    9:/var/cpanel/cpgs/cpgs_pkg q2.cpgs -p "q2" "3.2" "Quake 2"

    Everything shows up I can add quake 2 to a user and go through the setup wizard. But when I reach the installing game files it just hangs there. Doesn't create /home/user/.gameservers/q2_0 folder. Will not extract files. See it there though and shows how many files it is and block size. But does nothing.


    Some guidance to get this working work be great.

  3. #3
    Member
    Join Date
    Sep 2003
    Posts
    199

    Default

    got it working....

  4. #4
    cPanel Staff
    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    1,881

    Default

    Great, I'm glad you were able to build your own package for it. If you can remember, what was the problem you figured out at the end ? If you can think of things to make the process easier, let me know. Obviously by making cPGS modular I'm hoping more folks will be able to add support for their desired games rather than waiting around on slow (overworked!) developers to handle it all. Anything I can do to help make that process easier in the long run saves everyone time and effort.
    Need to put in a support ticket for cPGS ? Click on the url below and follow the bottom most link "Submit a Support Request without Logging In"
    https://tickets.cpanel.net/submit/index.cgi?support=1

  5. #5
    Member
    Join Date
    Sep 2003
    Posts
    199

    Default

    I will post the newer modified files when done. Not perfect but some perfection to clean up would be needed. I could use some guidance on how to add the new special startup parameters to it. Thanks for everything Darren.

  6. #6
    Member
    Join Date
    Sep 2003
    Posts
    199

    Default

    Have the parameters straightened out....

  7. #7
    Member
    Join Date
    Sep 2003
    Posts
    199

    Default

    How do I restart the cpgs without rebooted the box for meta information to go through.

  8. #8
    cPanel Staff
    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    1,881

    Default

    Just restart cpgsd, `/var/cpanel/cpgsd.pl` as root via ssh will reload all the games, meta data and all.
    Need to put in a support ticket for cPGS ? Click on the url below and follow the bottom most link "Submit a Support Request without Logging In"
    https://tickets.cpanel.net/submit/index.cgi?support=1

  9. #9
    Member
    Join Date
    Sep 2003
    Posts
    199

    Default

    I am in process of adding 2 games to CPGS. Would like some assistance completing these 2 projects.
    Games:
    Quake 2
    Nexuiz 2.5.2

    http://www.rabidservers.com/downloads/nx.zip
    http://www.rabidservers.com/downloads/q2.zip

    Readme.txt included
    Missed the other things you need to do in the readme though.

    /var/cpanel/cpgs/cpgs_pkg q2.cpgs -p "q2" "3.2" "Quake 2"
    var/cpanel/cpgs/cpgs_pkg nx.cpgs -p "nx" "2.5.2" "Nexuiz"
    /var/cpanel/cpgsd.pl

    Most of the project is working except the config file information not working properly.
    Last edited by Lestat; 01-21-2010 at 02:30 PM.

  10. #10
    cPanel Staff
    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    1,881

    Default

    Here are some initially completed versions, do you want these added to cPGS or just left as is ?

    http://cpgs.cpanel.net/nx.tgz
    http://cpgs.cpanel.net/q2.tgz

    The Quake 2 package seems to be set to use a "tourney" mod, however if you want cPGS to adopt them I can probably change it to work with other mods as well. Let me know if you have problems with it. You'll probably need to "reset configs" to defaults on any existing install before it works 100%
    Need to put in a support ticket for cPGS ? Click on the url below and follow the bottom most link "Submit a Support Request without Logging In"
    https://tickets.cpanel.net/submit/index.cgi?support=1

  11. #11
    Member
    Join Date
    Sep 2003
    Posts
    199

    Default

    Yeah my fault on the tourney mod. I have the server parameters already working that you added to 7.2. They work great. You can remove the mod thing.

    Yeah problem I am having is the configuration saving and editing for both packages. Also have to fix some of the q2 information as it is from the q3.

    Darren would be great to see these added to the CPGS. People sometimes like to go back to classics.

    Nexuiz makes a 64 bit server version as well.

  12. #12
    Member
    Join Date
    Sep 2003
    Posts
    199

    Default

    All in all Darren is definitly getting easier to add custom games to CPGS. Two thumbs up for you all !

  13. #13
    cPanel Staff
    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    1,881

    Default

    Thanks Lestat, I'll work on q2 and nx a bit more to make them "everyone-friendly" once I'm done with this ts3 stuff so they can be added to the list of supported games. The difference between adding a new game that shares or uses a similar engine of an already supported game (q2/nx) to a totally new system (ts3) is huge, and unfortunately there's nothing I can do about that as it involves figuring out the file placement, syntax of config files, tricks and nuances (and bugs) with getting it running as expected, etc. I'm glad you were able to get so far on your own, and thanks for sharing for others to use. And FYI, it doesn't look like I'll be able to get 0.7.3 out by today like I'd hoped, will shoot for next week.
    Need to put in a support ticket for cPGS ? Click on the url below and follow the bottom most link "Submit a Support Request without Logging In"
    https://tickets.cpanel.net/submit/index.cgi?support=1

  14. #14
    Member
    Join Date
    Sep 2003
    Posts
    199

    Default

    NO rush on my part.... I got the servers up and running for now. Maybe I will find some other games to add ).
    Thanks for CPGS

  15. #15
    Member HOSSAM's Avatar
    Join Date
    Jun 2007
    Location
    Egypt
    Posts
    52

    Default

    Thanks Lestat, I grateful of your effort , I was love Quake 2 so much and this is good thing Quake 2 added to cPGS.

    I will share your effort with this game covers.. lol when Darren add it for cPGS

    Quake 2
    http://i49.tinypic.com/2vtxykg.jpg

    Nexuiz
    http://i48.tinypic.com/2hebhnm.jpg

    Go ahead guys.

Similar Threads & Tags
Similar threads

  1. Replies: 2
    Last Post: 04-01-2010, 05:48 PM
  2. Installing The Game Server Add-On
    By Weber in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 10-21-2006, 10:36 AM
  3. Can i add COD2 to game list?
    By samhostinguk in forum cPanel Developers
    Replies: 0
    Last Post: 09-26-2006, 06:32 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube