BlacKnightBK 47 Posted November 13, 2017 Hello, I am using the following trigger to make players immune to damage within the trigger zone, but I would like the vehicles to be immune to damage too but unable to. Any help would be greatly appreciated. Thankshttps://gyazo.com/be7c55ef4780a71360eecbfb7f3ff123 Share this post Link to post Share on other sites
johnnyboy 3744 Posted November 13, 2017 Add this to OnActivation: vehicle player allowDamage false; Add this to OnDeactivation: vehicle player allowDamage true; Share this post Link to post Share on other sites
BlacKnightBK 47 Posted November 13, 2017 12 minutes ago, johnnyboy said: Add this to OnActivation: vehicle player allowDamage false; Add this to OnDeactivation: vehicle player allowDamage true; I do not just want the player vehicle to be immune but all the vehicles within the trigger until they leave Share this post Link to post Share on other sites
Muzzleflash 111 Posted November 13, 2017 This is actually quite involved to make work. 1. Do you need to support join-in-progress? 2. Will the vehicles only by driven into/out of the area by players (not AI)? If #2 is true. Then one way is, for all players (and server) when joining, go through all vehicles and players, and for those that are in the trigger area (inArea MyTrigger) you allowDamage false. Then on your trigger activation, you also have allowdamage false, for both the vehicle and the player. And on leaving you have allowdamage true for all players and the vehicle. Share this post Link to post Share on other sites
BlacKnightBK 47 Posted November 13, 2017 So there is no way for me to get the whole list of vehicles in the area at once? Hmm. Share this post Link to post Share on other sites
Muzzleflash 111 Posted November 13, 2017 2 minutes ago, BlacKnightBK said: So there is no way for me to get the whole list of vehicles in the area at once? Hmm. Well technically no, since I believe it the list only gives occupied vehicles. But in practice yes., but you have to do it manually using a separate script, by grabbing all objects in the area, and then filter them to ensure they are in the trigger. Worst case for a rectangle trigger you grab all objects in a radius encompassing the rectangle size, and filter them trough inArea. Share this post Link to post Share on other sites
johnnyboy 3744 Posted November 13, 2017 36 minutes ago, BlacKnightBK said: So there is no way for me to get the whole list of vehicles in the area at once? Hmm. I was just following your example screenshot. To do all vehicles do something like this (exact syntax untested): {vehicle _x allowdamage false} foreach thisList; thisList should be list of all units in the trigger area. Note that the screenshot you posted has a condition of "player in thislist". You may want to change that to "true" instead, so any units in the trigger area execute the code. Edit: @Muzzleflash is correct. My suggestion here would not cover unoccupied vehicles. For that you need to script a nearObjects check and more if they must be within the area of the trigger. Share this post Link to post Share on other sites
HazJ 1288 Posted November 14, 2017 { if ((_x inArea thisList)) then // or triggerName { _x allowDamage false; } else { _x allowDamage true; }; } forEach vehicles; Not tested! Share this post Link to post Share on other sites
BlacKnightBK 47 Posted November 14, 2017 Thanks, guys, I was informed that no vehicles will be within the area on server start, so I will add to the spawn script the disable damage since all vehicle will be spawned within, and once the player is leaving the damage will be enabled for both player and vehicle :) Share this post Link to post Share on other sites
pierremgi 4743 Posted November 14, 2017 There is a typo in HazJ solution (extra "in"), but on the way... if you, definitely, disregard thisList. thisList is weird in that case. thisList applied on anybody, will return empty car, crates, vehicles and foot units (but not the crew). And once your trigger is fired, you need to desarm it and rearm it to fire the code again. Instead of that trick, you can let none none (instead of anybody present) and just use the trigger (or marker, as well) for its area. So, using the trigger and scripting inside it, make this condition: true and run a code , looping for check by its own: 0 = thisTrigger spawn { while {true} do { _allUnits = allUnits select { !(_x getVariable [str(_this),false])}; _vehicles = vehicles select { !(_x iskindOf "weaponHolderSimulated") && !(_x getVariable [str(_this),false]) }; { _x setVariable [str (_this),true]; [_x,_this] spawn { params ["_unit","_trig"]; while {!isNull _unit} do { waitUntil {sleep 1; _unit inArea _trig}; _unit allowdamage false; waitUntil {sleep 1; !( _unit inArea _trig) }; _unit allowdamage true; }} } forEach (_allunits + _vehicles) } }; This code works for multiple trigger areas (code must be added on each activation field). Should work in MP. 1 Share this post Link to post Share on other sites
HazJ 1288 Posted November 14, 2017 Sorry, my bad. Thanks for pointing it out! @pierre MGI I have now corrected that in my previous post. Share this post Link to post Share on other sites