Raised This Month: $51 Target: $400
 12% 

Script to start HLTV


Post New Thread Reply   
 
Thread Tools Display Modes
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-22-2012 , 21:11   Re: Script to start HLTV
Reply With Quote #11

Quote:
Originally Posted by 8088 View Post
Quote:
Originally Posted by ghostofmybrain View Post
It's not possible with a bash script?
It is, but I can't write it for you Still, I think using bash will make it harder to maintain. Considering the fact that you want to query several HLDS servers and control multiple HLTVs, I would prefer to administer it from a webinterface.
You can run the a PHP script exactly as you would a bash script (provided that you have PHP installed on the system, which is easy to do). It's called the Command Line Interface (IIRC). It's basically the same as a web based PHP script but without the GUI output. This being said, you don't get the "administration from a web interface" that you mentioned but this way you have the power and knowledge of PHP at your disposal.
__________________
fysiks is offline
ghostofmybrain
Veteran Member
Join Date: Mar 2010
Old 03-22-2012 , 21:32   Re: Script to start HLTV
Reply With Quote #12

Yeah, I have php installed, which I forgot about. A php script would be perfectly fine.
__________________
Boycott ESEA
My servers
ghostofmybrain is offline
8088
Veteran Member
Join Date: Jan 2008
Old 03-22-2012 , 22:55   Re: Script to start HLTV
Reply With Quote #13

Quote:
Originally Posted by fysiks View Post
You can run the a PHP script exactly as you would a bash script (provided that you have PHP installed on the system, which is easy to do). It's called the Command Line Interface (IIRC). It's basically the same as a web based PHP script but without the GUI output. This being said, you don't get the "administration from a web interface" that you mentioned but this way you have the power and knowledge of PHP at your disposal.
That's exactly what I had in mind. The scheduled script then retrieves the settings (which HLTV should connect to which HLDS on which conditions) from a database, which can be managed from a web interface.
__________________
steamID converter with OpenSearch browser plugin
8088 is offline
sylar02
Member
Join Date: Jun 2011
Old 03-23-2012 , 03:04   Re: Script to start HLTV
Reply With Quote #14

hey 8088, is it possible to do it like this
A - create a php script
1) get rcon_hl_net.inc for php
2) call serverinfo method and send that rcon to server to get number of players.
3) have an if statement where if # of players greater then 1, then send another rcon to exec record.cfg
record.cfg will have ip address of hltv; rcon password and record command.
4) and if less then 1, then send rcon to exec stoprecording.cfg which send command "stop recording"

B - create a bash script
1)start your hltv session with screen (hopefully he is running linux)
2) install some qstats or phgstats library and query his gs.
3) have a if statement and if more then 1, then send command to screen with screen -S hltv -X stuff 'record' or 'stop recording'

only problem is that ghost will have to do deploy an instance of this script for every server individually.
and also i dont know if hltv would overwrite existing demo or create a new hltv demo with timestam in suffix.


if this is one way to go, let me know, i can write some sloppy php to make it work.
sylar02 is offline
8088
Veteran Member
Join Date: Jan 2008
Old 03-23-2012 , 09:22   Re: Script to start HLTV
Reply With Quote #15

From what I understood, ghostofmybrain has his HLTV servers running and connected to HLDS non-stop, so I figured stopping and starting them should be left out of this script's scope. This will make it easier to write (no ssh connections are required in case of remote control), install and administer, and it allows for other control panels to be used for stop/start/restart purposes.

I was thinking of doing it like this, in pseudo code:
Code:
mysql> show columns from hlds;
+-----------------+------------------+------+-----+---------+----------------+
| Field           | Type             | Null | Key | Default | Extra          |
+-----------------+------------------+------+-----+---------+----------------+
| id              | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| name            | varchar(256)     | NO   |     | NULL    |                |
| ip              | int(10) unsigned | NO   |     | NULL    |                |
| port            | int(5) unsigned  | NO   |     | NULL    |                |
| min_playercount | int(2)           | NO   |     | 1       |                |
| recording       | int(1) unsigned  | NO   |     | 0       |                |
| monitor         | int(1) unsigned  | NO   |     | 1       |                |
+-----------------+------------------+------+-----+---------+----------------+
7 rows in set (0.00 sec)

mysql> show columns from hltv;
+---------------+------------------+------+-----+---------+----------------+
| Field         | Type             | Null | Key | Default | Extra          |
+---------------+------------------+------+-----+---------+----------------+
| id            | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| name          | varchar(256)     | NO   |     | NULL    |                |
| ip            | int(10) unsigned | NO   |     | NULL    |                |
| port          | int(5) unsigned  | NO   |     | NULL    |                |
| rcon_password | varchar(25)      | YES  |     | NULL    |                |
| command       | varchar(100)     | YES  |     | NULL    |                |
| hlds_id       | int(10) unsigned | YES  | UNI | NULL    |                |
+---------------+------------------+------+-----+---------+----------------+
7 rows in set (0.00 sec)
PHP Code:
<?php
foreach(HLDS) {
    
    
query HLDS// with https://github.com/xPaw/PHP-Source-Query-Class

    
if(playercount >= min_playercount && recording == false && monitor == true) {
        
send_rcon(HLTV ip:portstart_recording);
        
set_status(HLDSrecording true);
    }
    
    elseif(
playercount min_playercount && recording == true && monitor == true) {
        
send_rcon(HLTV ip:portstop_recording);
        
set_status(HLDSrecording false);
    }
    
}
?>
Then again, I've never used HLTV, so if this approach is wrong I'd be glad to hear about it.
Quote:
if this is one way to go, let me know, i can write some sloppy php to make it work.
I think ghostofmybrain should be the judge of that ;) What may work for me and/or you may or may not work for others.
__________________
steamID converter with OpenSearch browser plugin
8088 is offline
ghostofmybrain
Veteran Member
Join Date: Mar 2010
Old 03-23-2012 , 14:37   Re: Script to start HLTV
Reply With Quote #16

