Raised This Month: $ Target: $400
 0% 

File writing error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
untamed0
Junior Member
Join Date: Jan 2010
Old 02-23-2010 , 07:45   File writing error
Reply With Quote #1

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:

Quote:
L 02/23/2010 - 130:58: [SM] Native "WriteFileLine" reported: Invalid file handle 0 (error 4)
L 02/23/2010 - 130:58: [SM] Displaying call stack trace for plugin "connect_log.smx":
L 02/23/2010 - 130:58: [SM] [0] Line 35, /groups/sourcemod/upload_tmp/text7BSmNj.sp::OnMapStart()
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];
    
    
GetConVarStringLogFileiLogFileLocsizeofiLogFileLoc ) );
    
FormatLogFileLocsizeofLogFileLoc ), "addons/sourcemod/%s"iLogFileLoc );

    if ( 
FileExistsLogFileLoc ) )
    {
        
DeleteFileLogFileLoc );
    }

    
decl String:Path[PLATFORM_MAX_PATH];
    
decl String:Time[21];

    
FormatTimeTimesizeofTime ), "%m/%d/%y - %I:%M:%S", -1) ;

    
BuildPathPath_SM,PathsizeofPath ), LogFileLoc );

    new 
Handle:File OpenFilePath"a" );
    
WriteFileLineFile,"[%s] %t"Time"Log Started" );
    
CloseHandleFile );
}
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 
OnClientPostAdminCheckclient )
{
    if( 
IsFakeClientclient ) )
        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];

    
FormatTimeTimesizeofTime ), "%m/%d/%y - %I:%M:%S", -);

    
GetConVarStringLogFileiLogFileLocsizeofiLogFileLoc ) );
    
FormatLogFileLocsizeofLogFileLoc ), "addons/sourcemod/%s"iLogFileLoc );

    
GetClientNameclientgNameMAX_NAME_LENGTH );
    
GetClientIPclientgIpsizeofgIp ) );
    
GetClientAuthStringclientgAuthsizeofgAuth ) );

    new 
Handle:File OpenFileLogFileLoc"a" );

    if( 
File == INVALID_HANDLE )
    {
        
LogError"%t""File Not Created" );
        return;
    }

    
WriteFileLineFile,"[%s] %s[%s][%s] connected"TimegNamegAuthgIp );

    if( 
File != INVALID_HANDLE )
        
CloseHandleFile );
    
    return;

Thanks very much.
untamed0 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:12.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode