Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
      4. Frontier Pursuits
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Diamond Casino & Resort
      2. DLC
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA 6

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA IV Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA SA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA VC Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA III Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. News

    2. Forum Support

    3. Site Suggestions

NexusAU

Reading ini files.

Recommended Posts

NexusAU

How would I go about reading key controls from an .ini file?

 

I'm using this function but I'm having trouble with adding the parameters needed to read from the .ini

DWORD openKey = GetPrivateProfileString("CONTROLS", "OPEN_KEY", VK_F3, "LSDrift.ini");

Share this post


Link to post
Share on other sites
PhK

 

How would I go about reading key controls from an .ini file?

 

I'm using this function but I'm having trouble with adding the parameters needed to read from the .ini

DWORD openKey = GetPrivateProfileString("CONTROLS", "OPEN_KEY", VK_F3, "LSDrift.ini");

Hi man, the best way that I've found to read is this (that I use in my scripts and works fine):

LPCTSTR path = ".\\nitroMod.ini";char infiniteNitro[3];GetPrivateProfileString(_T("CONFIGURATION"), _T("infiniteNitro"), _T(""), _T(infiniteNitro), 3, path);     if (strcmp(_T(infiniteNitro), "1") == 0) {	nitroInfinito = true;     } else {	nitroInfinito = false;     }

I hope this helps! :)

Edited by PhK

Share this post


Link to post
Share on other sites
fastman92

                GetPrivateProfileStringA("MAP LIMITS", "Paths map size", NULL, cTmp, sizeof(cTmp), cPath);

if (strlen(cTmp))

MapLimits::SetPathsMapSize(atoi(cTmp));

		// Map limits

#if TRUE

{

 

GetPrivateProfileStringA("MAP LIMITS", "Apply tracks.dat coordinate limit patch", NULL, cTmp, sizeof(cTmp), cPath);

if (atoi(cTmp))

MapLimits::EnableTracksDatCoordinateLimitPatch(atoi(cTmp));

 

GetPrivateProfileStringA("MAP LIMITS", "Renderware world map size", NULL, cTmp, sizeof(cTmp), cPath);

if (strlen(cTmp))

MapLimits::SetRenderwareWorldMapSize(atoi(cTmp));

 

GetPrivateProfileStringA("MAP LIMITS", "Radar map size", NULL, cTmp, sizeof(cTmp), cPath);

if (strlen(cTmp))

MapLimits::SetRadarSize(atoi(cTmp));

 

GetPrivateProfileStringA("MAP LIMITS", "Water map size", NULL, cTmp, sizeof(cTmp), cPath);

if (strlen(cTmp))

MapLimits::SetWaterMapSize(atoi(cTmp));

 

GetPrivateProfileStringA("MAP LIMITS", "World map size", NULL, cTmp, sizeof(cTmp), cPath);

if (strlen(cTmp))

MapLimits::SetWorldMapSize(atoi(cTmp));

 

GetPrivateProfileStringA("MAP LIMITS", "World sector size", NULL, cTmp, sizeof(cTmp), cPath);

if (strlen(cTmp))

MapLimits::SetWorldSectorSize(atoi(cTmp));

 

GetPrivateProfileStringA("MAP LIMITS", "World LOD sector size", NULL, cTmp, sizeof(cTmp), cPath);

if (strlen(cTmp))

MapLimits::SetLODSectorSize(atoi(cTmp));

 

MapLimits::CommitChanges();

}

#endif

Remember to pass a full INI file path to GetPrivateProfileStringA Edited by fastman92

Share this post


Link to post
Share on other sites
ThalonMook

Hi,

 

I tried to use the nitromod sample to read a ini. But it will not compile in VS 2013.

I used the Script Hook SDK Sample file as base.

When I use the GetPrivateProfileString it will show:

This Declaration has no storage class or type specifier

 

This is my script:

