Home   Help Search Login Register  

Author Topic: Class eventhandlers  (Read 1312 times)

0 Members and 1 Guest are viewing this topic.

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Class eventhandlers
« on: 24 Dec 2004, 04:14:09 »
what exactly is the syntax for eventhandlers in the config (i searched the forums to almost 2 years back and it didn't help)
what i want is a fired EH

Offline Killswitch

  • Members
  • *
  • Peace, cheese and ArmA
Re:Class eventhandlers
« Reply #1 on: 24 Dec 2004, 07:45:48 »
The events available in OFP and in your EventHandler definintion are
  • init
  • dammaged   (yes, misspelled with two 'm':s)
  • engine
  • fired
  • fuel
  • gear
  • getin
  • getout
  • hit
  • incomingMissile
  • killed
Example using just four of them:
Code: [Select]
...
...
class MyVehicle {
        ...
        ...
        ...
        class EventHandlers
        {
                init   = "string with init code goes here";
                hit     = "code for hit EH";
                fired  = "fired code";
                killed = "aargh";
        };
        ...
        ...
};
...
...

               
« Last Edit: 24 Dec 2004, 07:48:45 by Killswitch »

sa8gecko

  • Guest
Re:Class eventhandlers
« Reply #2 on: 24 Dec 2004, 08:00:28 »
Inside the cfgVehicle class:
Code: [Select]
...
class eventHandlers
{
fired = " ...";
};
what exactly do you need ?
The 'fired' EH returns a five elements array: the first (_this select 0) is
the shooter, the last (_this select 4) is the ammo type being fired,
the other elements are the weapon being fired and its muzzle modes.
This array can obviously be used inside the EH itself, that is:

Code: [Select]
fired = "if ((_this select 4) == ""psy_mcar_dummyTow"") then {deleteVehicle (nearestObject [_this select 0, _this select 4]); ...};";this delete the bullet fired by the shooter if this happens to be "psy_mcar_dummyTow" type. Note the use of double quotes: they
are compulsory, otherwise OFP will return an error.

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Class eventhandlers
« Reply #3 on: 24 Dec 2004, 16:19:45 »
I'm makin a flashbang, so there is no cfg vehicles

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Class eventhandlers
« Reply #4 on: 24 Dec 2004, 16:59:44 »
nevermind, i just realized that won't work