Jump to content
Sign in to follow this  
tomhighway

How to reuse code between missions?

Recommended Posts

I'd like to reuse scripting code and parts of the description.ext between missions with include preprocessor command. I've made a small client side mod called ndClient, started both the game and dedicated server with that mod.

I've created a mission with description.ext. In description.ext I've put a line like this

#include "\ndClient\Sd\description.h"

Hoping that it would go into added addon and fetch description.h file. Unfortunately, rpt log says it can't find that file.

File is placed in packed pbo @ndclient\addons\ndclient.pbo

Share this post


Link to post
Share on other sites

It's most likely that the issue is in your mod, and to be specific, a missing (or wrongly packed) $PBOPREFIX$ file.

 

Could you post the following?

 

- directory structure within ndclient.pbo

- the config.cpp in ndclient.pbo

- the $PBOPREFIX$ in ndclient.pbo

- the \Sd\description.h file which you try to include

 

This would help us to identify the issue for you.

Share this post


Link to post
Share on other sites

Thank you for replying.

 

I've changed few things but the weird issue - it works on local dedicated server set with TADST. It doesn't work on gameserver hosted dedicated server with mods turned on.

 

Here are the answers to your questions.

 

1. Directory structure within @ndClient folder

PS C:\Private\ND\server\@ndClient> dir


    Directory: C:\Private\ND\server\@ndClient


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----       25.10.2016.     10:30            addons
d----       25.10.2016.     10:30            keys


PS C:\Private\ND\server\@ndClient> cd .\addons
PS C:\Private\ND\server\@ndClient\addons> dir


    Directory: C:\Private\ND\server\@ndClient\addons


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---       25.10.2016.      8:50    1544977 ndClient.pbo
-a---       25.10.2016.      8:50        555 ndClient.pbo.nd.bisign

If I unpack the ndClient.pbo to another folder I have:

PS C:\Private\ND\server\ndClient> dir


    Directory: C:\Private\ND\server\ndClient


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----       25.10.2016.     10:33            sd
d----       25.10.2016.     10:33            sounds
-a---       25.10.2016.     10:33          9 $PREFIX$
-a---       20.10.2016.     18:30        146 config.cpp

2. config.cpp

class CfgPatches
 {
     class ndClient
     {
         units[] = {};
         weapons[] = {};
         requiredVersion = 0.1;
         requiredAddons[] = {};
     };
 };

3. $PREFIX$ (I've used that instead of $PBOPREFIX$ - Arma 3 uses it, CBA too).

nd\client

4. sd\description.h

respawn = 1; // BIRD
respawnDialog = 0;
disabledAI = 0;
debriefing = 1;
respawnTemplates[] = {"Spectator"};
disableChannels[] = { {0,false,true}, {1,false,true} };

ReviveMode = 1;                         //0: disabled, 1: enabled, 2: controlled by player attributes
ReviveUnconsciousStateMode = 0;         //0: basic, 1: advanced, 2: realistic
ReviveRequiredTrait = 1;                //0: none, 1: medic trait is required
ReviveRequiredItems = 1;                //0: none, 1: medkit, 2: medkit or first aid kit
ReviveRequiredItemsFakConsumed = 1;     //0: first aid kit is not consumed upon revive, 1: first aid kit is consumed
ReviveDelay = 30;                       //time needed to revive someone (in secs)
ReviveMedicSpeedMultiplier = 1;         //speed multiplier for revive performed by medic
ReviveForceRespawnDelay = 5;            //time needed to perform force respawn (in secs)
ReviveBleedOutDelay = 180;              //unconscious state duration (in secs)

class Header
{
	gameType   = Coop;          // DM, Team, Coop, CTI
	minPlayers = 1;            // min # of players the mission supports
	maxPlayers = 20;           // Max # of players the mission supports
};

corpseManagerMode = 1;
corpseLimit = 50;
corpseRemovalMinTime = 300;
corpseRemovalMaxTime = 1800;

class CfgDebriefing
{
	class End1
	{
		title = "AA destroyed";
		description = "Blufor wins.";
	};

    class End2
	{
		title = "Blufor are dead";
		description = "Opfor wins.";
	};

    class End3
	{
		title = "Out of time";
		description = "Opfor wins.";
	};
};

class CfgSounds
{
	sounds[] = {};

	class SpawnBlufor
	{
		name = "";
		// filename, volume, pitch
		sound[] = {"@ndClient\sounds\spawn_blufor.ogg", 0.5, 1};
		titles[] = {0,""};
	};

	class SpawnOpfor
	{
		name = "";
		// filename, volume, pitch
		sound[] = {"@ndClient\sounds\spawn_opfor.ogg", 0.5, 1};
		titles[] = {0,""};
	};

	class Suspense
	{
		name = "";
		// filename, volume, pitch
		sound[] = {"@ndClient\sounds\suspense.ogg", 0.5, 1};
		titles[] = {0,""};
	};

	class BluforWins
	{
		name = "";
		// filename, volume, pitch
		sound[] = {"@ndClient\sounds\blufor_wins.ogg", 1, 1};
		titles[] = {0,""};
	};

	class OpforWins
	{
		name = "";
		// filename, volume, pitch
		sound[] = {"@ndClient\sounds\opfor_wins.ogg", 1, 1};
		titles[] = {0,""};
	};
};

The way I try to include it in the mission is in mission description.ext. I've tried omitting \ on start but then it crashes the local dedicated server.

#include "\nd\client\sd\description.h"

author = "Highway";

OnLoadName 	= "Search and destroy";
OnLoadMission = "Search for the enemy vehicles and destroy one of them.";
loadScreen = "images\loadScreen.jpg";

overviewPicture = "images\loadScreen.jpg";
overviewText = "Search for the enemy vehicles and destroy one of them.";

class CfgFunctions
{
    class A3MT
    {
#include "functions\functions.h"
#include "features\functions.h"
    };
};

It's not logical that it works on my local PC dedicated server but doesn't on gameservers hosted one. Server report file for the mission says:

 8:54:10 Initializing Steam server - Game Port: 2302, Steam Query Port: 2303
 8:54:10 Steam AppId from steam_appid.txt: 107410
 8:54:10 Connected to Steam servers
ErrorMessage: Include file nd\client\sd\description.h not found.

Once again - thank you for your assistance.

Share this post


Link to post
Share on other sites

Thanks for the extra info, that really helps.

 

 

The $PREFIX$ file can only be used within mission PBO's, while addons use $PBOPREFIX$. So as I expected this is the issue why it can't be found ;)

 

 

