Advertisement

Author Topic: Making a mod that automatically adds an eventHandler to all units  (Read 910 times)

0 Members and 1 Guest are viewing this topic.

Offline Lone~Wolf

  • Mission Tools & Mods
  • Members
  • *
  • Vladimir Dmitri Mikhail Andreevich Stamenov
Hi again guys,

I've got a problem that's driving me bananas. I've got a script that I want to run for every Man type unit whenever they get hit. So I want to put an eventHandler on all Man type units globally.
I want to do this as part of a mod so it runs on all missions, so for example I could run the mod with "-mod=@blahblah" and then open Trial By Fire or some other vanilla mission and the eventhandler would be applied to all units there.

I've spent five hours trying to solve this and I've reverse engineered tons of other mods to see how they do it and nothing I do seems to work, even when it seems to be the same code as other people's mods.

Please help me here, I'm going mad.
Snarling creature, lurking in the background, still writing in .sqs

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
It's not that hard I reckon..
What Arma is different from OFP is that it's pretty anal about inheritance, so you have to make the addon dependant on CACharacters so that the class CAManBase gets loaded up first, then you 'edit' that class as all men inherit from it..

Anyway, this should work  :dunno:

Code: [Select]
#define ReadAndWrite 0
#define ReadAndCreate 1
#define ReadOnly 2
#define ReadOnlyVerified 3

#define private 0
#define protected 1
#define public 2

#define true 1
#define false 0

class CfgPatches {
class sometestcrapo {
  units[]={};
  weapons[]={};
  requiredVersion=1.00;
  requiredAddOns[]={"CACharacters"};
  };
};

class CfgVehicles {
class CaManBase {
class EventHandlers {
init="[]spawn{sleep 1; hint 'WEE'}";
};
};
};

EDIT:
Also went all moderator and moved this to a more suitable place :P
« Last Edit: 11 Aug 2015, 15:43:25 by h- »
Project MCAR   ---   FWW2 - Finland At War 1939-1945
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.