ExciteEfect13 Posted May 20, 2015 Share Posted May 20, 2015 Hi, I'm learning C++ and I need a tutorial on how to add .ini file to change keys. I'm using native trainer SDK and piece of code to explain would be great! Thanks! Link to comment Share on other sites More sharing options...
BenBaron Posted May 20, 2015 Share Posted May 20, 2015 (edited) Well, the general code would be something like this: int key = 0;key = GetPrivateProfileInt("Keys", "key", -1, ".\\NameOfFile.ini"); Try to get the key defined in Section "Keys", Key "key" of file "NameOfFile.ini" (.\\ meaning the .ini file is in the same folder path the process is running from). If this doesn't succeed for any reason (like the file wasn't found), int key will revert to the default value of -1 (3rd paramater). Of course, the ini file must look something like this: [Keys] key=0x76 // hexadecimal value for F7 The hexadecimal values for the key codes can be found here https://msdn.microsoft.com/de-de/library/windows/desktop/dd375731%28v=vs.85%29.aspx. Then simply check if "key" was pressed in your code, using GetAsyncKeyState or something similar. Edited May 20, 2015 by BenBaron MagicStyle 1 Link to comment Share on other sites More sharing options...
ExciteEfect13 Posted May 20, 2015 Author Share Posted May 20, 2015 Well, the general code would be something like this: int key = 0;key = GetPrivateProfileInt("Keys", "key", -1, ".\\NameOfFile.ini"); Try to get the key defined in Section "Keys", Key "key" of file "NameOfFile.ini" (.\\ meaning the .ini file is in the same folder path the process is running from). If this doesn't succeed for any reason (like the file wasn't found), int key will revert to the default value of -1 (3rd paramater). Of course, the ini file must look something like this: [Keys] key=0x76 // hexadecimal value for F7 The hexadecimal values for the key codes can be found here https://msdn.microsoft.com/de-de/library/windows/desktop/dd375731%28v=vs.85%29.aspx. Then simply check if "key" was pressed in your code, using GetAsyncKeyState or something similar. Sorry if I am making obvious mistake, something like this?? int key = 0; key = GetPrivateProfileInt("0x76", "0x74", -1, ".\\trainer.ini"); Link to comment Share on other sites More sharing options...
BenBaron Posted May 20, 2015 Share Posted May 20, 2015 No, it seems you don't know the basic structure of ini files. They consist of sections and keys: [Keys -> this is the section] key -> this is the key = 0x76 GetPrivateProfileInt's first paramater is the section and the second is the key , so in your example the .ini file would need to look like this in order to return something, which is obviously most probably not what you want: [0x76] 0x74= I am going to give you an example: This is part of the .ini: [Keys]init=0x76nextseat=0x27prevseat=0x25radiotoggle=0xBD[settings]tvpos=1 and this is how those keys are read out in code: keyInit = GetPrivateProfileInt("Keys", "init", -1, ".\\LimoMod.ini");keyNextSeat = GetPrivateProfileInt("Keys", "nextseat", -1, ".\\LimoMod.ini");keyPrevSeat = GetPrivateProfileInt("Keys", "prevseat", -1, ".\\LimoMod.ini");keyRadioToogle = GetPrivateProfileInt("Keys", "radiotoggle", -1, ".\\LimoMod.ini");setTVPos = GetPrivateProfileInt("Settings", "tvpos", -1, ".\\LimoMod.ini"); Link to comment Share on other sites More sharing options...
ExciteEfect13 Posted May 20, 2015 Author Share Posted May 20, 2015 No, it seems you don't know the basic structure of ini files. They consist of sections and keys: [Keys -> this is the section] key -> this is the key = 0x76 GetPrivateProfileInt's first paramater is the section and the second is the key , so in your example the .ini file would need to look like this in order to return something, which is obviously most probably not what you want: [0x76] 0x74= I am going to give you an example: This is part of the .ini: [Keys]init=0x76nextseat=0x27prevseat=0x25radiotoggle=0xBD[settings]tvpos=1 and this is how those keys are read out in code: keyInit = GetPrivateProfileInt("Keys", "init", -1, ".\\LimoMod.ini");keyNextSeat = GetPrivateProfileInt("Keys", "nextseat", -1, ".\\LimoMod.ini");keyPrevSeat = GetPrivateProfileInt("Keys", "prevseat", -1, ".\\LimoMod.ini");keyRadioToogle = GetPrivateProfileInt("Keys", "radiotoggle", -1, ".\\LimoMod.ini");setTVPos = GetPrivateProfileInt("Settings", "tvpos", -1, ".\\LimoMod.ini"); I got it working now, thanks alot!! Link to comment Share on other sites More sharing options...
flynhigh09 Posted May 20, 2015 Share Posted May 20, 2015 (edited) How bout c# anyone know mine never loads. SPraceMod.net.ini [RACE_SETTINGS]VEHICLE=3057713523 _settings = ScriptSettings.Load("SPraceMod.net");//doesnt load? VehicleModel = _settings.GetValue<VehicleHash>("RACE_SETTINGS", "VEHICLE", VehicleHash.Dukes2);//loads if use Settings.GetValue but only default.? Edited May 20, 2015 by flynhigh09 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now