Jump to content

Recommended Posts

Hey there!

 

I was wondering if there was a way to pack scripts into a mod and initialize them whenever the player beginns a mission in single or multiplayer. If tried it with this:

class CfgVehicles
{
	class Land;
	class Man : Land
	{
		class UserActions
		{
			class acms
			{
				displayName="acms";
				position="player";
				onlyforplayer=1;
				radius=1.0;
				condition="this == player";
				statement="[] execVM ""ACMS\init.sqf""";
			};
		};
	};
	class All {};
	class Static: All {};
	class Building: Static {};
	class NonStrategic: Building {};
	class TargetTraining: NonStrategic {};
	class TargetGrenade: TargetTraining {};
};

and also with this:

class cfgvehicles
{
class Logic;


    class ACMS_Name  : Logic
    {
        displayName = "ACMS";
        icon = "\ca\ui\data\icon_functions_ca.paa";
        picture = "\ca\ui\data\icon_functions_ca.paa";
        vehicleClass = "Modules";

        class Eventhandlers  {
            init = "(_this select 0) execvm ""init.sqf"" ";
        };
    };

};

which is a part of this forum topic: http://www.ofpec.com/forum/index.php?topic=35205.0

 

It would be okay if the player would have to Press a button like F7 or smth like that but not have to change anything in the mission.

 

I don't know any other way to do this. I am new in the modding scene altough i know the basics and more of scripting.

 

I really do hope that someone can help me with my prolem. :)

Share this post


Link to post
Share on other sites

I guess you're looking for the following way to add actions or the like to the Man class:

 

class CfgVehicles
{
        class Land;
        class Man: Land
        {
                class EventHandlers
                {
                        class UNS_radio_man
                        {
                                init = "_this call uns_radio_addaction";
                        };
                };
        };
};

 

Another path would be to add a module that does implement the needed logic, but then you need to sync units or groups against the module as mission editor.

 

TeTeT

  • Like 1

Share this post


Link to post
Share on other sites

Thank you for the reply! Now I've used your version but changed some of the text to look like this:

class CfgVehicles
{
        class Land;
        class Man: Land
        {
                class EventHandlers
                {
                        class Init
                        {
                           init = "[]execVM "init.sqf"";
                        };
                };
        };
};

But now when I start Arma with the Mod i geht the Error Message

Quote

File acms\config.cpp, line 9:'/CfgVehicles/Man/Eventhandlers/Init.init':'.' encountered instead of '='

 

Share this post


Link to post
Share on other sites

Try to use single quotes around init.sqf:

 

init = "[]execVM 'init.sqf'";
  • Like 1

Share this post


Link to post
Share on other sites

Thank you for the reply! It partially worked ^^.Now I don't get any error messages anymorge but it seems like the init.sqf is not getting initialized. I'm gonna explain a bit more what my intentions are so you can understand my problem a bit better (hope it helps ^^). this is what is in my init.sqf:

vehicle player addEventHandler ["IncomingMissile", {_projectile = _this select 1; _enemy = _this select 2; [_projectile, _enemy] execVM "newassignment.sqf";}];

So. What i wanted to do is that when the player starts a mission (without having to initialize anything in the editor or smth like that), this init script gets activated so when the player gets shot with a missile the newassignment.sqf gets executed (All of the scripts would work. I have tested that). But when I activate the mod and start a mission, absolutely nothing happens when I get shot with at with a tracking missile.

 

Hope that this helps and also hope that you can help me. :P

 

Edit: Jetz am Schluss is mir aufgefallen, dass du auch "schätze ich mal" Deutscher bist also können wir ja jetz Deutsch reden, da es vllt einfacher wäre ^^

Share this post


Link to post
Share on other sites

Do all of the players start off in vehicles?

 

If not, then you are adding the EH to the players (men/women etc)

 

btw:  don't use "init.sqf" as a script name.  It could confuse Arma, as it already looks for init.sqf when the mission starts, so maybe call your script "Mike_init.sqf" or something like that

  • Like 2

Share this post


Link to post
Share on other sites

The players are in vehicles. I now have used this in my "Mike_init.sqf":

[]spawn
{
player globalChat "Test";
vehicle player addEventHandler ["IncomingMissile", {_projectile = _this select 1; _enemy = _this select 2; [_projectile, _enemy] execVM "weaponfire.sqf";}];
};

but still nothing happens :/. I now feel like I'm one of the most stupid people on earth :dontgetit:

Share this post


Link to post
Share on other sites

The biggest problem with event handlers is the fact that it's too specific on when they are executed, while your question is too global to give a perfect answer.

 

And for some reason there are no (scripted) events available which trigger on mission load and/or player spawn (like init.sqf and initPlayerLocal.sqf in a mission).

 

However there is way!!!!

 

add this to your config.cpp in the addon (addon.pbo)

class CfgFunctions
{
	class myTag
	{
		class myCategory
		{
			// call the function upon mission start, after objects are initialized.
			class postInit
			{
				postInit = 1;
				file = 'functions/postInit.sqf';
			};
		};
	};
};

functions/postInit.sqf

// execute all scripts to non-player objects

// make sure the player is in-game and available
waitUntil {!isNull player};

// execute any scripts you want to the player

 

Of course you can extend this to anything you want, although it really depends on WHAT and WHEN.

 

 

sources:

https://community.bistudio.com/wiki/Functions_Library_(Arma_3)#Attributes

https://community.bistudio.com/wiki/Initialization_Order

https://community.bistudio.com/wiki/player (see comments)

  • Thanks 1

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

×