Preywinder   3 Posted September 6, 2021 Hi Chaps.  Been looking around and found various suggestions but unable to find a solution to this little problem. In my ignorance I was hoping simply putting "Cooldown = 600" in the trigger would sort it, but alas, it's never quite that simple 😛  Essentially the trigger calls a script which then spawns 3 rifleman and a mortar round in the middle of them (it's basically a battlefield casualty drill). The trigger works, the script works, but what I need is for the trigger to only be able to fire once every 10 minutes.  Trigger is simply this... Condition: this On Act: execVM "bravo4casualties.sqf"; On Deact:  Script as follows... if (isServer) then { _BravoCasualty41 = [getmarkerpos "BC41", WEST, ["CUP_B_BAF_Soldier_Rifleman_MTP"],[],[],[],[],[],200] call BIS_fnc_spawnGroup; _BravoCasualty42 = [getmarkerpos "BC42", WEST, ["CUP_B_BAF_Soldier_Rifleman_MTP"],[],[],[],[],[],30] call BIS_fnc_spawnGroup; _BravoCasualty43 = [getmarkerpos "BC43", WEST, ["CUP_B_BAF_Soldier_Rifleman_MTP"],[],[],[],[],[],110] call BIS_fnc_spawnGroup; }  As I say I did try a few suggestions where other people were trying similar things but no joy 😞 Share this post Link to post Share on other sites
Schatten   287 Posted September 6, 2021 @Preywinder, use this condition: this and { (time - (thisTrigger getVariable ["ActivatedAt", 0])) >= 10 * 60 } Also add this line into "On act." field: thisTrigger setVariable ["ActivatedAt", time];  2 1 Share this post Link to post Share on other sites
Preywinder   3 Posted September 6, 2021 18 minutes ago, Schatten said: @Preywinder, use this condition: this and { (time - (thisTrigger getVariable ["ActivatedAt", 0])) >= 10 * 60 } Also add this line into "On act." field: thisTrigger setVariable ["ActivatedAt", time];   Perfect. This works. Many thanks!  My understanding of the language is not good enough to put the pieces together by myself, but I can work out what each part of the condition and on act. mean by reading them. Share this post Link to post Share on other sites
pierremgi   4863 Posted September 6, 2021  Rearming a trigger (repeatable of course). Classic way: in cond field: this && isNil "blabla" in activ. field: your code; blabla = TRUE in deact: [] spawn {sleep 60; blabla = nil}  This way, the trigger is rearmed after 60 sec. So, if the condition are met, the trigger will fire again. Note 1: the condition stays checked every 0.5 sec which can be resource demanding on convoluted one (with allunits and so on) Note 2: if you need to rearm fast (for example treating all grouped units entering in a trigger), you can even deact without spawning and sleeping: blabla = nil.  Cooling down a trigger. That doesn't mean you rearm it! If condition stays met (the trigger is not deactivated), the trigger doesn't fire again! in condition field or in on act field, just add an interval. Examples: thisTrigger setTriggerInterval 600; this This way the trigger is immediately cooled down! or in on act. field: thisTrigger setTriggerInterval 600; your code This way the trigger is cooled down only after the first activation. That can be fine, especially for triggers supposed to fire not too late in scenario. (the condition is checked every 0.5 sec, then every 600 sec. after the first activation) Notes: - the repeated trigger interval doesn't hurt at all and it's far more resource saving than any other code. - Of course in a scripted trigger, you just have to run this setting once, without any link with the condition, as any other trigger's setting (area,text...).  You can of course mix the rearming and the cooldown. In this case, no need to add a sleep: in cond. field: this && isNil "blabla" in act. field: thisTrigger setTriggerInterval 600; your code; blabla = TRUE in deact field: blabla = nil  Have fun! EDITED: for radio triggers, see below. 2 1 Share this post Link to post Share on other sites
kibaBG   53 Posted November 16, 2022 @pierremgi Sorry for my incompetence, what is "blablabla" replacing? The name of the trigger?@Schatten How can I make this to work with radio triggers? this and { (time - (thisTrigger getVariable ["ActivatedAt", 0])) >= 10 * 60 } thisTrigger setVariable ["ActivatedAt", time];  Share this post Link to post Share on other sites
Harzach   2517 Posted November 17, 2022 2 hours ago, kibaBG said: what is "blablabla"  A boolean variable. You can change it to whatever you want - "myTriggerVariable", "iLikePancakes", "yourMomIsSoFat", etc. 1 Share this post Link to post Share on other sites
pierremgi   4863 Posted November 17, 2022 9 hours ago, kibaBG said: @pierremgi Sorry for my incompetence, what is "blablabla" replacing? The name of the trigger?@Schatten How can I make this to work with radio triggers? this and { (time - (thisTrigger getVariable ["ActivatedAt", 0])) >= 10 * 60 } thisTrigger setVariable ["ActivatedAt", time];    Radio triggers are specific: there is no deactivation code!  So, Schatten's code works as you don't need it, on the contrary of the variable method I wrote above: in cond. field: this && {time - (thisTrigger getVariable ["ActivatedAt",0]) > 10} for 10 sec deact here  in on act. field: your code; thisTrigger setVariable ["ActivatedAt", time];   1 Share this post Link to post Share on other sites
kibaBG   53 Posted February 12 @pierremgi Unfortunately I cannot make your code work ... I am trying to add cool time to radio trigger. Share this post Link to post Share on other sites
pierremgi   4863 Posted February 13 On 2/12/2024 at 3:37 AM, kibaBG said: @pierremgi Unfortunately I cannot make your code work ... I am trying to add cool time to radio trigger.  Schatten's code works for me.  You need to wait for the delta time you set (here 10 sec), even at start. Cond. : this && {time - (thisTrigger getVariable ["ActivatedAt",0]) > 10}  example on act: thisTrigger setVariable ["ActivatedAt", time]; hint str time  As said above, my code works only for repeatable triggers except for radio triggers which don't have deactivation code.   Share this post Link to post Share on other sites
BarLo_NLD   0 Posted October 3 (edited) what am i doing wrong here? without the timers everything worked, im still pretty new to coding hopeflly theres someone that can help EDIT figured it out, i swear i spend way to many hours on tis, First of all call function didnt work somehow in this script, so condition was changed, then becouse the other perosn (variable) didnt exist in the world until someone was actually in that slot (and i was testing alone) it didnt wanna work. aka ima rookie making rookie mistakes  Edited October 3 by BarLo_NLD worked it out somehow after spending 4 more hours Share this post Link to post Share on other sites