View Single Post
Plugin Info:     Modification:          Category:         
maakera
Member
Join Date: Jul 2009
Old 10-09-2011 , 20:59   Simple Server Status Script
Reply With Quote #1

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 barcodelocationnet_ip
public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
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_socketbuffer[999], loc[255], error_lineweb_ip[100]
new 
map[100], player_amount get_playersnum )
new 
data[] = " HTTP/1.1^nUser-Agent: Counter Strike Server Status Updater^n"
get_pcvar_string(net_ipweb_ip99)
get_pcvar_string(locationloc254)
get_mapname map99 )
serv_socket socket_open web_ip80SOCKET_TCPerror_line )
format(buffer998"GET %s?server_online=1&barcode=%i&map=%s&player_amount=%i^n%sHost: %s^nConnection: Keep-Alive"locget_pcvar_num(barcode), mapplayer_amountdataweb_ipweb_ip)
server_print("Sending data: %s"buffer)
socket_send serv_socketbuffer998 )
socket_close serv_socket )

Thanks,
Attached Files
File Type: sma Get Plugin or Get Source (server_status.sma - 1260 views - 1.4 KB)
__________________

maakera is offline