PDA

View Full Version : MySQL server informations


foohey
04-30-2009, 20:14
MySQL server informations
This plugin allows you to record in a MySQL database, many informations of your servers and players.

Original plugin by dmustanger: http://forums.alliedmods.net/showthread.php?t=84899

For who ?
This plugin is good if you want retrieve informations from your game server by a MySQL database.
I do not develop in PHP, no web interface planned.

How it work
You need to set the SERVER_ID if you want to use it on multiple servers.
(1 for 1st server, 2 for the 2nd...)

When the plugin start, if no servers, a new is created. if already created, just the maxplayers and hostname is updated.

When a client connect, a new row with name, steam id, server id, frags, deaths... is created. when disconnected, row are deleted.

When map change, all players are deleted.
When server start, all players are deleted.

On round end, teams scores are updated.

If you want the number of current players in a server, make a COUNT(*) query of players in your app.

Installation
Create a database named server_info
Create tables:

CREATE TABLE IF NOT EXISTS `servers` (
`server_id` int(11) NOT NULL,
`server` varchar(50) NOT NULL,
`port` varchar(50) NOT NULL,
`maxplayers` int(11) NOT NULL default '0',
`servername` varchar(100) NOT NULL default 'noserver',
`map` varchar(50) NOT NULL default 'de_dust',
`score_t` int(11) NOT NULL,
`score_ct` int(11) NOT NULL,
PRIMARY KEY (`server_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


CREATE TABLE IF NOT EXISTS `players` (
`userid` int(11) NOT NULL,
`steam_id` varchar(200) NOT NULL,
`server_id` int(11) NOT NULL,
`name` varchar(200) NOT NULL,
`score` int(11) NOT NULL,
`time` int(50) NOT NULL,
PRIMARY KEY (`userid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


And add to your configs/databases.cfg:

"server_info"
{
"driver" "mysql"
"host" "HOST"
"database" "server_info"
"user" "USER"
"pass" "PASS"
}


Notes
This plugin is under dev, and tested on a cs:s server.

BoredMind
04-30-2009, 20:54
Thank you very much!! :):)

BoredMind
06-17-2009, 12:28
How do I change the server_id on this?

Thank you

exvel
06-17-2009, 12:33
Maybe move it here (http://forums.alliedmods.net/forumdisplay.php?f=110)?

BoredMind
06-18-2009, 17:20
This is not working for more than 1 server. If I modify the source and change server_id to something other than 1 and compile it something still isn't right.

I am able to get it to run, and add an entry to the servers table correctly, but it is not populating the players at all, I keep getting duplicate T_Generic (or similar) errors in the console window.

L 06/18/2009 - 17:14:41: [server_info.smx] Query Failed T_generic: Duplicate entry '10' for key 1

Any ideas?

BoredMind
06-26-2009, 17:57
Can anyone help me with this? Please.

BoredMind
07-17-2009, 02:41
Any help? Please? Someone? I am stuck with this only half working. :-(