OFPEC Forum

Addons & Mods Depot => OFP - Addons & Mods General => Topic started by: Triggerhappy on 24 Dec 2004, 04:14:09

Title: Class eventhandlers
Post by: Triggerhappy 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
Title: Re:Class eventhandlers
Post by: Killswitch on 24 Dec 2004, 07:45:48
The events available in OFP and in your EventHandler definintion areExample 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";
        };
        ...
        ...
};
...
...

               
Title: Re:Class eventhandlers
Post by: sa8gecko 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.
Title: Re:Class eventhandlers
Post by: Triggerhappy on 24 Dec 2004, 16:19:45
I'm makin a flashbang, so there is no cfg vehicles
Title: Re:Class eventhandlers
Post by: Triggerhappy on 24 Dec 2004, 16:59:44
nevermind, i just realized that won't work