Skocz do zawartości

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Zdjęcie

Simple Server Status Script


  • Nie możesz napisać tematu
  • Zaloguj się, aby dodać odpowiedź
Brak odpowiedzi do tego tematu

#1 Adminek AMXX.PL

    Admin :)

  • Bot

Reputacja: 156
Profesjonalista

  • Postów:7 490
  • Lokalizacja:AMXX.PL
Offline

Napisano 10.10.2011 01:59

Hi,

I was searching for a server status script and i couldn't find it anywhere, so i thought i'd make one :3 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,
Attached Files Dołączona grafika Get Plugin or Get Source (server_status.sma - 1.4 KB)

Wyświetl pełny artykuł




Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych