Jump to content
Sign in to follow this  
nullsystems

Eventhandlers in configs.

Recommended Posts

Hi all,

Is there a way to add an eventhandler to all MAN class from an addon?

Share this post


Link to post
Share on other sites

class CfgVehicles {
class Land;	// External class reference
class Man : Land {
	class EventHandlers 
		{
		Fired="hint ""You Fired""";
		};
};
};

This doesnt show when I fire.

Where am I going wrong?

Share this post


Link to post
Share on other sites

I''m not sure, is Man the correct base class? Isn't it something like CAManBase? Also make sure you have the pbo, that creates this class in the requiredAddons array of your CfgPatches section.

Share this post


Link to post
Share on other sites

Like this?

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


class CfgVehicles {
class CAManBase {
	class EventHandlers 
		{
		INIT="hint ""test""";
		};
};
};

Share this post


Link to post
Share on other sites

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


class CfgVehicles {
class xy;
class CAManBase: xy {
	class EventHandlers 
		{
		INIT="hint ""test""";
		};
};
};

I'm not sure about the correct name of the addon where CAManBase is defined (I guess CACharacters) and I don't know the name of the parent class of CAManBase, so I called it xy... but this is how you should do it in general.

Share this post


Link to post
Share on other sites

@nullsystems

But if anybody makes another addon, that adds something to the CAManBase, your addon will be overwritten. If you wait for a new version of extendediniteventhandlers this would be easier.

Share this post


Link to post
Share on other sites

I have a script working with:

class CfgVehicles {
class Land;	// External class reference
class Man : Land {

Interesting.

---------- Post added at 12:38 PM ---------- Previous post was at 12:34 PM ----------

@nullsystems

But if anybody makes another addon, that adds something to the CAManBase, your addon will be overwritten. If you wait for a new version of extendediniteventhandlers this would be easier.

Wont the old one work anymore?

------------

Ive tried several methods now, there is a config here:

http://209.85.229.132/search?q=cache:hDF9iN4QVp8J:www.armaholic.com/forums.php%3Fm%3Dposts%26p%3D26003+CAManBase&cd=3&hl=en&ct=clnk&gl=uk&client=firefox-a

Even tried matching something like that, nothing works.

Edited by nullsystems

Share this post


Link to post
Share on other sites

Please correct EH use:

class DefaultEventhandlers;
..
cfgVehicles
{
...
class UnitClass: ParentClass
{
	...
	class Eventhandlers: DefaultEventhandlers
	{
			...
	};
};
};

nullsystems study the allInConfig - it will help you for sure. :)

Share this post


Link to post
Share on other sites

Surely there has to be a simpler way of adding an action to all "Man" class than waiting for someone to fix something?

This is STILL troubling me, can someone please help me out?

Share this post


Link to post
Share on other sites
Surely there has to be a simpler way of adding an action to all "Man" class than waiting for someone to fix something?

This is STILL troubling me, can someone please help me out?

If you don't want to or can't, create a config to handle the inheritance. You can always use a script:

//Get all the men at the start of a mission
_Processed=AllUnits;

//Add the user action
{_x  addAction ["Unit Action", "unit_action.sqf"]} ForEach _Processed;

//Run for ever
While {True} Do
{
//Remove any null objects
_Processed=_Processed-[ObjNull];

//See if there are any new men
_New=AllUnits-_Processed;

//We have some new men
If ((Count _New)>0) Then
	{		
	//Add the user action to the new men
	{_x  addAction ["Unit Action", "unit_action.sqf"]} ForEach _New;

	//Add the newly processed units to the list
	_Processed=_Processed+_New;
	};

//You probably don't have to run this loop that often?
Sleep 3;
};

Probably need to add some extra stuff to cull dead units, but you get the idea?

Share this post


Link to post
Share on other sites

It has to be a config im afraid.

I tried something similar to this, to make add the AddAction to pilots but it didnt work at all...

class CfgPatches {
class Null {
	units[] = {USMC_Soldier_Pilot};
	weapons[] = {};
	requiredVersion = 0.1;
	requiredAddons[] = {"CACharacters", "CAWeapons", "CAWeapons_Colt1911", "CAWeapons_AK", "CAWeapons_M1014", "CAWeapons_bizon", "CAWeapons_VSS_vintorez", "CAWeapons_Saiga12K", "CAweapons_ksvk", "CAweapons_m107"};
};
};

class CfgVehicles {
class Man;	// External class reference
class CAManBase : Man {};
class SoldierEB : CAManBase {};
class SoldierWB : CAManBase {};
       class USMC_Soldier_Base : SoldierWB {};
class USMC_Soldier_Pilot : USMC_Soldier_Base {
	scope = public;
	model = "\ca\characters2\USMC\usmc_soldier_pilot";
	portrait = "\Ca\characters\data\portraits\comBarHead_usmc_pilot_ca";

