View Full Version : Eventhandlers in configs.
nullsystems
Jun 15 2009, 10:50
Hi all,
Is there a way to add an eventhandler to all MAN class from an addon?
Sure, add it to the correct base class.
nullsystems
Jun 15 2009, 11:15
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?
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.
nullsystems
Jun 15 2009, 11:28
Like this?
class CfgPatches
{
class CAManBase
{
units[] = {};
weapons[]= {};
requiredVersion =0.1;
requiredAddons[]={};
};
};
class CfgVehicles {
class CAManBase {
class EventHandlers
{
INIT="hint ""test""";
};
};
};
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.
NeoArmageddon
Jun 15 2009, 11:34
@<hidden>
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.
nullsystems
Jun 15 2009, 11:38
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 ----------
@<hidden>
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.
.kju [PvPscene]
Jun 15 2009, 13:20
Please correct EH use:
class DefaultEventhandlers;
..
cfgVehicles
{
...
class UnitClass: ParentClass
{
...
class Eventhandlers: DefaultEventhandlers
{
...
};
};
};
nullsystems study the allInConfig (http://dev-heaven.net/repositories/browse/cmb/configs/A2/formatted) - it will help you for sure. :)
nullsystems
Jun 28 2009, 10:11
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?
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?
nullsystems
Jun 28 2009, 12:05
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 ""\@<hidden>\Addons\BFG.sqf""}];";
};
};
};
HeinBloed
Jun 29 2009, 11:19
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.
.kju [PvPscene]
Jun 29 2009, 12:33
Wait for XEH A2 version to be released.
DefaultEventhandlers are only used on vehicles, not on any man based class. ;)
So he actually did it right.
nullsystems
Jun 30 2009, 12:48
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.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.