AlliedModders Donor
|

08-17-2014
, 10:29
Re: [ANY] Log Connections
|
#30
|
I've made this basic plugin for my own server that just logs connections/disconnections (name, steamid, IP) and map changes in one file named Connections.log. This does not have the double logging bug.
What the log entries look like:
Code:
L 08/16/2014 - 14:53:18: -------- Mapchange to de_nuke --------
L 08/16/2014 - 14:53:18: Player 1<4><STEAM_1:0:********><><85.***.**.***> connected.
L 08/16/2014 - 15:01:33: Player 2<14><STEAM_1:0:********><><5.***.***.**> connected.
L 08/16/2014 - 15:01:59: Player 2<14><STEAM_1:0:********><><5.***.***.**> disconnected.
L 08/16/2014 - 15:15:53: Player 1<4><STEAM_1:0:********><><85.***.**.***> disconnected.
Source:
Spoiler
Code:
#include <sourcemod>
public Plugin:myinfo =
{
name = "Connection Logger",
author = "STAV3",
description = "Logs client Name, SteamID and IP.",
version = "1.1",
url = ""
}
public OnMapStart()
{
new String:map[64];
GetCurrentMap(map, sizeof(map));
decl String:filepath[PLATFORM_MAX_PATH];
BuildPath(Path_SM, filepath, sizeof(filepath), "logs/Connections.log");
LogToFileEx(filepath, "-------- Mapchange to %s --------", map);
return;
}
public OnClientAuthorized(client, const String:steamid[])
{
if (IsFakeClient(client))
return;
new String:ip[64];
GetClientIP(client, ip, sizeof(ip));
decl String:filepath[PLATFORM_MAX_PATH];
BuildPath(Path_SM, filepath, sizeof(filepath), "logs/Connections.log");
LogToFileEx(filepath, "%L<%s> connected.", client, ip);
return;
}
public OnClientDisconnect(client)
{
if (IsFakeClient(client))
return;
new String:ip[64];
GetClientIP(client, ip, sizeof(ip));
decl String:filepath[PLATFORM_MAX_PATH];
BuildPath(Path_SM, filepath, sizeof(filepath), "logs/Connections.log");
LogToFileEx(filepath, "%L<%s> disconnected.", client, ip);
return;
}
Source (old version):
Spoiler
Code:
#include <sourcemod>
public Plugin:myinfo =
{
name = "Connection Logger",
author = "allienaded",
description = "Logs client Name, SteamID and IP.",
version = "1.0",
url = ""
}
public OnMapStart()
{
decl String:map[64];
GetCurrentMap(map, sizeof(map));
decl String:path[PLATFORM_MAX_PATH];
BuildPath(Path_SM, path, sizeof(path), "logs/Connections.log");
new Handle:file = OpenFile(path, "a");
LogToOpenFileEx(file, "-------- Mapchange to %s --------", map);
CloseHandle(file);
return;
}
public OnClientAuthorized(client, const String:steamid[])
{
if (IsFakeClient(client))
return;
new String:ip[64];
GetClientIP(client, ip, sizeof(ip));
decl String:path[PLATFORM_MAX_PATH];
BuildPath(Path_SM, path, sizeof(path), "logs/Connections.log");
new Handle:file = OpenFile(path, "a");
LogToOpenFileEx(file, "%L<%s> connected.", client, ip);
CloseHandle(file);
return;
}
public OnClientDisconnect(client)
{
if (IsFakeClient(client))
return;
new String:ip[64];
GetClientIP(client, ip, sizeof(ip));
decl String:path[PLATFORM_MAX_PATH];
BuildPath(Path_SM, path, sizeof(path), "logs/Connections.log");
new Handle:file = OpenFile(path, "a");
LogToOpenFileEx(file, "%L<%s> disconnected.", client, ip);
CloseHandle(file);
return;
}
Last edited by allienaded; 10-08-2014 at 21:37.
Reason: Updated plugin to work more reliably with Sourcemod 1.6.x
|
|