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:port, start_recording);
set_status(HLDS, recording = true);
}
elseif(playercount < min_playercount && recording == true && monitor == true) {
send_rcon(HLTV ip:port, stop_recording);
set_status(HLDS, recording = 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.
__________________