Sideguy 0 Posted August 28, 2020 I'm trying to make a mission where the players are being transported to a base with helicopters, but then the helicopters would crash land. I want everyone except the AI pilots to survive. I was kinda successful in doing so by using two triggers, one that made the players invincible and a second one that made then vulnerable after a set time. The problem was that they were unconscious when the helicopter landed, and after the second trigger fired they all died in the fire. I'm using ace medical, so I think the allowDamage command works fully. I was also thinking of being able to teleport them outside of the vehicle and have them wake up, but I fear that it will either take too long for them to wake up or that they might get teled through the map. I also looked up and found this thread. I thought I might be doing everything wrong, and I was just making the players invincible and then vulnerable right before the helicopter exploded. I saw this line of code that supposedly makes players invincible in vehicles and has a blacklist on certain vehicles: Quote _unit = _this select 0; _unit addEventHandler ["HandleDamage",{ _unit = _this select 0; _vehicle = vehicle _unit; _checkVehicles = ["B_Parachute", ...]; if !((_unit == _vehicle) && (_vehicle in _checkVehicles)) exitWith {0}; }]; I don't understand what values I'd need to change, or what to even set this on. Also, someone said that this line of code had an error. I couldn't even begin to figure out what that error was and how to fix it. Does anyone have any clues? Share this post Link to post Share on other sites
Spriterfight 10 Posted August 29, 2020 _pilot = driver vehicle player If (vehicle player isTouchingGround) then { { _x setUncounsious true; _x allowDamage false _x action ["Eject", vehicle _x]; sleep 10; } forEach units groupName - _pilot; }; Share this post Link to post Share on other sites
Leopard20 813 Posted August 29, 2020 10 hours ago, Spriterfight said: _pilot = driver vehicle player If (vehicle player isTouchingGround) then { { _x setUncounsious true; _x allowDamage false _x action ["Eject", vehicle _x]; sleep 10; } forEach units groupName - _pilot; }; This code is full of all kinds of errors (5 lines out of 9 lines you wrote). 23 hours ago, Sideguy said: Also, someone said that this line of code had an error. I couldn't even begin to figure out what that error was and how to fix it. Does anyone have any clues? It appears to be a function that added some (broken) event handler, so it was proabbly executed like: [_someUnit] call THAT_fnc_addHandleDamage. You can put it in the init box of a unit, in which case you can just remove the first line and write: this addEventHandler [....................] The error is that the condition is wrong (I'm not sure what _checkVehicles were but I'm assuming they're the vehicle types that were allowed). It should've checked the type, not the vehicle itself: if ((_unit != _vehicle) && {typeOf _vehicle in _checkVehicles}) exitWith {0}; You can't use the handleDamage event handler if you're using ACE Medical. (ACE will return its own damage) I'm not sure what you were trying to do exactly, but this does what the title says: Add this to the init box of the heli: It makes any player unit that gets in invincible, and any unit (player and non player) that gets out becomes vulnerable. this addEventHandler ["GetIn", { params ["_heli", "", "_unit", ""]; _unit allowDamage !(isPlayer _unit); }]; this addEventHandler ["GetOut", { params ["_heli", "", "_unit", ""]; _unit allowDamage true; }]; If the units are in the vehicle at the start of the mission, add this to the init box of the units (or you can use {_x allowDamage false} forEach units this If you add it to the group's init box): this allowDamage false; 23 hours ago, Sideguy said: I don't understand what values I'd need to change, or what to even set this on You might want to learn some SQF programming before trying to make a mission that needs scripting. Share this post Link to post Share on other sites
Spriterfight 10 Posted August 29, 2020 39 minutes ago, Leopard20 said: This code is full of all kinds of errors (5 lines out of 9 lines you wrote). It appears to be a function that added some (broken) event handler, so it was proabbly executed like: [_someUnit] call THAT_fnc_addHandleDamage. You can put it in the init box of a unit, in which case you can just remove the first line and write: this addEventHandler [....................] The error is that, the condition is wrong (I'm not sure what _checkVehicles were but I'm assuming they're the vehicle types that were allowed). It should've checked the type, not the vehicle: if ((_unit != _vehicle) && {typeOf _vehicle in _checkVehicles}) exitWith {0}; You can't use the handleDamage event handler if you're using ACE Medical. I'm not sure what you were trying to do exactly, but this does what the title says: Add this to the init box of the heli: It makes any player unit that gets in invincible, and any unit (player and non player) that gets out becomes vulnerable. this addEventHandler ["GetIn", { params ["_heli", "", "_unit", ""]; _unit allowDamage !(isPlayer _unit); }]; this addEventHandler ["GetOut", { params ["_heli", "", "_unit", ""]; _unit allowDamage true; }]; If the units are in the vehicle at the start of the mission, add this to the init box of the units (or you can use {_x allowDamage false} forEach units this If you add it to the group's init box): this allowDamage false; Oh probably he wants the units to be unconscious and teleport them outside of the heli and then "wake" them up.Yeah i havent tested my code Share this post Link to post Share on other sites
JCataclisma 80 Posted July 12, 2023 Hello, guys! By trying and tracking this link and the previous ones, and also adding some stuff found on internet, I came to two slightly different approaches to it. Both of them work, at least on single player/mission editor. But one of my main goals is to have it running solely for MP dedicated server. I am running the code(s) bellow from a separated .sqf file, called from the init.sqf The problem remains the same for both: player will become invincible (which is desired) while inside ANY vehicle, not only in the ones from the specified classes. I don't mind whether I couldn't actually chose from a custom array of vehicles, but I'd be very happy if it worked only inside helicopters at least. Long in short, it remains ignoring the classes. { _heloClass = typeOf vehicle _x; if (_heloClass in ["B_Heli_Transport_03_F", "O_Heli_Transport_04_F", "I_E_Heli_light_03_dynamicLoadout_F"]) then { _x addEventHandler ["HandleDamage", { params ["_veh", "_source", "_selection", "_damage"]; if (_damage < 0) then { damage _veh; } else { _veh getHitIndex _damage; } }]; } } forEach allUnits; I believe this one is almost fully from forums here, and also works but for ANY vehicles: this addEventHandler ["HandleDamage", { _veh = _this select 0; if(vehicle _veh != _veh) then { if(_this select 5 < 0) then { damage _veh; } else { _veh getHitIndex (_this select 5); } } else { _this select 2; }; }]; Share this post Link to post Share on other sites