MitchJC 49 Posted July 24, 2018 Afternoon all, I'm after a bit of advice with calling postinit and preinit functions from a mod. I've created a mod which is basically a functions library. I have one rather inconvenient issue. My Postinit and preinit functions execute on Arma 3 start, for example: I have dynamic text appearing on the main menu, which whilst amusing, isn't particularly professional. My question: How do I execute postinit and preinit functions only on Mission start when called within a @mod? Thanks in advance! Share this post Link to post Share on other sites
HazJ 1288 Posted July 24, 2018 Example from mine: class CfgFunctions { class HazWSServer { class main { class postInit { postInit = 1; file = "HazWSServer\server\server_init.sqf"; }; }; }; class server { tag = "server"; class database { file = "\HazWSServer\server\functions\database"; class mysql_init {}; class mysql_connect {}; class mysql_query {}; class mysql_store_result {}; class mysql_free_result {}; }; }; }; I assume you have got your CfgPatches setup already. If not: class CfgPatches { class HazWSServer { name = "Haz's Wasteland - Server"; author[] = {"Haz"}; url = ""; requiredVersion = 1; requiredAddons[] = {"HazWSConfigs"}; units[] = {}; weapons[] = {}; }; }; Should get you started. 4 Share this post Link to post Share on other sites
MitchJC 49 Posted July 24, 2018 config.cpp class CfgPatches { class LRGFundamentals { units[]={}; weapons[]={}; requiredVersion=0.1; requiredAddons[] = {}; }; }; class CfgFunctions { #include "Functions\LRG\CfgFunctions.hpp" }; CfgFunctions.hpp class LR { tag = "LR"; class General { file = "LRG Fundamentals\Functions\LRG\General"; class Confirmation {postInit = 1;}; class Diary { postInit = 1; }; class initPlayerLocal {postInit = 1;}; class initServer {postInit = 1;}; class MedicalFacility {postInit = 1;}; class PlayerAddActions {}; class RealWeather {postInit = 1;}; class SafeZone {postInit = 1;}; class SideChat {postInit = 1;}; class TFAR {postInit = 1;}; class PilotCheck {postInit = 1;}; }; }; Hey HazJ, thanks for trying to help. Here's a copy of what I have so far. The functions work fine, other than executing at A3 start. Anything that has postinit or preinit is running as soon as the game launches. Is this intended? I thought prestart was for that outcome? None the less, I assume there must be something I need to put at the start of functions to ensure they only run post mission start. Anyone got any ideas? Share this post Link to post Share on other sites
Dedmen 2588 Posted July 25, 2018 15 hours ago, MitchJC said: I thought prestart was for that outcome? yes. preStart runs when the game launches. But I think you have the wrong definition for game launch there. Game == Arma. Meaning just after it goes fullscreen before the main menu. That is the game launch and that's when preStart fires. preInit runs before init.sqf and before objects are spawned. postInit runs when the mission is done intializing and generally after init.sqf What is your defintion of "as soon as the game launches" and "post mission start"? Share this post Link to post Share on other sites
MitchJC 49 Posted July 26, 2018 18 hours ago, Dedmen said: What is your defintion of "as soon as the game launches" and "post mission start"? So to answer your question, I'm wanting the postinit and preinit functions to operate on Mission Start. I have several functions that are required to run as soon as the server loads the mission or as the client joins. I've converted a mission template to a mod so it operated perfectly from within the mission folder. The issue is preinit and postinit functions are getting called from the main menu if called from within a mod. I get why as Arma 3 is effectively calling that mod on boot, hence why the functions are getting executed. I feel like there must be a simple way of telling the functions in the mod 'don't run until a mission starts' but have yet to come across how that's achieved. Share this post Link to post Share on other sites
Dedmen 2588 Posted July 26, 2018 1 hour ago, MitchJC said: The issue is preinit and postinit functions are getting called from the main menu if called from within a mod. Because the main menu background can be a mission. Before the new Main menu there was always a mission running in the background. Actually never thought about that problem. Also never experienced it myself. So I don't really know how one would fix that. Share this post Link to post Share on other sites
Leopard20 813 Posted July 16, 2019 If you guys are still interested, I found a solution for my own mod: if (allDisplays isEqualTo [findDisplay 0]) exitWith {}; 7 Share this post Link to post Share on other sites