I'm not 100% about this, but to be sure I would also do the following to make sure the mod gets loaded correctly:

- Create a mod.cpp file in the root of the mod (so \@ndClient\mod.cpp)

- Add the CfgMod {} class to the config.cpp within your (main) addon

 

See https://community.bistudio.com/wiki/Mod.cpp/bin_File_Formatfor more information about this.

 

 

 

And as a bonus: you also might take a look at the paths of the audio files in description.h ;)

1) As far as I can see the mod won't be loaded correctly, because it's not identified as such. To fix this you'll need to add 2 things:

1a) Create a mod.cpp file in the root of the mod (so \@ndClient\mod.cpp)

1b) Add the CfgMod {} class to the config.cpp within your (main) addon

 

See https://community.bistudio.com/wiki/Mod.cpp/bin_File_Formatfor more information about this.

Share this post


Link to post
Share on other sites

Thank you for reply. I will try that. But there is something fishy here.

 

How come does that work on local dedicated server then? I've tried, my friend tried and mission works.

 

I've tried also this - and it crashes the server. Start the game without mods.

 

1. create an empty mission - just one soldier (player)

2. add description.ext like this:
 

#include "\a3\missions_f_epa\Campaign\Missions\A_m01.Stratis\description.ext"

It's an asset from first SP campaign Survive.

 

3. export the mission to mpmissions and host it with local dedicated server (I recommend using TADST). It will work.

4. now put that thing on any hosted server - boom.

Dedicated server crashed with:

ErrorMessage: Include file a3\missions_f_epa\Campaign\Missions\A_m01.Stratis\description.ext not found.

 

Arma 3 can't find it's own assets?!

It works in preview. It's arma 3 asset from first campaign.

Share this post


Link to post
Share on other sites

I've tried the suggestion above, added mod.cpp and CfgMods in config.cpp - didn't help. Changed the $PREFIX$ to $PBOPREFIX$ (though cpbo just renames it to $PREFIX inside).

 

EDIT:

 

Is it possible that you can't include .h (or any other file) from addon if you're trying to do that in mission file (description.ext).

Share this post


Link to post
Share on other sites

I just some testing myself:

 

1) I created a new mission (F3 Mission Framework)

2) I moved the contents of description.ext (of mission, which worked without modifications) into description.h (in addon, from which I know it works)

3) I tried to run the mission

 

The result was that my game crashed, however this was because it couldn't do an include which was set in the describtion.h file (tried to include a script present in the mission).

 

This means that it is possible to include .h files from an addon into a mission, including configs.

 

 

It was on my local machine (and not a dedicated server), although based on my knowledge this shouldn't be an issue when both the mission file and mod/addon are present on the server and loaded correctly.

 

 

And if you take a look into \a3\missions_f_epa\Campaign\Missions\A_m01.Stratis\description.ext (the one you tried to include), it even contains includes to other mission settings within the PBO ;) So even A3 is doing it.

 

 

 

I still think it's a issue within the addon.

 

FYI; For my mod I use the Addon Builder to create the PBO's, which is part of the ArmA 3 Tools (available through Steam), but due some issues with it I do use some custom settings to make it work properly.

This includes manually setting the AddonPrefix, since it fails to read the $PBOPREFIX$ file.

 

 

BTW: you said it does work locally, but not on the dedicated server. Perhaps something very stupid, but did you load your addon at the server (with the -mod=@addon parameter) and performed a full restart?

Share this post


Link to post
Share on other sites

It works locally on dedicated server - but not on dedicated server hosted somewhere else. Also, it doesn't work on in-game hosted server (self-hosted) - crashes the game with error mentioned above.

 

#include in init.sqf functions very well though, on both servers. Who would know...

 

This is init.sqf

#include "features\init.sqf"
#include "\nd\client\sd\initClient.sqf"

So basically description.ext - I had to copy it from addon description.h. Sigh. :(

 

Thanks for your help. If you manage to create a working mission with description.ext including stuff from other mod, please post a link here.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×