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
__________________