	class SpeechVariants {
		class Default {
			speechSingular[] = {"veh_pilot"};
			speechPlural[] = {"veh_pilots"};
		};

		class EN : Default {};

		class CZ {
			speechSingular[] = {"veh_pilot_CZ"};
			speechPlural[] = {"veh_pilots_CZ"};
		};

		class CZ_Akuzativ {
			speechSingular[] = {"veh_pilot_CZ4P"};
			speechPlural[] = {"veh_pilots_CZ4P"};
		};

		class RU {
			speechSingular[] = {"veh_pilot_RU"};
			speechPlural[] = {"veh_pilots_RU"};
		};
	};
	TextPlural = "$STR_DN_pilots";
	TextSingular = "$STR_DN_pilot";
	nameSound = "veh_pilot";
	displayName = $STR_DN_PILOT;
	accuracy = 3.2;	// accuracy needed to recognize type of this target
	camouflage = 1.6;	// how dificult to spot - bigger - better spotable
	sensitivity = 2.6;	// sensor sensitivity
	cost = 20000;
	weapons[] = {MP5A5, "NVGoggles", "Throw", "Put", "ItemMap", "ItemCompass", "ItemWatch", "ItemRadio"};
	magazines[] = {"30Rnd_9x19_MP5", "30Rnd_9x19_MP5", "30Rnd_9x19_MP5", "30Rnd_9x19_MP5", "30Rnd_9x19_MP5", "30Rnd_9x19_MP5", "SmokeShellRed", "SmokeShellGreen"};
	respawnWeapons[] = {MP5A5, "NVGoggles", "Throw", "Put", "ItemMap", "ItemCompass", "ItemWatch", "ItemRadio"};
	respawnMagazines[] = {"30Rnd_9x19_MP5", "30Rnd_9x19_MP5", "30Rnd_9x19_MP5", "30Rnd_9x19_MP5", "30Rnd_9x19_MP5", "SmokeShellRed", "SmokeShellGreen"};

	class HitPoints : HitPoints {
		class HitHead : HitHead {
			armor = 500.7;
		};

		class HitBody : HitBody {
			armor = 1;
			passThrough = 0.8;
		};
	};

	class Wounds {
		tex[] = {};
		mat[] = {"ca\characters\data\us_pilot_body.rvmat", "ca\characters\data\us_pilot_body_wound1.rvmat", "ca\characters\data\us_pilot_body_wound2.rvmat", "ca\characters\data\us_pilot_hhl.rvmat", "ca\characters\data\us_pilot_hhl_wound1.rvmat", "ca\characters\data\us_pilot_hhl_wound2.rvmat"};
	};
	class UserActions {
		class BFG {
			displayName = "Enable BFG";
			onlyForPlayer = "true";
			position = this;
			radius = 0.5;
			condition = "alive player";
			statement = "hint ""BFG Enabled""; player addEventHandler [""fired"", {_this execVM ""\@Test\Addons\BFG.sqf""}];";

		};
	};
};

Share this post


Link to post
Share on other sites

Eventhandlers does not work the easy way like in Arma. Because BIS is using eventhandlers on many units. If you want to add an eventhandler you have to combine your eventhandler with the BIS ones. And there are many config files in this game.

Share this post


Link to post
Share on other sites

Wait for XEH A2 version to be released.

Share this post


Link to post
Share on other sites

DefaultEventhandlers are only used on vehicles, not on any man based class. ;)

So he actually did it right.

Share this post


Link to post
Share on other sites

I now have this working, but of course if the eventhandler is overwritten by the mission, it wont work. Not too much of a worry right now.

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  

×