sasha013 225 Posted May 14, 2017 Hi, is there any way to trigger 'setCaptive true' only if certain conditions are met? Basically I want it to trigger it 'True' ONLY if the player is disguised as a CSAT helicopter pilot, wearing: Quote this forceAddUniform "U_O_PilotCoveralls"; this addItemToUniform "FirstAidKit"; this addItemToUniform "SmokeShellRed"; this addItemToUniform "SmokeShellOrange"; this addItemToUniform "SmokeShellYellow"; this addBackpack "B_Parachute"; this addHeadgear "H_PilotHelmetHeli_O"; this addGoggles "G_Balaclava_TI_blk_F"; this linkItem "ItemMap"; this linkItem "ItemCompass"; this linkItem "ItemWatch"; this linkItem "ItemRadio"; I have been reading methods via this post but any further help would be welcome. Thanks! Share this post Link to post Share on other sites
Belbo 462 Posted May 14, 2017 Try this script I made a while ago. It offers additional functionalities und basically just checks for the uniform (given that the colour of your smoke grenades shouldn't really matter in terms of your undercover status). https://github.com/Pergor/ADV_MissionTemplate/blob/master/public/fn_undercover.sqf #edit: Oh, I see right now that I've added additional functions to this script that aren't included. That's a bit lame, i'll try to rectify that. #edit2: There: https://github.com/Pergor/ADV_MissionTemplate/tree/master/public/undercover Just place the undercover-folder in your mission and call it via init.sqf: [player] call compile preprocessFileLineNumbers "undercover\fn_undercover.sqf"; CBA is needed for that to work though. 1 Share this post Link to post Share on other sites
sasha013 225 Posted May 15, 2017 11 hours ago, belbo said: Try this script I made a while ago. It offers additional functionalities und basically just checks for the uniform (given that the colour of your smoke grenades shouldn't really matter in terms of your undercover status). https://github.com/Pergor/ADV_MissionTemplate/blob/master/public/fn_undercover.sqf #edit: Oh, I see right now that I've added additional functions to this script that aren't included. That's a bit lame, i'll try to rectify that. #edit2: There: https://github.com/Pergor/ADV_MissionTemplate/tree/master/public/undercover Just place the undercover-folder in your mission and call it via init.sqf: [player] call compile preprocessFileLineNumbers "undercover\fn_undercover.sqf"; CBA is needed for that to work though. Thanks a lot mate, appreciate the feedback. I will give this a go tonight as I'm at work right now. I confess I would've preferred a Vanilla script but I'll gladly try it out. Share this post Link to post Share on other sites
Belbo 462 Posted May 15, 2017 37 minutes ago, sasha013 said: Thanks a lot mate, appreciate the feedback. I will give this a go tonight as I'm at work right now. I confess I would've preferred a Vanilla script but I'll gladly try it out. The fn_undercover.sqf function can be quite easily rewritten to include while-loops instead of cba-evhs and the wonderful cba_fnc_waitUntilAndExecute. The CBA functions reduce the performance cost of such a script enormously, but they're technically not needed. Share this post Link to post Share on other sites
sasha013 225 Posted May 15, 2017 5 hours ago, belbo said: The fn_undercover.sqf function can be quite easily rewritten to include while-loops instead of cba-evhs and the wonderful cba_fnc_waitUntilAndExecute. The CBA functions reduce the performance cost of such a script enormously, but they're technically not needed. Could you give me more details on how to go about it? Not asking you to rewrite the whole script, just an example maybe, to point me in the right direction. I'm new in the scripting world and would appreciate the help! Share this post Link to post Share on other sites
Belbo 462 Posted May 15, 2017 Well, think it like this: [{testVar isEqualTo 1},{ hint format ["testVar is now %1.",testVar]; },[]] call cba_fnc_waitUntilAndExecute; Is more or less the same as: [] spawn { waitUntil {testVar isEqualTo 1}; hint format ["testVar is now %1.",testVar]; }; I use cba_fnc_waitUntilAndExecute only for this: adv_undercover_scriptfnc_switch_tooclose = { [ { ( !isNull ([player,8] call adv_fnc_findNearestEnemy) ) || (player getVariable ["adv_undercover_tooClose",false]) }, { params ["_unit"]; [_unit, false] call adv_undercover_scriptfnc_setCaptive; },[player]] call CBA_fnc_waitUntilAndExecute; }; That could be rewritten like: adv_undercover_scriptfnc_switch_tooclose = { _this spawn { waitUntil { sleep 1; ( !isNull ([player,8] call adv_fnc_findNearestEnemy) ) || (player getVariable ["adv_undercover_tooClose",false]) ) }; [player, false] call adv_undercover_scriptfnc_setCaptive; }; }; But that won't gain you much, since the script relies on the cba-player-evhs. That's a bit more complex to write. You could try instead of: adv_undercover_scriptevh_uniform = ["loadout", {[_this select 0] call adv_undercover_scriptfnc_switch_uniform}] call CBA_fnc_addPlayerEventHandler; Something along these lines: adv_undercover_scriptevh_uniform = [] spawn { while {true} do { waitUntil {sleep 1; (toUpper uniform player) in adv_undercover_uniforms}; [player, true] call adv_undercover_scriptfnc_setCaptive; [player] call adv_undercover_scriptfnc_switch_tooclose; waitUntil {sleep 1; !((toUpper uniform player) in adv_undercover_uniforms)}; [player, false] call adv_undercover_scriptfnc_setCaptive; }; }; That's at least something you could do for the uniforms. Everything else, like the vehicle and weapon handling are not really something that you could implement without larger hassle. 1 Share this post Link to post Share on other sites
sasha013 225 Posted May 15, 2017 Thanks @belbo, appreciate the help! Will let you know how it works out then. Share this post Link to post Share on other sites
Belbo 462 Posted May 16, 2017 I made a version that works without cba, but it's a bit wonky at times: https://github.com/Pergor/ADV_MissionTemplate/tree/master/public/undercoverNOCBA You can take it or try to develop your own version of it. :) 2 Share this post Link to post Share on other sites
sasha013 225 Posted May 16, 2017 59 minutes ago, belbo said: I made a version that works without cba, but it's a bit wonky at times: https://github.com/Pergor/ADV_MissionTemplate/tree/master/public/undercoverNOCBA You can take it or try to develop your own version of it. :) Cheers mate, will give it a go as well! Share this post Link to post Share on other sites