killer12 10 Posted May 9, 2015 I've been working on this task script, it creates a countdown timer when certain criteria are met, but i'm trying to make it dissapear when the person has delivered the item. At the moment, after completion it continues to countdown . Any ideas how to stop it? Here's the script: private["_dp","_target","_text","_uiDisp","_time","_bleedout"]; _target = [_this,0,ObjNull,[ObjNull]] call BIS_fnc_param; _time = time + 600; if(str(_target) in life_medic_points) then { private["_point"]; _point = life_medic_points - [(str(_target))]; _dp = _point call BIS_fnc_selectRandom; } else { _dp = life_medic_points call BIS_fnc_selectRandom; }; life_dp_start = _target; life_delivery_in_progress = true; life_dp_point = call compile format["%1",_dp]; _dp = [_dp,"_"," "] call KRON_Replace; life_medic_task = player createSimpleTask [format["Delivery_%1",life_dp_point]]; life_medic_task setSimpleTaskDescription [format[localize "STR_NOTF_DPStart",toUpper _dp],"Delivery Job",""]; hintSilent parseText format["<t align='center'><t size='1.8'><t color='#38C40A'>Job Accepted</t><br/><br/></t>Destination: <t color='#FA4F4F'>%1</t><br/><br/>Description: Immediately drive or fly to the required Hospital to transport the live Organ to the surgeon waiting. The patient is on bypass at the moment but will bleed out soon, so hurry doctor!",toUpper _dp]; life_medic_task setTaskState "Assigned"; _text = format["%1",life_dp_point]; life_medic_task setSimpleTaskDestination (getMarkerPos _text); player setCurrentTask life_medic_task; _bleedout = true; //["DeliveryAssigned",[format[localize "STR_NOTF_DPTask",toUpper _dp]]] call bis_fnc_showNotification; sleep 10; [] spawn { waitUntil {!life_delivery_in_progress OR !alive player}; if(!alive player) then { life_medic_task setTaskState "Failed"; cancelSimpleTaskDestination life_medic_task; player removeSimpleTask life_medic_task; hint "Failed, you died an the organ Perished."; life_delivery_in_progress = false; life_dp_point = nil; }; }; while {_bleedout} do { if((round(_time - time)) > 0) then { _countDown = [(_time - time),"MM:SS"] call BIS_fnc_secondsToString; hintSilent parseText format["<t size='2'><t color='#FA4F4F'>BLEEDOUT TIME</t></t><br/><t size='4'>%1</t>",_countDown]; }; if((round(_time - time)) < 1) exitWith {hint "You have failed the mission, the Patient bled out on the operation table because you took too long."; life_medic_task setTaskState "Failed"; cancelSimpleTaskDestination life_medic_task; player removeSimpleTask life_medic_task; life_delivery_in_progress = false; life_dp_point = nil; }; if(!alive player && ((round(_time - time)) > 0)) exitWith {hint "You have failed the mission, the patient bled out on the operating table because you didn't deliver the organ and it perished..."; life_medic_task setTaskState "Failed"; cancelSimpleTaskDestination life_medic_task; player removeSimpleTask life_medic_task; life_delivery_in_progress = false; life_dp_point = nil; }; if (!life_delivery_in_progress) then { _bleedout = false; }; sleep 0.1; }; Share this post Link to post Share on other sites
flyinpenguin 30 Posted May 9, 2015 (edited) Your going to need to define a missionNamespace variable of type boolean near the beginning. Switch it to the opposite in the code when the player succeeds. When ever you display the timer, check the variable to see if it has been completed. You dont always need to use getVariable for missionNamespace variables once you declare them, but it doesnt hurt to make sure by using 'missionNamespace getVariable "MyMissionVariable";' Of course setting them looks like 'missionNamespace setVariable ["MyMissionVariable", false];' Edit: Looked into the code further, you are using the default task system, just check the taskstate for completion in the timer. I never use default task's so I'm not too familiar with them. Edited May 9, 2015 by flyinpenguin Share this post Link to post Share on other sites
killer12 10 Posted May 10, 2015 (edited) Thanks for the feedback flyingpenguin! I'm still having trouble understanding what you menitoned. I looked up on missionNamespace, but unfortunately i couldn't exactly understand it. I'm unsure how to check the taskstate, so i just threw these together: if((round(_time - time)) > 0) then { _countDown = [(_time - time),"MM:SS"] call BIS_fnc_secondsToString; if (life_medic_task taskState !"Succeeded") then { hintSilent parseText format["<t size='2'><t color='#FA4F4F'>BLEEDOUT TIME</t></t><br/><t size='4'>%1</t>",_countDown]; }; }; if((round(_time - time)) > 0) then { _countDown = [(_time - time),"MM:SS"] call BIS_fnc_secondsToString; if (life_medic_task taskState == "Assigned") then { hintSilent parseText format["<t size='2'><t color='#FA4F4F'>BLEEDOUT TIME</t></t><br/><t size='4'>%1</t>",_countDown]; }; }; Any chance one of those would work? Thanks Edited May 10, 2015 by killer12 Share this post Link to post Share on other sites
flyinpenguin 30 Posted August 2, 2015 You have it backwards slightly. Reference https://community.bistudio.com/wiki/taskStateShould be if((round(_time - time)) > 0) then { _countDown = [(_time - time),"MM:SS"] call BIS_fnc_secondsToString; if (taskState life_medic_task != "Succeeded") then { hintSilent parseText format["<t size='2'><t color='#FA4F4F'>BLEEDOUT TIME</t></t><br/><t size='4'>%1</t>",_countDown]; }; }; if((round(_time - time)) > 0) then { _countDown = [(_time - time),"MM:SS"] call BIS_fnc_secondsToString; if (taskState life_medic_task == "Assigned") then { hintSilent parseText format["<t size='2'><t color='#FA4F4F'>BLEEDOUT TIME</t></t><br/><t size='4'>%1</t>",_countDown]; }; }; Sorry for late reply. I dont go on these forums that often.Also, use this to define life_medic_task missionNamespace setVariable ["life_medic_task", (player createSimpleTask [format["Delivery_%1",life_dp_point]]) ]; Share this post Link to post Share on other sites