#include "script.h"#include <string>#include <ctime>#include <Windows.h>#pragma warning(disable : 4244 4305) // double <-> float conversionsLPCTSTR path = ".\\SelfRadio.ini";char RadioIndex[32];GetPrivateProfileString(TEXT("CONFIG"), TEXT("RadioIndex"), TEXT("1"), Text(RadioIndex), 32, path);int rindex = atoi(RadioIndex);void update(){	Ped playerPed = PLAYER::PLAYER_PED_ID();	Vehicle veh = PED::GET_VEHICLE_PED_IS_USING(playerPed);	if (GetAsyncKeyState(VK_OEM_1) || GetAsyncKeyState(VK_SUBTRACT))	{		AUDIO::SET_RADIO_TO_STATION_INDEX(rindex);	}}void main(){	while (true)	{		update();		WAIT(0);	}}void ScriptMain(){	srand(GetTickCount());	main();}

It works without the ini reading but I need to give the users the chance to set their own Radiostation and also the Buttons.

 

 

CU

Thalon

Share this post


Link to post
Share on other sites
Silent

What's with the code outside of any scope?

Share this post


Link to post
Share on other sites
ThalonMook

Hi,

 

do you mean this:

LPCTSTR path = ".\\SelfRadio.ini";char RadioIndex[32];GetPrivateProfileString(TEXT("CONFIG"), TEXT("RadioIndex"), TEXT("1"), Text(RadioIndex), 32, path);int rindex = atoi(RadioIndex);

Share this post


Link to post
Share on other sites
fastman92

Hi,

 

do you mean this:

LPCTSTR path = ".\\SelfRadio.ini";char RadioIndex[32];GetPrivateProfileString(TEXT("CONFIG"), TEXT("RadioIndex"), TEXT("1"), Text(RadioIndex), 32, path);int rindex = atoi(RadioIndex);

 

Will this code compile?

Share this post


Link to post
Share on other sites
ThalonMook

No it will not.

 

Where I have to put it?

 

Without this it will compile and work.

I set AUDIO::SET_RADIO_TO_STATION_INDEX(17);

without the ini part.

 

Sorry Im new at c++ programming so I need more help than pros :D

Edited by ThalonMook

Share this post


Link to post
Share on other sites
Skorpro

No it will not.

 

Where I have to put it?

 

Without this it will compile and work.

I set AUDIO::SET_RADIO_TO_STATION_INDEX(17);

without the ini part.

 

Sorry Im new at c++ programming so I need more help than pros :D

 

Hi,

if you want to read Integers from INI use this instead:

#define INI_path "./SelfRadio.ini"int iRadioIndex = GetPrivateProfileIntA("CONFIG", "RadioIndex", 1, INI_path);

Set it global.

Share this post


Link to post
Share on other sites
ThalonMook

Thx for the help.

 

I will try it but I also need to read a string from the ini

 

I need to set the button in the ini so that the user can change it.

 

Sorry for the dumb question how do I set it global?

 

Can you post my code with your changes?

 

 

*Edit ok it works the ini was read and the station is set to the station from the ini

 

Now only the button problem is left :-(

 

Cu

Thalon

Edited by ThalonMook

Share this post


Link to post
Share on other sites
Skorpro
Now only the button problem is left :-(

The keys are integers too ;)

 

F3 key: VK_F3 = 0x72 = 114

 

BTW. if you need a function to read a string, you can use s.t. like this:

char* skpINI_ReadString(char* Section, char* Key, const char* DefaultString){	char* Result = new char[255];	memset(Result, 0x00, 255);	GetPrivateProfileStringA(Section, Key, DefaultString, Result, 255, INI_Name);	return Result;}

C ya

 

Share this post


Link to post
Share on other sites
ThalonMook

Thx for the help.

 

I have it now working and can set the key and index in the ini.

 

Cu

Thalon

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 2 Users Currently Viewing
    0 members, 0 Anonymous, 2 Guests

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.