Announcement

Collapse
No announcement yet.

Timer with Countdown Message

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [INFO] Timer with Countdown Message

    Hello fellow TGers,
    I wanted to post this timer script on the forums, in case anyone wanted to use it. The script is an alternative way to run a timer on a mission. The script can also be used to create a ticking down timer on screen. I currently have it implemented on a few of my missions, i.e. TvT_Bomb_Defuse_Tanoa and CO16_OP_Tiger's_Lair. There are a few thing you need to make the timer work correctly:

    -Trigger in game to activate the script.
    If you run the script in the init.sqf files then it will start as soon as the mission is opened, regardless if people have spawned. I prefer to have a trigger at the starting location of the
    missions. Place a trigger and set the condition to your preference, in the activation field place the following nul = execVM "timer.sqf"; The idea is to have the players use their time in
    the briefing section of the mission and not be constricted by the timer.

    -Trigger in game as the end condition once time runs out.
    The script needs a trigger in game to activate once the timer reaches zero. Create a trigger and place the following into the condition field ELAPSED_TIME > END_TIME. Additionally set
    the trigger type to be "lose" in case you want the trigger to end the mission.

    That pretty much covers it, if you want you could probably place a few lines in the initServer.sqf saying,
    Code:
    if (isDedicated) then {
    [] spawn {
    waitUntil {ELAPSED_TIME > END_TIME};
    ["Lose", true] call BIS_fnc_endMission;
    };
    so that you do not have to put an ending trigger in game but I have not tested it yet. Let me know if you have found some neat little changes, like changing the displayed message to be in a radio channel, and feel free to share with everyone. Here is the link to the page where I found the script https://forums.bistudio.com/topic/15...een-time-left/ credit goes to mindstorm on the BI Forums. Let me know if I missed something or you need help!

    Code:
    //Countdown Timer Credit mindstorm
    //Create a new file name timer.sqf
    END_TIME = 3000; //When mission should end in seconds.
    
    ELAPSED_TIME = 0;
    
    if (isServer) then {
    
    [] spawn {
            
    	START_TIME = diag_tickTime;
    
    	while {ELAPSED_TIME < END_TIME} do 
    
    		{
    
    			ELAPSED_TIME = diag_tickTime - START_TIME;
    
    			publicVariable "ELAPSED_TIME";
    
    			sleep 1;
    
    		};
    
    	};
    
    };
    
    if(not isDedicated) then {
    
    [] spawn {
    
    	while{ELAPSED_TIME < END_TIME } do
    
    		{
    
    		_time = END_TIME - ELAPSED_TIME;
    
    		_finish_time_minutes = floor(_time / 60);
    
    		_finish_time_seconds = floor(_time) - (60 * _finish_time_minutes);
    
    		if(_finish_time_seconds < 10) then
    
    			{
    
    				_finish_time_seconds = format ["0%1", _finish_time_seconds];
    
    			};
    
    		if(_finish_time_minutes < 10) then
    
    			{
    
    			_finish_time_minutes = format ["0%1", _finish_time_minutes];
    
    			};
    
    		_formatted_time = format ["%1:%2", _finish_time_minutes, _finish_time_seconds];
    		
    			hintSilent format ["Time left:\n%1", _formatted_time]; //display on screen timer
    		
    			sleep 1;
    
    		};
    
    	};
    
    };

Connect

Collapse

TeamSpeak 3 Server

Collapse

Advertisement

Collapse

Twitter Feed

Collapse

Working...
X