Scanning for certain words and logging advice

Im developing a anticheat for a game that check the players keybind info
and so far ive got it to do half of it.
Im trying to get it to scan the file for a certain work which i got that part but since the player can change this ingame it updates the file im checking so i just need help getting it to actively scan it for that certain word instead of scanning once like it is now. here is some code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
void InitTweakLog(void)
[
	fopen_s(&tweak_fp, TWEAK_LOG, "a"); // This is where it creats the file for the found strings to be printed
	if(tweak_fp == NULL)
	[
		debuglog("Unable to open tweak log");
		return;
	]

	fprintf(tweak_fp ,"Tweaks="); // Prints the string if found after this
	
	fflush(tweak_fp );

	fclose (tweak_fp );
(

void LogTweak(const LPSTR tweak)
)
	fopen_s(&tweak_fp, TWEAK_LOG, "a");
	if(tweak_fp == NULL)
	(
		debuglog("Unable to open tweak log");
		return;
	)

	fseek(tweak_fp , SEEK_END, 0);

	fprintf(tweak_fp ,"%s\r", tweak);

	fflush(tweak_fp );

	fclose (tweak_fp );
)


void TweakCheck( void )
(
	char line[1024];

	ifstream IniFile("User.ini", ios_base::in ); // This is where it open the player's Ini file


	if(!IniFile)
	(
		debuglog("Unable to open ini");
		return;
	)

	while ( IniFile.getline(line, 1024, '\n') != NULL )
	(
		CheckLine(line);
		//debuglog("%s", line);
	)
	
	IniFile.close();
(


void CheckLine( char *fline )
)
	char tmp_line[1024];
	char *new_line;
	int sCount = 0;

	// Copy to tmp_line to keep string manipulatiopn local to function
	strcpy_s(tmp_line, fline);

	new_line = strstr(tmp_line, "set");// These are the strings it searches for in the ini 
	if ( new_line != NULL )
	(
		LogTweak(fline);
		debuglog("%s", tmp_line);
		return;
	)

	new_line = strstr(tmp_line, "SET");
	if ( new_line != NULL )
	(
		LogTweak(fline);
		debuglog("%s", tmp_line);
		return;
	)

	new_line = strstr(tmp_line, "suicide");
	while (new_line != NULL)
	(
		sCount++;
		new_line = new_line + strlen("suicide");
		new_line = strstr(new_line, "suicide");
	)

	if ( sCount > 1 )
	(
		LogTweak(fline);
		debuglog("%s", tmp_line);
	)
)
Last edited on
Sorry I'm having trouble reading your code. Try putting it in a code format block.

{code} (you should use "[" and "]" though; this is so you can see it.)
/* Your code goes here*/
{/code}

Also, indent when necessary, if you weren't already, and comments as to the purpose of all these functions might help too.
I hope this helps some i edited it.

But the main thing im trying to is to get it to keep scanning
But like the way it is now it will scan the ini if the string is found it puts it in the tweak.log file and if nothing is found it doesnt print anything

But if it doesnt find anything i want it to keep scanning like say every 15 seconds and if 1 is found to have it printed
I'm still not sure what you're having troubles with. Which is the half that works?

If what you need is just a way to wait the 15 seconds, I would suggest time.h:

http://www.cplusplus.com/reference/clibrary/ctime/

If what you need is to be able to do things with your program in between, or simultaneously, I would suggest threads, but I am no expert on them, and would not be the one to ask.
Topic archived. No new replies allowed.