Help Saving ini files via UScript

Hello guys!

I want to change, in runtime, through Unreal Script, the value of the string variable

PreviewImageMarkup

For some maps on DefaultGame.ini

This variable is located under the section:

[MapName UTUIDataProvider_MapInfo]

But I don’t know how access this section of the ini file.

I have been reading this page on UDN: https://docs.unrealengine.com/udk/Th…ameSystem.html

This works, but is not what I need, as on this example, it creates a new section inside the ini file (it does not teach how to change variables from a specific section on the ini file).

Any help?

Only thing I can help you with, but the thing is that I really don’t know how to do such thing is that you can point which ini file you can write on at the beginning of your class something like

class TestConfig extends Actor config(User); from here https://docs.unrealengine.com/udk/Th…tionFiles.html.

Hello my friend. Thanks for the answer.

What I want to do is to create a small ranking system. In example, I have got a challenge mission for my game, similar to Hitman 2, on which the player needs to perform at least 10 headshots to complete this mission.

So if the player performs 10 headshots, he completes the mission, but earns rank C. If he performs more than 10 headshots and less than 15, earns rank B. And if performs more than 15 headshots, earns Rank A.

I already got the ranking system working, done entirely in kismet, but I used some unrealscripting on the enemies pawn classes to detect headshot using HitBone function, and to save a boolean variable (IsHeadShot), an then on kismet it reads the value of this boolean variable and increments another kismet variable (HeadShotCounter) to count the number of headshots, so after all the enemies are killed (i used an ObjectList to detect it), there is another kismet sequence which checks the number of headshots performed, and then triggers a flash movie (icon) for each ranking (A,B,C). I just wanted to “save” this ranking information for each map.

My initial idea was to create for each map 4 Preview images (the original map image + 3 images for the rankings A,B, C), then according to the earned ranking for each map, the image would change. So if player got on Map 1 ranking A, always whenever he plays the game, and opens the map selection list, he would see the map image with kinda badget over it (RankA, RankB or RankC).

I have tested this Script:


class TestConfig extends Actor
config(Game);

var config int X;

function postbeginplay()
{
X=5;
SaveConfig();
}

But then, what I got was this, on my UDKGame.ini


[AnaIrhabi.TestConfig]
X=5

“AnaIrhabi” here is my custom gametype name.

As I told before, I would need to access this section of the ini file

[TM-EliminateAll UTUIDataProvider_MapInfo]
MapName=TM-EliminateAll
PreviewImageMarkup=UI_FrontEnd_Art.MapPics.___map-pic-ai-mission1
Description=TM-EliminateAll
FriendlyName=TM-EliminateAll

I have been searching this tutorial:

https://docs.unrealengine.com/udk/Th…ameSystem.html

This is close to what I need, as for saving the Items it uses the perobjectconfig

class SapituItem extends UTUIResourceDataProvider perobjectconfig;

It declares here the config variables, as they appear on the ini files:


/**
* The name of this item to show ingame.
*/
var config string DisplayName;

/**
* The description of the item
*/
var config string Description;

/**
* Name of the texture to use for the icon
*/
var config string icon;

However, the only problem, is that on the tutorial, it says:

"SapituItems are declared by hand. At runtime the should never change. To declare an item simply create a configuration file. And add an entry like this:

[sword1 SapituItem]
DisplayName=Short
sword level=(min=1,max=10)
weight=(base=10,levelMult=0.5)
value=(base=5,levelMult=1)"

If this tutorial teached how to declare the items via UnrealScript, I would know how to access the [TM-EliminateAll UTUIDataProvider_MapInfo] section.

Thanks!

You may already be aware of this, but when you save config values from Unrealscript, it will not update those in DefaultSomeFile.ini, but rather in UDKSomeFile.ini.

When you first boot the game, it will generate the UDK*.ini file from the Default*.ini files.

If you manually edit Default*.ini, it will re-generate the UDK*.ini file.

If you want to use (and save) config values in unrealscript classes, you need to setup your class like this:



class MyClass extends SomeOtherClass
config(MyIniFileName);


In this example, the .ini file would be called DefaultMyIniFileName.ini

Then any values you want to draw from the ini file, you define like this in class:



var config float SomeFloatVar;


Changing the var (and having thay var updated in the .ini file), you simply do like this:



function ChangeMyVar(float newVal)
{
    SomeFloatVar= newVal;
    SaveConfig();
}


However… I don’t think this is the best way to do what you need. Config vars are really meant for configuring your game setup, not for saving game state. Using them in the way you are describing will likely cause needless complexity if you want to save states across multiple maps, play-throughs, characters etc.

