Jump to content
BEAKSBY

Help with BIS_fns_paramCountdown

Recommended Posts

I don't want the default "MISSION COMPLETE" ending generated from the BIS_fns_paramCountdown.

How do tell the mission to end with if (estimatedEndServerTime < 0) then { "SideTickets" call bis_fnc_endMissionServer}; when I'm using a countdown function BIS_fns_paramCountdown?

I created my own version in the descrition.ext, but it's not working:

class Params
{
class TimeLimit 
{
	title = "Time Limit";
	texts[] = {"Unlimited", "1 minute", "10 minutes", "15 minutes", "20 minutes", "25 minutes", "30 minutes", "45 minutes", "60 minutes"};		
	values[] = {0, 60, 600, 900, 1200, 1500, 1800, 2700, 3600};
	default = 1200;
	file = "BEAKSparamCountdown.sqf"; 
	//function = "BIS_fnc_paramCountdown";
	//isGlobal = 1;
};
};

BEAKSparamCountdown.sqf

/*
Author: Karel Moricky

Description:
Set side mission time

Parameter(s):
NUMBER - time (in seconds)

Returns:
BOOL
*/

private ["_countdown"];
_countdown = [_this,0,-1,[0]] call bis_fnc_param;
if (_countdown >= 0) then {
_countdown spawn {
	waituntil {time > 0};
	if (estimatedEndServerTime < 0) then { "SideTickets" call bis_fnc_endMissionServer};
	estimatedtimeleft _this;

};
};
true

Share this post


Link to post
Share on other sites

Ive never actually used these commands Beaksby but from a quick read of the wiki i would presume it would be something like...

Description.ext

class CfgFunctions
{
class BEAKs
{
	class myCategory
	{
		class myFunction {file = "paramCountdown.sqf";};
	};
};
};

class Params
{
class TimeLimit 
{
	title = "Time Limit";
	texts[] = {"Unlimited", "1 minute", "10 minutes", "15 minutes", "20 minutes", "25 minutes", "30 minutes", "45 minutes", "60 minutes"};        
	values[] = {0, 60, 600, 900, 1200, 1500, 1800, 2700, 3600};
	default = 1200;

	//REF: https://community.bistudio.com/wiki/Arma_3_Mission_Parameters

	//This sound like its is called evey time a player joins, as in the viewDistance example from the wiki
	//setViewDistance is a local command so would not make sense if this was a one off call or server only
	//file = "BEAKSparamCountdown.sqf";


	//This needs testing does the wiki mean when the first player joins?
	//Presume so else the end time would be resetting everytime a player joined
	function = "BEAKs_fnc_paramCountdown";
	isGlobal = 0;
};
}; 

paramCountdown.sqf

private ["_countdown"];
_countdown = [_this,0,-1,[0]] call bis_fnc_param;
if (_countdown >= 0) then {
_countdown spawn {
	waituntil {time > 0};
	estimatedtimeleft _this;
	_gameTime = [] spawn {
		//waitUntil {time > 300};
		waitUntil {serverTime => estimatedEndServerTime};
		"SideTickets" call BIS_fnc_endMissionServer;
	};
};
};
true

So game starts by first player joining.

Param gets passed to this function.

As soon as the mission starts (time > 0)

The estimated time left is set to the amount of time passed in the param.

Then a new thread is started that waits unitl the amount of time the server has been running is longer than the estimate end time (in serverTime - server time is how long the server has been running, not how long the mission has been going)

which will end the mission.

The only thing you may need to note is:- from the serverTime page on the wiki

NOTE: serverTime is available to both server and clients and shows the same value when synced. The only time it is not synced is on the server, right after server restart and only for the first 300 seconds.
and may need accounting for, which i have put in the code as a comment. Just trying to think ahead, what if the server has just been restarted and a player jumps straight on then serverTime is more than likely to return crap values according to the wiki comment. (300 seconds is 5 minutes :/ )

I have also used a preInit function using CfgFunctions just to make sure the function is there in time, again needs testing.

This is all untested just going off a bit of reading. Let me know how it goes.

Edited by Larrow
Fixed derp with preInit

Share this post


Link to post
Share on other sites

Well dont know if it interests you BEAKSBY but i just put this through some testing...

description.ext

enabledebugconsole = 2;
respawn = 3;
respawnOnStart = 1;
respawnDelay = 1;

class CfgFunctions
{
class LARs
{
	class myCategory
	{
		class testFunction {
			file = "testFunction.sqf";
		};
	};
};
};


class Params
{

class myValue1
{
	title = "myValue1";
	texts[] = {"opt1","opt2","opt3","opt4"};
	values[] = {1,2,3,4};
	default = 1;
	function = "LARs_fnc_testFunction"; //Function is called when a machine connects inculding JIP, selected value is passed as an argument
		isGlobal = 1; //1 is called when anyone connects server or client (server only connects at initial mission start)/ 0 is only called when the server connects (server only connects at initial mission start)
};
class myValue2
{
	title = "myValue2";
	texts[] = {"opt10","opt11","opt12","opt13"};
	values[] = {10,11,12,13};
	default = 10;
	file = "testFile.sqf"; //Script is called on server when player joins, only at initial mission start (not called for JIP)
};
};

init.sqf

if (!isDedicated) then {
fnc_hint = {
	systemChat _this;
};
};

testFunction.sqf

h = _this spawn {
sleep 5;
if (isServer) then {
	[ format["Server: function : %1", _this], "fnc_hint", playableUnits] call BIS_fnc_MP;
};
if (!isServer) then {
	[ format["Client: function : %1", _this], "fnc_hint", playableUnits] call BIS_fnc_MP;
};
};

testFile.sqf

h = _this spawn {
sleep 5;
if (isServer) then {
	[ format["Server: file : %1", _this], "fnc_hint", playableUnits] call BIS_fnc_MP;
};
if (!isServer) then {
	[ format["Client: file : %1", _this], "fnc_hint", playableUnits] call BIS_fnc_MP;
};
};

Initial results testing on a dedicated server show..

FILE

Script is called on server when player joins, only at initial mission start (not called for JIP), selected value is passed as an argument

(still need to test effects of multiple clients being present at mission start - dont have an extra client setup atm - it maybe that it is not the player connecting that is firing this but the server itself seeing as it does not fire for JIP)

FUNCTION

Function is called when a machine connects inculding JIP, selected value is passed as an argument

isGlobal - 1 is called when anyone connects server or client (server only connects at initial mission start)/ 0 is only called when the server connects (server only connects at initial mission start)

Well that seems different to how the wiki explains it and makes the wiki somewhat miss leading.

If anyone can see an error with my test logic or has previous experience with these param options would be good to hear your opinions

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

×