SpeedSter

How to override existing class values?

3 posts in this topic

New to sqf and have experience in cpp. I have written a server side exile addon and want to store my defined values (class member variables) in the addons config.cpp, instead of the mission or server_config config.cpp. For example accessing a defined value or class member is done as such, configFile >> "CfgSettings" >> "SomeClass" >> "somesetting"; or for mission config.cpp using missionConfigFile. My config.cpp is stored in myaddon.pbo. I want to do this without making the values global variables, or by passing local variables as parameters to another function. Hopefully, someone can shed some light on this, or maybe I am going about this the wrong way. Basically what I am trying to do is either add variables to an existing class, such as class Time or class Weather, define my own class, or use class inheritance, and add my variables in through the addons config.cpp, so that they can be accessed by my newly added functions. Instead of users having to add my variables to the main config, they can just install the addon and edit the config.cpp in the addon pbo

Edit: Not going to lie, but I had made a change earlier and published it to my server and noticed later some log output showing it working. I just made a single class with no base class or parent, put in my config.cpp "configFile >> "MyClass" >> "variable;" and it worked. I'm guessing exile or the game code merges config files at some point? I must have been using class inheritance wrong earlier.

Edit2: In my addons config.cpp. How do I override the existing "class Time" variables and add my own variables in. Can I only override existing variables of the Time class and need create my own class for my new variables? In other words, say I am making a time addon that depends on the exile_server_config time settings and want to centralize those settings with my addon time settings.

This is how I have tried to do it:

class CfgSettings;
class Time : CfgSettings
{
	// Uses Dedicated Server time as ingame Time
	useRealTime = 0;

	// Will overide RealTime
	useStaticTime = 1;

	// time in ARMA FORMAT << CONFIG
	// https://community.bistudio.com/wiki/setDate
	staticTime[] = {2039,10,24,8,0};
	
	// My inserted values
	newvalue = 0;
	anothernewvalue = 1;
};

Edit3: I must have been looking at code for too long. Anyway I got it working as I had originally done it. This will override the original time values and add my own in. Another way is to make my own class with CfgSettings as parent.

class CfgSettings
{
	class Time
	{
	// Uses Dedicated Server time as ingame Time
	useRealTime = 0;

	// Will overide RealTime
	useStaticTime = 1;

	// time in ARMA FORMAT << CONFIG
	// https://community.bistudio.com/wiki/setDate
	staticTime[] = {2039,10,24,8,0};
	
	// My inserted values
	newvalue = 0;
	anothernewvalue = 1;
	};
};

 

Edited by SpeedSter
Solved

Share this post


Link to post
Share on other sites

If you want to store stuff in the exile_client config you need to make another mod. (pointless). either store it in the server or the mission file.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks Mezo, I already had my addon settings in my exile_server_config, but I wanted to move those settings to my server addon config.cpp. I probably fat fingered some code or forgot to save some file before packing. However, it is working now as an addon, which is nice because it centralizes the time settings in my addon.

Share this post


Link to post
Share on other sites
Advertisement

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.