Jump to content

Home

Writing stats


axel364

Recommended Posts

Hello,

I want to write a stats file.

 

This code looks correct :

 

void WritePlayerStats(char playername[MAX_TOKEN_CHARS], int kills, int deaths, int duelwins, int duelloss )
{
FILE *playerstats;
if ((playerstats = fopen("playerstats.txt","w+" )) == NULL) {
	trap_SendServerCommand( -1, va("print \"""^1Error!^7\""));
	return;
} else {
	fprintf(playerstats,"%s\n{\n%i\n%i\n%i\n%i\n}",playername,kills,deaths,duelwins,duelloss);
	fclose(playerstats);	
}
}

 

I want the mod writes player's stats in "playerstats.txt" for every players on the server, when a player enters, I want the mod looks for his name in playerstats.txt and store him in the file if he comes for the first time. The playerstats.txt looks like this :

 

AxeL364
{
5
2
0
0
}

 

And I want to be able to read my stats from the game... I really need to know how to find a "string" in a file.

 

Thanks.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...