Jump to content
JohnKalo

Pause and Continue Action

Recommended Posts

We will be talking about an MP mission.

 

So at some point one of the players should be able to start an action that will need to take about 20 seconds to be completed. BUT if he stops pressing the action then the action's progress should pause. So when he starts the action again he will continue from let us say 40% and not 0% again. Also this Pause function will need to be applied to a video that will be playing on a screen. The video should pause and then continue too. So is this possible in a simple way please?

Share this post


Link to post
Share on other sites

Hhhmmm... there must be more than one way to do it. Unfortunately, I don't have experience with UI, textures, PIPs, videos and such things. Regarding the paused action, the first thing that comes to mind is to create a variable that will hold the percentage of the video played (pretty much like the animation phases work in ArmA). So an example with a holdAction would look like this (I have taken the biggest part from the documentation of BIS_fnc_holdActionAdd)

/*
 * Inside video player's init.sqf
 */

// Initialise and set the video-played variable
missionNamespace setVariable["videoPlayed", 0];

// Now add the hold action to the video player
[
	this,                                                                    // Object the action is attached to (video player)
	"Play Video",                                                            // Title of the action
	"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",	         // Idle icon shown on screen
	"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",	         // Progress icon shown on screen
	"(_this distance _target < 3)",                                          // Condition for the action to be shown
	"_caller distance _target < 3",                                          // Condition for the action to progress
	{													                     // Code executed when action starts
		// HERE YOU SHOULD PLACE THE CODE TO SHOW THE VIDEO
	},													                
    {                                                                                // Code executed on every progress tick
		private _newValue = missionNamespace getVariable "videoPlayed";      // Get the current duration of the video
		_newValue = _newValue + (_progress/_maxProgress);                    // Get the progress as percentage (normalised)
		// HERE PLACE CODE TO CONTINUE VIDEO PLAYBACK IF YOU HAVE TO, OTHERWISE SKIP IT
		missionNamespace setVariable["videoPlayed", _newValue];              // Update the videoPlayed value representing the duration of the video played
	},													
	{						                     // Code executed on completion
		// HERE PLACE CODE TO STOP VIDEO PLAYBACK
	},
	{						                     // Code executed on interrupted
		// HERE PLACE CODE TO STOP VIDEO PLAYBACK
	},													
	[],								    // Arguments passed to the scripts as _this select 3
	20,								    // Action duration [s]
	0,								    // Priority
	true,								    // Remove on completion
	false								    // Show in unconscious state
] remoteExec ["BIS_fnc_holdActionAdd", 0, true];		            // MP compatible implementation

Not sure how helpful this may be for you, but hopefully it will at least serve as a starting point.

 

EDIT:
I believe that a better way to do the "percentage update" would be to update a parameter that holds how much of the whole video duration has been played in the code that plays the video (this may not be possible though, as I said I have no experience with video playing in ArmA) and use the holdAction just to start and stop the video. This is because holdAction has only 24 four ticks, so your playedVideo value will be quantised in a quite low resolution. If this is not an issue you could very well go with this. Otherwise, you should do it in a different place with a higher refresh rate.

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites

Thank you very much!!! The above is code I have used before but since I never had so helpful notes I never knew what all those columns were for! It did work with simple tricks but it could be done easier too had I used the other now translated lines. The problem however is that I still cannot find a way to Pause the video and then Continue it. The action as you wrote above I suppose does work as intended but the video will continue playing as is. Maybe I will need to use another way for the task to work.

  • Like 2

Share this post


Link to post
Share on other sites

Glad this kinda-worked for you. Still not able to help you with the video playback though. As soon as I find some free time I will have a look at video playbacks in ArmA in case I come up with some solution. I'll make sure to let you know if I find something useful.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×