Hi!
Any idea for get query server infos into php website?
So example:
Server Name
Online/Offline
IP, Port
Currently Players/Max Players
Map Admin/mod comment
There's even "Server" in the title. Clearly a case for the "Server" section... /DC yes.. but built in to my website...so
when users view my site
the server info be on left side Ah yes, then that's up to your design and implementation. Where is your website? Maybe it's not so hard to do. i currently build it
wait some minute and i give address
[edit]
but the game-server is not on same network..
possible? Possible, if you look at the script, it handles remote packet response, not parse responses. SD User Offline
@ Apache uwu:
Your script does not show correct amount of players when gamemode is Standard. Here's the way to fix it. Go to step 8, copy everything and paste it before step 7. Because problem occurs in step 7 and we will need variables from step 8. Finally, step 8 should go right after step 6 but before step 7. Now let's detect if gamemode is Standard, replace everything in step 8 with this.
1
2
3
4
5
6
7
8
9
if (strlen($v_temp)-$namelen*2-strlen($svmap)*2-4==8)
{
	$gamemode="Standard";
}
else
{
	$gamemodes=array("Deathmatch","Team Deathmatch","Construction","Zombies!");
	$gamemode=$gamemodes[intval(substr($v_temp,-4,2))-1];
}
Now go to step 7 where it gets current players. Let's tell the script to detect current gamemode and parse right values.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
if (strlen($v_temp)-strlen($namelen)*2-strlen($svmap)*2-4==8)
{
	$players=hexdec(substr($v_temp,-6,2));
	$maxplayers=hexdec(substr($v_temp,-4,2));
	$bots=hexdec(substr($v_temp,-2,2));
}
else
{
	if ($gamemode=="Standard")
	{
		$players=hexdec(substr($v_temp,-6,2));
		$maxplayers=hexdec(substr($v_temp,-4,2));
	}
	else
	{
		$players=hexdec(substr($v_temp,-8,2));
		$maxplayers=hexdec(substr($v_temp,-6,2));
	}
	$bots=hexdec(substr($v_temp,-2,2));
}
Now it will show correct amount of players even if gamemode is Standard. I'd also recommend you to update your file to avoid further confusions. edited 2×, last 20.06.12 05:22:31 pm
Ah yeah, forgot to update to my files, I'll do it now. Use some basic php and css positioning DC Admin Offline
@ Ghost-Rider: You can still use the PHP script provided by Apache uwu. It doesn't matter if the webserver is on another machine/network than the game server. PHP allows you to use UDP sockets to contact any server you want. But note that this can have a bad impact on the performance of your webserver. Many webhosters deactivate PHP sockets for that reason.
There are also other solutions. For example (in case your game server has also a webserver running): Create a Lua script on the game server that updates a file with all current stats and writes it to the webserver www/htdocs folder. You can now show this file at every website by using an IFrame. Or json or jsonp inline loading via php and loaded by ajax. i found a php script named gameQ and its support CS2D 1
2
3
4
5
6
7
8
9
$this->p->skip(2);
$this->r->add('hostname', $this->readString());
$this->r->add('password', $this->p->readInt8());
$this->r->add('mapname', $this->readString());
$this->r->add('num_players', $this->p->readInt8());
$this->r->add('max_players', $this->p->readInt8());
$this->r->add('fog_of_war', $this->p->readInt8());
$this->r->add('war_mode', $this->p->readInt8());
$this->r->add('version', $this->readString());
Much more efficient, however, they don't support loading all the players though. (Like player names with their kills/deaths)