Quote:
Originally Posted by 8088
From what I understood, ghostofmybrain has his HLTV servers running and connected to HLDS non-stop
That is correct.

Quote:
Originally Posted by sylar02
hey 8088, is it possible to do it like this
A - create a php script
1) get rcon_hl_net.inc for php
2) call serverinfo method and send that rcon to server to get number of players.
3) have an if statement where if # of players greater then 1, then send another rcon to exec record.cfg
record.cfg will have ip address of hltv; rcon password and record command.
4) and if less then 1, then send rcon to exec stoprecording.cfg which send command "stop recording"
This looks about what I am wanting it to do. But I think it would have to be less than 2, or else it might be counting the HLTV as a connected person and thus constantly record. I could just have one script per hltv, with the various .cfg files in their individual directories.
__________________
Boycott ESEA
My servers
ghostofmybrain is offline
sylar02
Member
Join Date: Jun 2011
Old 03-23-2012 , 14:39   Re: Script to start HLTV
Reply With Quote #17

yea, your code is actually better and if he has mysql and more manageble, then its way to go.

i was trying to avoid using mysql since he doesnt have it and if he does, i would still opt to not rely on mysql db and keep connecting and closing connections.

every 30 seconds.

ghost, u mind telling me how u are deploying your hltv, and under what os.
sylar02 is offline
ghostofmybrain
Veteran Member
Join Date: Mar 2010
Old 03-23-2012 , 15:21   Re: Script to start HLTV
Reply With Quote #18

I've installed LAMP on this same machine, which runs CentOS 5.6, stock kernel.

On the machine, I have a seperate directory for each HLTV. It gets booted with a command like this:

Code:
./hltv +exec hltv_pub.cfg -port 27015
Within that hltv.cfg file, there will be things like this:

Code:
// set HLTV proxy name as shown in score board
name "Absurd Minds' HLTV"

// set HLTV name, how it should appear in game server browsers
hostname "Absurd Minds' HLTV"

//HLTV player slots - the number of people who can connect to HLTV
maxclients "20"

// set offline info text clients will see as reject reason if HLTV isn't broadcasting yet
offlinetext "Sorry, game is delayed. Please try again later."

// Delay between actual server play and HLTV broadcast
delay 0.0

// allow 3.5 KByte/sec as client rate. This is good a value
// for internet broadcasts. On LAN you may set this value to 10000
maxrate 3500

// log HLTV console in proxy.log
// logfile 1

// local chatting for HLTV spectators enabled
chatmode 1

// if the server the HLTV is connecting to has a password, enter it here
serverpassword   ""

// proxy's adim password for rcon, commentator etc.
adminpassword   "xxxxxx"

// show message for 5 seconds each 60 seconds in center of X axis (-1) and
// above help text bar (0.85). Color given as hexadecimal RGBA .
loopcmd 1 60 localmsg "You're watching AM's pug. Visit www.absurdminds.net" 5 -1 0.85 FFA000FF

// hltv.tga will be shown instead of the default HLTV logo in spectator GUI
// bannerfile "hltv.tga"

// these commands will be executed on connecting spectator client and may be used
// to adjust settings for HLTV (for example voice parameters)
//signoncommands "voice_scale 2; voice_overdrive 16; volume 0.5; echo Voice adjusted for HLTV"

echo hltv.cfg loaded.

//Game Server Connection Info - enter the game server ip and port in the following
// format by adding a new line below the example shown. Then start your HLTV server
connect 70.34.195.6:27018
You'll notice the two most important lines there: connect <ip address>, and serverpassword "<hlds server's password>"
__________________
Boycott ESEA
My servers
ghostofmybrain is offline
ghostofmybrain
Veteran Member
Join Date: Mar 2010
Old 03-25-2012 , 11:10   Re: Script to start HLTV
Reply With Quote #19

Quote:
Originally Posted by 8088 View Post
This can be done with PHP and a cronjob. At the moment I don't have much time, but if you can't find another script or solution I'll try to whip up something by the end of the week/beginning of next week.
I haven't found any solution better than a php script, so if you get any free time this would be amazing.
__________________
Boycott ESEA
My servers
ghostofmybrain is offline
8088
Veteran Member
Join Date: Jan 2008
Old 03-25-2012 , 19:19   Re: Script to start HLTV
Reply With Quote #20

Alright. I've made a start, but other things keep coming up, so I won't make any promises other than that I'll try to finish it asap.
__________________
steamID converter with OpenSearch browser plugin
8088 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:08.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode