froggyluv 2135 Posted September 5, 2018 For some reason getting In and Out of loops sends my brain into a circular maze of logic that i cant get out of. So want to have an eventhandler call only Special Forces Soldiers to play an animation Roll on the ground via a firedNear EH but only want to allow it every 30 seconds or so -as of now they go nuts spam rolling almost every shot {if (_x in Frog_SpecialF) then { \\\\\\\Frog_SpecialF is Array of all Special Force units _x addEventHandler ["Firednear", {[_this select 0] call Frog_Roll}]; };} foreach allunits; Frog_Roll = { _target = _this select 0; _shooter = _this select 1; _hasEvaded =_target getVariable ["hasEvaded", false]; if (side _shooter == side _target) exitWith {}; if (random 100 > 70) exitWith {}; _name = name _target; _rolls = selectRandom ["amovppnemstpsraswrfldnon_amovppnemevaslowwrfldr","amovppnemstpsraswrfldnon_amovppnemevaslowwrfldl"]; _target switchmove "amovppnemstpsraswrfldnon_amovppnemevaslowwrfldr"; if ((!(_target in Frog_Hush) && !(_hasEvaded) && (stance _target == "Prone"))) then {systemchat format [ " %1 Calling Rolling Now!!", _name]; _target setVariable ["hasEvaded",true];_target switchmove _rolls;0 = _target execvm "ego\ego\scripts\freeMe.sqf" } /* else {_target setVariable ["hasEvaded",true];_target setvelocity [2, 0, 0]; _target switchmove "ActsPercMrunSlowWrflDf_FlipFlopPara"; systemchat "tumblin down";0 = _target execvm "ego\ego\scripts\freeMe.sqf" } */; frog_Hush pushback _this; }; Pretty sure im not using the setVariable hasEvaded properly. freeMe.sqf \\\\\\ Hoping to use as a 30 second timer to make the hasEvaded False again so they are once again free to Roll sleep 30; _target = _this; _target setVariable ["hasEvaded",false]; systemchat "This one freed"; Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted September 6, 2018 Here's how you can do a simple time based lockout: test addEventHandler ["Firednear", {[_this select 0] call Frog_Roll}]; Frog_Roll = { params ["_target","_shooter"]; _lockoutTime = 5; _lastLockout = _target getVariable ["GOM_fnc_lockout",-_lockoutTime];//so it returns -5 as default, initially enabling the roll if (time < _lastLockout + _lockoutTime) exitWith {false}; //at this point the last lockout was more than 5 seconds ago, so we save the current lockout time on the unit, then roll _target setVariable ["GOM_fnc_lockout",time,true]; _rolls = selectRandom ["amovppnemstpsraswrfldnon_amovppnemevaslowwrfldr","amovppnemstpsraswrfldnon_amovppnemevaslowwrfldl"]; _target switchmove "amovppnemstpsraswrfldnon_amovppnemevaslowwrfldr"; }; Pretty straightforward, heh. Cheers 5 Share this post Link to post Share on other sites
froggyluv 2135 Posted September 6, 2018 _lastLockout = _target getVariable ["GOM_fnc_lockout",-_lockoutTime]; Now see im always confused thinking you cant retrieve a Variable ie GOM_fnc_lockout before its been set ie setVariable.. One of these days ill have to pony up and start using params, they seem all the rage nowadays with todays hipsters. Thanks again Old Man -this actually helps me on alot of fronts and excess scripts 2 3 Share this post Link to post Share on other sites
HazJ 1289 Posted September 6, 2018 1 hour ago, froggyluv said: they seem all the rage nowadays with todays hipsters. 1 Share this post Link to post Share on other sites