I would advise instead creating a class to manage these various gameplay stats, and then use class’Engine’.static.BasicSaveObject() and class’Engine’.static.BasicLoadObject() to save/load the class data to a local file. Then you can also expand on this by using JsonObject to serialize and nest other classes data into the same data.

Checkout the UDN “gem” for a simple SaveGame system: https://docs.unrealengine.com/udk/Th…ameStates.html

Hello my friend.

Thanks for the insight!

With the help of my brazillian comrade, Rod Lima (https://www.youtube.com/channel/UCM7…y3z4VdVysR1DQ/), the guy who remade Resident Evil 2 in UDK (many years before Capcom), I created this function (using some parts of the UTGFX class):


exec function SetImageMarkupByMapName(String InMapName, string newPreviewImageMarkup)
{
local int i;
local array<UDKUIResourceDataProvider> ProviderList;
local array<UTUIDataProvider_MapInfo> LocalMapList;

`log("SetImageMarkupByMapName(" @ InMapName @ ")");

// Get a list of all available maps.
class'UTUIDataStore_MenuItems'.static.GetAllResourceDataProviders(class'UTUIDataProvider_MapInfo', ProviderList);
for (i = 0; i &lt; ProviderList.Length; i++)
{
LocalMapList.AddItem(UTUIDataProvider_MapInfo(ProviderList*));
}

// Find the appropriate map, retrieve its image markup.
for (i = 0; i &lt; LocalMapList.Length; i++)
{
// Map names from Provider do not match capitalization in .INI files.
if (Locs(LocalMapList*.MapName) == Locs(InMapName))
{
`log("SetImageMarkupByMapName SET(" @ InMapName @ ")");

LocalMapList*.PreviewImageMarkup = newPreviewImageMarkup;
LocalMapList*.SaveConfig();
}
}
}


It works perfectly, but I wont use it, because on consoles it does not work. By calling this exec function on my kismet sequence, I can manually change the map image (it changes the ini files). However, as for consoles, the ini files get cooked inside the *.XXX files, and you can’t save this cooked files in run time.

I am now trying the Kismet Version of the UDK Save Game System (https://forums.unrealengine.com/lega…ve-load-kismet), maybe it can work on consoles also.

Cheers and thanks for this help.

[USER=“287012”]NIDAL NIJM GAMES[/USER] May I ask which consoles you’re running your game on?

Yes my brother. Just search on google:

https://www.google.com/search?q=udk+ultimate+engine

I was able to port UDK Engine May 2011 and make it run on PS3 and Xbox360. That’s a well known project, it stayed a long time online, from since 2015. But then EPIC Games got aware of this, and contacted me, explaining that I must not distribute my modified version of UDK Engine, as it goes against their EULA, however, they were very kind to me, allowing me to officially use my custom UDK Engine for developing and distributing my games.

I signed a standard Unreal Engine Commercial License, and now I am using my custom version of UDK Engine to develop this game for PC, PS3 and Xbox360:

https://www.indiedb.com/games/fursan…al-aqsa-mosque

However, many people here on this forum helped me with Unreal Scripting (my weakest point), like @Nathanael @CobaltUDK @Neongho @Coldscooter :smiley: @O_and_N @Chosker and many others.

I will release a demo until this weekend, and would like to receive some feedback from you all here on UDK Forums.

My game is getting a very good visibility arround the web, thanks to that project (UDK for Consoles), I became well known especially on Playstation Homebrew Community, made many friends there, I published about my game on thousands of forums, also thousands banned me because the political content of my game, but many allowed me to promote my game there, and even are helping me to promote my game.

Just search on google:

https://www.google.com/search?q=fursan+al+aqsa+game

I am very active on twitter, and made friendship with some important people of game press, here on Brazil, like IGN Brazil! They liked the concept of my game, and told me they will make a review for my game.

My game even won the first place on its category (3rd person shooter), on the 100 Best Upcoming Indie Games of 2019 in IndieDB website.

So I am very happy, however, I need to polish this demo, so the game will live up to people expectations.

Thanks!

[USER=“287012”]NIDAL NIJM GAMES[/USER] Ah I see. Those are last generation consoles though (about to be 2 generations behind), so it’s hard to justify the development effort in those ports against the potential sales on those platforms.

I understand you bro, but I have done it more for fun and for a personal achievement, I always desired to make a PS3 Game. About my game, It will be a PC Game, and the consoles version are kinda extra stuff, just for fun (also because I have many friends who want to play my game on their PS3).

About the save system, I did use the Kismet Save System and it is working like a charm on PC and Xbox360. As for PS3, I need to adjust somethings on the game executable to add write permissions, as for PS3 homebrew games, they need a specific flag on the EBOOT.BIN (game executable) to write data on PS3 HDD.

Cheers and thank you all for the help!