Raised This Month: $ Target: $400
 0% 

Server crashes because of my plugin?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Drocona
Junior Member
Join Date: Oct 2005
Location: The Netherlands
Old 10-30-2005 , 08:43   Server crashes because of my plugin?
Reply With Quote #1

ok i made this plugin.. everything seems to be working but after a while it just crashes (read error acces memory shit)

i dont know whats the problem.... it just logs some things ingame, writing it to a .txt file.



Code:
void CTSlogging::FireGameEvent( KeyValues * event )
{
	const char * name = event->GetName();
	FileHandle_t tslogs;
    tslogs = filesystem->Open("TSlog.txt","a+t");

	if ( FILESYSTEM_INVALID_HANDLE != tslogs )
	{
		if (FStrEq(name, "round_start"))
		{
			filesystem->FPrintf(tslogs,"Round Started \n");
			filesystem->Close(tslogs);
		}

		else if (FStrEq(name, "player_say"))
		{
			int pname = event->GetInt("userid");
			const char* text = event->GetString("text");

			char buffer[300];
			Q_snprintf(buffer,300,"%s%s%s%s\n","say ",pname,": ",text);

			filesystem->FPrintf(tslogs,buffer);
			filesystem->Close(tslogs);
		}			

		else if (FStrEq(name, "player_death"))
		{
			int killer = event->GetInt("attacker");
			int victim = event->GetInt("userid");

			if (victim == killer)
			{
				filesystem->FPrintf(tslogs, killer + "comitted suicide \n");
				filesystem->Close(tslogs);
			}

			else
			{
				char buf[300];
				Q_snprintf(buf,300,"%s%s%s\n",killer," killed ",victim);

				filesystem->FPrintf(tslogs,buf);
				filesystem->Close(tslogs);
			}
		}
	} 
}
i think it might have something to do with the filesystem->FPrintf function because mani said it makes alot of crashes?
if it is that function, can someone tell me how i could write to a file without the FPrintf function and without any extra things i need to have in C++

***EDIT***
after a little testing i noticed that the server crashes after shooting a player a few times ingame
__________________
Team .Mystic - Drocona
Drocona is offline
Send a message via MSN to Drocona
 



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 11:52.


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