PDA

View Full Version : [SOLVED]Get server status with plugin?


mcpan313
02-20-2012, 00:12
] status
hostname: Test
version : 2.1.0.0 4777 secure (unknown)
udp/ip : 111.15.108.180:27015 [ public same ]
os : Windows Dedicated
map : c1m4_atrium
players : 0 humans, 0 bots (10 max) (not hibernating) (unreserved)

# userid name uniqueid connected ping loss state rate adr
#end


I want get the server <version> <udp/ip> and <players> info,
is there have same netprop about server resource?


solved:
use ServerCommandEx (http://docs.sourcemod.net/api/index.php?fastload=show&id=981&) get and process this reply string
not work on tf2, l4d2 and later.

*edit:
use Socket (https://forums.alliedmods.net/showthread.php?t=67640) Get A2S_INFO (https://developer.valvesoftware.com/wiki/Server_Queries#A2S_INFO)

berni
02-21-2012, 08:29
Storing server info in an entity wouldn't make much sense.

You can use smlib (http://www.sourcemodplugins.org/pages/smlib/)'s function for reading the server IP and port:

https://github.com/bcserv/smlib/blob/master/scripting/include/smlib/server.inc

For getting client count: GetClientCount().
You have to count the humans and bot's yourself, or use smlib's Client_GetCount()

For the version you can read the file steam.inf in the game folder (there is an other thread about this)

mcpan313
04-13-2012, 08:06
Storing server info in an entity wouldn't make much sense.

You can use smlib (http://www.sourcemodplugins.org/pages/smlib/)'s function for reading the server IP and port:

https://github.com/bcserv/smlib/blob/master/scripting/include/smlib/server.inc

For getting client count: GetClientCount().
You have to count the humans and bot's yourself, or use smlib's Client_GetCount()

For the version you can read the file steam.inf in the game folder (there is an other thread about this)

thx :3, I found a better way.

Impact123
04-13-2012, 13:06
thx :3, I found a better way.
Uhm, then why u don't post it?

Yours sincerely
Impact

11530
04-13-2012, 13:12
Uhm, then why u don't post it?

He posted the solution at the bottom of the OP.

Impact123
04-13-2012, 13:16
He posted the solution at the bottom of the OP.
Thanks for the hint, i'm indeed a little bit blind sometimes.

Yours sincerely
Impact

berni
04-13-2012, 13:19
Calling ServerCommand or ServerCommandEx is not really the greatest way of doing it.

The output of the status command can change in updates, or plugins can modify it. Also aliasing it to something else would break it, be warned.