Naming the output file

JohnW63

I would like to use the plrfilename variable to create each drivers output file name for my plugin. I think I tried using a variable before and it barked at me. What is the proper way to use use the player name and possibly the track name as well , in the file creation ?

ex: <track name>_<player name>.txt for the output file name.

Even better might be <track name>_<player name>_<time of creation>.txt

That way, it's easy to see who sent the file, what race it was, and when it was created, so I can keep them sorted and use the time stamp as a check.
 
Code:
char outputFilename[200];
sprintf(outputFilename,"%s_%s",info.mTrackName, info.mPlrFileName);
 
Once that is done, I'd have a file created, and I can point fprintf commands to it , right ?

I would also have to run those commands from the UpdateScoring, but aren't the open all files function called prior to that ?
 
You can just put your own code in UpdateScorring. Something like this:
Code:
char outputFilename[200];
sprintf(outputFilename,"%s_%s.txt",info.mTrackName, info.mPlrFileName);

FILE *fo;
fo = fopen( outputFilename, "w" );
if( fo != NULL )
{
	fprintf( fo, "This fool just changed his tires!!" );
	fclose( fo );
}

This code will overwrite <TrackName>_<PlayerName>.txt or create a new one if it doesn't exist. If you just want to append the file then change "w" to "a".
 
Of course. I forgot I could replace it with the "w". I've just be letting the plugin create it and write to the file of the same name. I have changed that " same name" at this point, but it was still going to be static for everyone.
 

Back
Top