Solved Best way to save and restore config files

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

kaz

Coder
Full Member
Nobleman
Apr 3, 2013
160
1,183
7
I'm trying to create a configuration file (mine in this case is simply config.txt) that can be saved based on your menu selections and when you relaunch the hack you can click Load config.txt.



C++:
//THIS IS C++, std::boolalpha is to have the bools print as true instead of 1, if I remove std::boolalpha then save>load>save then the text file will print garbage numbers like 204 for bools
	void LoadConfig()
	{
		ifstream in("config.txt");
		in >>std::boolalpha>> espactive  >> bunnyactive >> espspecial>>  esphumans>>  espinfected>>  espsnapline >> espmehealth>>  esp3D >> esphealth >> espzomhealth>>  aimbotactive >> aimbothumans>>  aimbotspecial>>  aimbotsmooth >> aimbotbounce >> fovdist>>aimbotkey>>triggerkey>>aimFOV>>aimsens;
		in.close();
	}
	void SaveConfig()
	{
		ofstream out("config.txt");
		out <<std::boolalpha<< espactive  << bunnyactive << espspecial<<  esphumans<<  espinfected<<  espsnapline << espmehealth<<  esp3D << esphealth << espzomhealth<<  aimbotactive << aimbothumans<<  aimbotspecial<<  aimbotsmooth << aimbotbounce << fovdist<<aimbotkey<<triggerkey<<aimFOV<<aimsens;
		out.close();
	}
}
everything is booleans until it gets to aimbotkey, triggerkey,aimFOV, aimsens
aimbotkey,triggerkey are integers
aimfov,aimsens are float values.

When I save configuration this is what I usually get saved into my .txt document

truetruetruefalsefalsefalsefalsetruetruefalsetruefalsetruetruetruefalse12101.25
aimbotkey = 1
triggerkey = 2
aimfov = 10 //uses slider bar
aimsens = 1.25 //uses slider bar

Loading the config.txt will set everything back the way it way until after aimbotkey, I think I'm reading the values incorrectly(fstream is new to me) because I'm not sure if using my technique as above is only reading one character or not because my float values can be from 1 char to 4 chars.

It's not loading as soon as I get to the numbers in the config.txt


Here's what it will look like, I'll save the hack, then click load afterwards before anything else and you can see the keybindings change which is incorrect
|||


Thanks so much for reading.

if there is a better way to do this that you guys can help me with that would be appreciated as well.
 

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
12,638
76
Use .ini or .xml, .. eg. WriteProfileString/ReadProfileString or some simple xml parser. I got my menu separated into tabs, each tab will be a app name in ini and each menu element is a key. I iterate over all the menu items and based on type format the value accordingly.
 

till0sch

Respected Hacker
Dank Tier VIP
Dank Tier Donator
Oct 14, 2012
1,104
12,593
51
Yeah maybe just save like "01 00 01 00 01 01 00 01 01" then load the file while every byte there stand for on or off (you might have done it like that but it's too much text to read and I'm too lazy for that)
 

NTvalk

Hacker
Meme Tier VIP
Jul 6, 2013
499
3,108
8
Yeah as c5 said you should try to parse it from some structured format
 

MJZombieMan

Newbie
Full Member
Jul 7, 2014
11
418
0
Just make the format be separated by a new line '\n'. Simplest way there is. Read in a line, that's the first option's value. read in the second line, that's the second option's value, etc. Super simple. And depending on the line you could parse it differnetly - boolean, or integer.
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Similar threads

Community Mods