Hello, I've modified Fredd's CD announcer (
http://forums.alliedmods.net/showthread.php?p=522403) to just log connections to a .txt file which is recreated on every map start, and it works, however I get this error:
So I was wondering if anyone could help me get rid of the error? Here's the code:
PHP Code:
#include <sourcemod>
#pragma semicolon 1
#define CD_VERSION "2.3"
new Handle:LogFile = INVALID_HANDLE;
public Plugin:myinfo =
{
name = "CD Announcer",
author = "Fredd",
description = "",
version = CD_VERSION,
url = "www.sourcemod.net"
}
public OnMapStart()
{
decl String:iLogFileLoc[PLATFORM_MAX_PATH], String:LogFileLoc[PLATFORM_MAX_PATH];
GetConVarString( LogFile, iLogFileLoc, sizeof( iLogFileLoc ) );
Format( LogFileLoc, sizeof( LogFileLoc ), "addons/sourcemod/%s", iLogFileLoc );
if ( FileExists( LogFileLoc ) )
{
DeleteFile( LogFileLoc );
}
decl String:Path[PLATFORM_MAX_PATH];
decl String:Time[21];
FormatTime( Time, sizeof( Time ), "%m/%d/%y - %I:%M:%S", -1) ;
BuildPath( Path_SM,Path, sizeof( Path ), LogFileLoc );
new Handle:File = OpenFile( Path, "a" );
WriteFileLine( File,"[%s] %t", Time, "Log Started" );
CloseHandle( File );
}
public OnPluginStart()
{
LoadTranslations( "cdannouncer.phrases" );
CreateConVar( "cd_announcer_version", CD_VERSION, "Connect/Disconnect Announcer Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY );
LogFile = CreateConVar( "cd_logfile" , "data/connect_log.log", "location of the log file relative to the sourcemod folder" );
}
public OnClientPostAdminCheck( client )
{
if( IsFakeClient( client ) )
return;
decl String:gName[MAX_NAME_LENGTH+1];
decl String:gIp[26], String:gAuth[21];
decl String:Time[21], String:iLogFileLoc[PLATFORM_MAX_PATH], String:LogFileLoc[PLATFORM_MAX_PATH];
FormatTime( Time, sizeof( Time ), "%m/%d/%y - %I:%M:%S", -1 );
GetConVarString( LogFile, iLogFileLoc, sizeof( iLogFileLoc ) );
Format( LogFileLoc, sizeof( LogFileLoc ), "addons/sourcemod/%s", iLogFileLoc );
GetClientName( client, gName, MAX_NAME_LENGTH );
GetClientIP( client, gIp, sizeof( gIp ) );
GetClientAuthString( client, gAuth, sizeof( gAuth ) );
new Handle:File = OpenFile( LogFileLoc, "a" );
if( File == INVALID_HANDLE )
{
LogError( "%t", "File Not Created" );
return;
}
WriteFileLine( File,"[%s] %s[%s][%s] connected", Time, gName, gAuth, gIp );
if( File != INVALID_HANDLE )
CloseHandle( File );
return;
}
Thanks very much.