HenPet 8 Posted May 15, 2021 Hey guys, I don't know what im doing wrong and can't find anser on google. I'm trying to add an eventHandler to the driver of a vehicle wich i spawned before: vehicleName= createVehicle [vehicleToSpawn, getMarkerPos "Marker", [], 0, "NONE" ]; createVehicleCrew vehicleName; deleteVehicle commander vehicleName; driver vehicleName addEventHandler ["HitPart", { (_this select 0) params ["_target", "_shooter", "_projectile", "_position", "_velocity", "_selection", "_ammo", "_vector", "_radius", "_surfaceType", "_isDirect"]; if ((_selection select 1) == "hit_head") then { hint "Head";}; if (((_selection select 1) == "hit_spine1") || ((_selection select 1) == "hit_spine2") ||((_selection select 1) == "hit_spine3")) then { hint "Torso";}; if ((_selection select 1) == "hit_neck") then { hint "Neck";}; if (((_selection select 1) == "hit_arms") || ((_selection select 1) == "hit_leftarm") ||((_selection select 1) == "hit_rightarm")) then { hint "Arm";}; if ((_selection select 1) == "hit_hands") then { hint "Hands";}; if ((_selection select 1) == "hit_pelvis") then { hint "Pelvis";}; if (((_selection select 1) == "hit_leftleg") || ((_selection select 1) == "hit_rightleg")) then { hint "Legs";}; if (((_selection select 1) == "hit_leftfoot") || ((_selection select 1) == "hit_rightfoot")) then { hint "Feet";}; }]; I don't know if the HitPart event handler doesn't work for mounted vehicles or if im doing something else wrong. I tried to get the name of the driver in many ways but none work. If I create an infantry unit the eventHandler works well. I would be happy if someone has an idea or a hint what I could search for. Thanks in advance. Share this post Link to post Share on other sites
pierremgi 4889 Posted May 15, 2021 aTank ? what is the common link with vahicleName? Same object? Share this post Link to post Share on other sites
HenPet 8 Posted May 15, 2021 yes changed the name for this post so its easier to read but forgot this one Share this post Link to post Share on other sites
pierremgi 4889 Posted May 15, 2021 You should try EH "hit" or EH "handleDamage" which work probably better for a unit inside a vehicle. Share this post Link to post Share on other sites
HenPet 8 Posted May 15, 2021 Thank you for your advice but ive got it to work. I messed something up while testing the parameters and thought I had to use select 1 I tested it again and found select 0 to be right for the driver as there is only one string in the _selection array. So if anybody wants the code here you go: driver vehicleName addEventHandler ["HitPart", { (_this select 0) params ["_target", "_shooter", "_projectile", "_position", "_velocity", "_selection", "_ammo", "_vector", "_radius", "_surfaceType", "_isDirect"]; if ((_selection select 0) == "head") then { hint "Head";}; if (((_selection select 0) == "spine") || ((_selection select 0) == "spine1") || ((_selection select 0) == "spine2") ||((_selection select 0) == "spine3")) then { hint "Torso";}; if ((_selection select 0) == "neck") then { hint "Neck";}; if (((_selection select 0) == "arms") || ((_selection select 0) == "leftarm") ||((_selection select 0) == "rightarm")) then { hint "Arm";}; if ((_selection select 0) == "hands") then { hint "Hand";}; if ((_selection select 0) == "pelvis") then { hint "Pelvis";}; if (((_selection select 0) == "leftleg") || ((_selection select 0) == "rightleg") || ((_selection select 0) == "leftupleg") || ((_selection select 0) == "rightupleg")) then { hint "Leg";}; if (((_selection select 0) == "leftfoot") || ((_selection select 0) == "rightfoot")) then { hint "Foot";}; }]; Share this post Link to post Share on other sites