Linking GS1 with PHP?

Ex: PlayerCount at the home page…

How is it done? I’ve seen someone do it in GS2 for a server.
Do you use C# to retrieve the data from the RC
then get it to display on the web with PHP or is there some other way?

Seems cool z.z…

GS1 is only clientside on here. To do some playercount stuff with php you would either need to modify the gserver to send the filecount data to a mysql/sqlite db or write to a text file or extend the npc-server functionality to do this. You can also grab the information from the XML-serverlist http://www.graal.in/xml.php?get=servers

Here’s a jquery example:
[php]
var servers = [];
$.get(
http://www.graal.in/xml.php?get=servers”,
function(data)
{
var rssid = 0;
var $xml = $(data);
$xml.find(“server”).each(
function()
{
rssid++;
var $this = $(this),
server = {
name: $this.find(“name”).first().text(),
language: $this.find(“language”).text(),
description: $this.find(“description”).text(),
playercount: $this.find(“player-count”).text(),
mostplayers: $this.find(“most-players”).text(),
id: $this.find(“id”).text(),
players: [],
url: $this.find(“url”).text(),
version: $this.find(“version”).text(),
host: $this.find(“host”).text(),
port: $this.find(“port”).text()
};
$this.find(“player”).each(
function()
{
var player = {
pid: $this.find(“pid”).text(),
accname: $this.find(“accname”).text(),
nickname: $this.find(“nickname”).text()
};
server.players.push(player);
}
);
servers.push(server);
}
);

				//done++;
				
				servers.forEach(
					function(server) 
					{
						alert("Server: "+server.name+" Players: " + server.playercount);
					}
				);
			}
		);

[/php]

YOU FRICKEN GENIUS

I’ve always wanted to make a webpage displaying player achievements, kills, deaths. You know, stats and such. This looks like something i’d be interested in doing.

Yeah do it

Let’s get to it Glyde.

jQuery syntax is so ugh.

It’s just javascript syntax with objects and nestled functions. :wink:

Yes but it goes too far, it ends up that your nested functions are indented the full length of the page if you don’t plan your algorithms carefully. I like my modularity :stuck_out_tongue:

You don’t exactly need to nestle the functions like I did.

[php]
var servers = [];
$.get(
http://www.graal.in/xml.php?get=servers”,
getCallback
);

function getCallback(data)
{
var $xml = $(data);
$xml.find(“server”).each(
serverObject
);

servers.forEach(
	function(server) 
	{
		alert("Server: "+server.name+" Players: " + server.playercount);
	}
);

}

function serverObject(data)
{
var $this = $(this),
server = {
name: $this.find(“name”).first().text(),
language: $this.find(“language”).text(),
description: $this.find(“description”).text(),
playercount: $this.find(“player-count”).text(),
mostplayers: $this.find(“most-players”).text(),
id: $this.find(“id”).text(),
players: [],
url: $this.find(“url”).text(),
version: $this.find(“version”).text(),
host: $this.find(“host”).text(),
port: $this.find(“port”).text()
};

servers[server.id] = server;

$this.find("player").each(
	playerObject(server)
);

}

var playerObject = function(server)
{
return function(data, textStatus)
{
var $this = $(this);
var player = {
pid: $this.find(“pid”).text(),
accname: $this.find(“accname”).text(),
nickname: $this.find(“nickname”).text()
};
server.players.push(player);
};
};
[/php]

There are of course other ways to do this, but it’s all about what you prefer.

Sure, i’ve got a dev server up right now, how should we communicate? I’ve been looking for something to work on.

The gserver could probably be modified to send player variables to the listserver, then we could make a soap/json/xml api to get the data. It could also be made so the gserver listen for http requests on a certain port and respond directly with json/xml

Skype if you’d like. I’ll set us up with a host.

Cadavre I am completely lost with all this server side stuff. >_<
Any documentation available? I hate to say it but I know virtually nothing about Listservers and GServer modification.

No better way to learn than to read the source

Lol ty, so much shit to think about that I overlooked it.

Pestering nalin works better actually.

Nalin doesn’t have time for stuff like this. Bad idea.