It works ok, but the only problem with this plugin is that it spams the logs with data of the same client every few minutes or so (probably on map changes). So its a bit annoying that it floods the logfile with data of same client.
So is there anyone who would be willing write similar plugin, or maybe rewrite this one ( since the author hasnt been online since like 2013) so it does only logs once each client, unless the client use different name/steam id/ip, so then it would log this client again. Im not sure if this is even possible?
Im needing this for L4D2 servers, but im sure there would be more people interesting in this since it would be very helpfull, even for tracking some kids trying DOS or such.
This actually record players in database and refresh log file on map change.
This can use either SQLite or MySql connection.
Log file you find from server root folder, called "log_players.txt"
What you need to do is add plugin database setting into
sourcemod/databases.cfg file
databases.cfg
Code:
"Databases"
{
"driver_default" "mysql"
// When specifying "host", you may use an IP address, a hostname, or a socket file path
"default"
{
"driver" "default"
"host" "localhost"
"database" "sourcemod"
"user" "root"
"pass" ""
//"timeout" "0"
//"port" "0"
}
"log_players"
{
"driver" "sqlite"
"host" "localhost"
"database" "sourcemod"
"user" "root"
"pass" ""
//"timeout" "0"
//"port" "0"
}
"storage-local"
{
"driver" "sqlite"
"database" "sourcemod-local"
}
"clientprefs"
{
"driver" "sqlite"
"host" "localhost"
"database" "clientprefs-sqlite"
"user" "root"
"pass" ""
//"timeout" "0"
//"port" "0"
}
}
/* CREATE TABLE `log_players` ( `steamid` varchar(65) NOT NULL, `name` varchar(65) NOT NULL, `ip` varchar(65) NOT NULL, `port` int(11) NOT NULL, `timestamp` varchar(65) NOT NULL, PRIMARY KEY (`steamid`,`name`,`ip`,`port`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 */ new Handle:g_hTimer; new Handle:g_hDatabase; new Handle:g_hStatement;
new String:buffer[512]; Format(buffer, sizeof(buffer), "CREATE TABLE log_players (steamid varchar(65) NOT NULL,name varchar(65) NOT NULL,ip_port varchar(65) NOT NULL,timestamp varchar(65) NOT NULL,PRIMARY KEY (steamid,name,ip_port))");
new Handle:query = SQL_Query(g_hDatabase, "SELECT * FROM log_players");
if(query == INVALID_HANDLE) { return; }
new Handle:log_players = OpenFile("log_players.txt", "w");
new field_count = SQL_GetFieldCount(query); new String:temp[65]; new String:buffer[512];
for(new a = 0; a < field_count; a++) { SQL_FieldNumToName(query, a, temp, sizeof(temp)); Format(buffer, sizeof(buffer), "%s, %s", buffer, temp); } WriteFileLine(log_players, "%s", buffer[1]); buffer[0] = '\0';
while (SQL_FetchRow(query)) { for(new a = 0; a < field_count; a++) { SQL_FetchString(query, a, temp, sizeof(temp)) Format(buffer, sizeof(buffer), "%s, %s", buffer, temp); } WriteFileLine(log_players, "%s", buffer[1]); buffer[0] = '\0'; } CloseHandle(log_players); }
I haven't test plugin in long period so beware. And this use temporary database connection, automatically close after 2 minutes if there not happen new player connection or mapchange.