Bad_Dad 4 Posted December 19, 2022 so looking for some code help.... anyone know how to kill a code running in the game.... have a timer setup on a trigger the timer is in a sqf... bombtimer = [] spawn { execvm "scripts\timer.sqf"; }; but i want to be able to kill the scripts\timer.sqf" when they interact with at laptop how can i do this? timer.sqf looks like this 0 = [] spawn { private _duration = 60; private "_color"; if (isServer) then {[_duration,true] call BIS_fnc_countdown}; waitUntil {!isNil "BIS_fnc_countdown_time"}; _time = BIS_fnc_countdown_time; for "_i" from _duration to 0 step -1 do { call { if (_i < 6) exitWith {_color = "#ff0000"}; if (_i < 16) exitWith {_color = "#eef441"}; _color = "#45f442"; }; _tt = if isMultiplayer then [{serverTime},{time}]; hintSilent parseText format ["BOMB COUNTDOWN:<br/><t color= '%1'>--- %2 ---</t>", _color, [(_time - _tt)/3600,"HH:MM:SS"] call BIS_fnc_timetostring]; uisleep 1; }; uisleep 1; hintSilent parseText format ["<t color='%1'>--- Time is up! ---</t>",_color]; uisleep 1; null = [boom, 10, TRUE, TRUE] execVM "freestyleNuke\iniNuke.sqf"; }; Share this post Link to post Share on other sites
Larrow 2822 Posted December 19, 2022 You have too many nested scheduled code blocks( spawn, execVM ), just use the original execVM to return a handle to the spawned script. Then you can use the terminate command on the handle to prematurely disable the countdown. Also, there is no need for the For loop to monitor the time remaining as this can be queried from BIS_fnc_countDown. Spoiler bombtimer = [] execVM "scripts\timer.sqf"; //scripts\timer.sqf private _duration = 60; private [ "_color", "_remainingTime" ]; if (isServer) then {[_duration,true] call BIS_fnc_countdown}; //Wait until the global countdown has been started waitUntil { uiSleep 0.25; [ true ] call BIS_fnc_countdown }; //While the countdown is running while { [ true ] call BIS_fnc_countdown } do { //Get remaining time _remainingTime = [ 0 ] call BIS_fnc_countdown; //Get hint color based on time _color = switch ( true ) do { case ( _remainingTime < 6 ) : { "#ff0000" }; case ( _remainingTime < 16 ) : { "#eef441" }; default { "#45f442" }; }; //hint time reminaing hintSilent parseText format ["BOMB COUNTDOWN:<br/><t color= '%1'>--- %2 ---</t>", _color, [_remainingTime/3600,"HH:MM:SS"] call BIS_fnc_timetostring]; //Wait for new tick of countdown waitUntil{ uiSleep 0.25; [ 0 ] call BIS_fnc_countdown < _remainingTime }; }; //Time up - booooom! hintSilent parseText format ["<t color='%1'>--- Time is up! ---</t>",_color]; uiSleep 1; null = [ boom, 10, true, true ] execVM "freestyleNuke\iniNuke.sqf"; //To stop timer prematurely terminate bombtimer; //stop script [ -1 ] call BIS_fnc_countdown; //stop timer hintSilent parseText "<t color='#45f442'>--- Bomb Difused! ---</t>"; //Either remove timer hint or display success Share this post Link to post Share on other sites
Bad_Dad 4 Posted December 19, 2022 33 minutes ago, Larrow said: You have too many nested scheduled code blocks( spawn, execVM ), just use the original execVM to return a handle to the spawned script. Then you can use the terminate command on the handle to prematurely disable the countdown. Also, there is no need for the For loop to monitor the time remaining as this can be queried from BIS_fnc_countDown. Reveal hidden contents bombtimer = [] execVM "scripts\timer.sqf"; //scripts\timer.sqf private _duration = 60; private [ "_color", "_remainingTime" ]; if (isServer) then {[_duration,true] call BIS_fnc_countdown}; //Wait until the global countdown has been started waitUntil { uiSleep 0.25; [ true ] call BIS_fnc_countdown }; //While the countdown is running while { [ true ] call BIS_fnc_countdown } do { //Get remaining time _remainingTime = [ 0 ] call BIS_fnc_countdown; //Get hint color based on time _color = switch ( true ) do { case ( _remainingTime < 6 ) : { "#ff0000" }; case ( _remainingTime < 16 ) : { "#eef441" }; default { "#45f442" }; }; //hint time reminaing hintSilent parseText format ["BOMB COUNTDOWN:<br/><t color= '%1'>--- %2 ---</t>", _color, [_remainingTime/3600,"HH:MM:SS"] call BIS_fnc_timetostring]; //Wait for new tick of countdown waitUntil{ uiSleep 0.25; [ 0 ] call BIS_fnc_countdown < _remainingTime }; }; //Time up - booooom! hintSilent parseText format ["<t color='%1'>--- Time is up! ---</t>",_color]; uiSleep 1; null = [ boom, 10, true, true ] execVM "freestyleNuke\iniNuke.sqf"; //To stop timer prematurely terminate bombtimer; //stop script [ -1 ] call BIS_fnc_countdown; //stop timer hintSilent parseText "<t color='#45f442'>--- Bomb Difused! ---</t>"; //Either remove timer hint or display success Thanks.... i figured out the too many spawn issues shortly after i posted this... but didn't know how to kill the timer... appreciate it this is what i ended up with boom = [] spawn { private _duration = 300; private "_color"; if (isServer) then {[_duration,true] call BIS_fnc_countdown}; waitUntil {!isNil "BIS_fnc_countdown_time"}; playSound "activated"; _time = BIS_fnc_countdown_time; for "_i" from _duration to 0 step -1 do { call { if (_i < 6) exitWith {_color = "#ff0000"}; if (_i < 16) exitWith {_color = "#eef441"}; _color = "#45f442"; }; _tt = if isMultiplayer then [{serverTime},{time}]; hintSilent parseText format ["BOMB COUNTDOWN:<br/><t color= '%1'>--- %2 ---</t>", _color, [(_time - _tt)/3600,"HH:MM:SS"] call BIS_fnc_timetostring]; uisleep 1; }; uisleep 1; hintSilent parseText format ["<t color='%1'>--- Time is up! ---</t>",_color]; uisleep 1; null = [[6949.75,2226.93,25.3147], 10, TRUE, TRUE] execVM "freestyleNuke\iniNuke.sqf"; }; then adding this to a laptop to stop the bomb... [this, "DISARM BOMB", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "_this distance _target < 3", "_caller distance _target < 3", {}, {}, {execVM "scripts\terminatebomb.sqf";}, {}, [], 12, 0, true, false ] remoteExec ["BIS_fnc_holdActionAdd", 0, this]; and terminatebomb.sqf looks like this... // Terminate the bomb terminate boom; hint parseText "<t size='2.0'>Bomb Defused</t>"; [ -1 ] call BIS_fnc_countdown; //stop timer playSound "disarmed"; Share this post Link to post Share on other sites