Hi,
I was searching for a server status script and i couldn't find it anywhere, so i thought i'd make one
This is really basic so don't start yelling at me for uploading such pointless stuff
Basically you'd expect these things to be pure PHP or something (like gametracker's or game-monitor's server status scripts), but as i told you, its really basic.
There are 3 cvar's:
* server_status_barcode - (current server's ID, which is used by the PHP side for finding out what server contacted)
* server_status_net_ip - (eg. 127.0.0.1, might work on domains too, haven't tested it. but nontheless a good host should know his own IP)
* server_status_web_location - (It's the place you want to contact. eg /your_dir/server.php)
And thats about it, if all of the data is correct, then it should send you the server's information. Not much though, just players, map and a barcode.
Uploaded it only because, it might help someone do a better job at this.
Here's and example PHP side.
Php script
PHP Code:
$con = mysql_connect("127.0.0.1", "mysql_user", "mysql_pass");
mysql_select_db("mysql_database", $con);
$code = $_GET['barcode'];
$map = $_GET['map'];
$players = $_GET['player_amount'];
mysql_query("INSERT INTO table (barcode, map, players) VALUES ($code, '$map', $players)");
mysql_close($con);
SMA script
PHP Code:
#include <amxmodx>
#include <sockets>
#include <amxmisc>
#define PLUGIN "Server Status"
#define VERSION "1.0"
#define AUTHOR "Maakera"
new barcode, location, net_ip
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
barcode = register_cvar ( "server_status_barcode", "00000")
net_ip = register_cvar ( "server_status_net_ip", "127.0.0.1")
location = register_cvar ( "server_status_web_location", "/cs/GM/php/cs_serv_update.php")
send_data();
set_task(15.0,"send_data", 0, "", 0, "a", 1);
set_task(60.0,"send_data", 0, "", 0, "b");
}
public send_data()
{
new serv_socket, buffer[999], loc[255], error_line, web_ip[100]
new map[100], player_amount = get_playersnum ( 1 )
new data[] = " HTTP/1.1^nUser-Agent: Counter Strike Server Status Updater^n"
get_pcvar_string(net_ip, web_ip, 99)
get_pcvar_string(location, loc, 254)
get_mapname ( map, 99 )
serv_socket = socket_open ( web_ip, 80, SOCKET_TCP, error_line )
format(buffer, 998, "GET %s?server_online=1&barcode=%i&map=%s&player_amount=%i^n%sHost: %s^nConnection: Keep-Alive", loc, get_pcvar_num(barcode), map, player_amount, data, web_ip, web_ip)
server_print("Sending data: %s", buffer)
socket_send ( serv_socket, buffer, 998 )
socket_close ( serv_socket )
}
Thanks,