Jump to content
Sign in to follow this  
Cookieeater

Timer script not working on dedicated server

Recommended Posts

I'm trying to get a visible timer working in ArmA III. This script, made by [FRL]Myke, was originally designed for ArmA II yet works exactly the same in ArmA III. The problem is that this script, like in ArmA II, doesn't work on a dedicated server. The script works on single player and hosted multiplayer games, but only displays the 2nd argument("Reinforcments arriving...") when used on a dedicated server. How could I get this working on a dedicated server?

//nul = [951, "Reinforcements arrive:", "Reinforcements arriving..."] execVM "timer.sqf"

private ["_remaining", "_ref", "_timer", "_msg1", "_msg2"];
_timer = _this select 0;
_msg1 = _this select 1;
_msg2 = _this select 2;
_ref = time;
"glt_timerMsg" addPublicVariableEventHandler {[] call glt_showCountdown};
if (isnil "glt_timeFormat") then {
glt_timeFormat = {
	private ["_hours", "_minutes", "_seconds"];
	_hours = 0;
	_minutes = 0;
	_seconds = 0;
	_seconds = _this;
	if (_seconds > 59) then {
		_minutes = floor (_seconds / 60);
		_seconds = _seconds - (_minutes * 60);
	};
	if (_minutes > 59) then {
		_hours = floor (_minutes / 60);
		_minutes = _minutes - (_hours * 60);
	};
	if (_seconds < 10) then {
		_seconds = format ["0%1", _seconds];
	};
	if (_minutes < 10) then {
		_minutes = format ["0%1", _minutes];
	};
	[_hours, _minutes, _seconds]
};
};

if (isnil "glt_showCountdown") then {
glt_showCountdown = {
	hintsilent glt_TimerMsg;
};
};

if (isServer) then {
while {_timer > 0} do {
	_remaining = _timer call glt_timeFormat;
	glt_timerMsg = format ["%1\n\n%2:%3:%4",_msg1, (_remaining select 0), (_remaining select 1), (_remaining select 2)];
	publicVariable "glt_timerMsg";
	if (local player) then {[] call glt_showCountdown};
	_timer = _timer - 1;
	sleep 1;
};
};
glt_timerMsg = _msg2;
publicVariable "glt_timerMsg";
if (local player) then {[] call glt_showCountdown};

EDIT:

I fixed it by myself, but if anyone wants to know how to get it to work on a dedicated server, you need to replace "_timer = _timer - 1;" to "_timer = _initial - time;" so it'll look like this

//nul = [951, "Reinforcements arrive:", "Reinforcements arriving..."] execVM "timer.sqf"

private ["_remaining", "_ref", "_timer", "_initial", "_msg1", "_msg2"];
_initial = _this select 0;
_msg1 = _this select 1;
_msg2 = _this select 2;
_ref = time;
"glt_timerMsg" addPublicVariableEventHandler {[] call glt_showCountdown};
if (isnil "glt_timeFormat") then {
glt_timeFormat = {
	private ["_hours", "_minutes", "_seconds"];
	_hours = 0;
	_minutes = 0;
	_seconds = 0;
	_seconds = _this;
	if (_seconds > 59) then {
		_minutes = floor (_seconds / 60);
		_seconds = _seconds - (_minutes * 60);
	};
	if (_minutes > 59) then {
		_hours = floor (_minutes / 60);
		_minutes = _minutes - (_hours * 60);
	};
	if (_seconds < 10) then {
		_seconds = format ["0%1", _seconds];
	};
	if (_minutes < 10) then {
		_minutes = format ["0%1", _minutes];
	};
	[_hours, _minutes, _seconds]
};
};

if (isnil "glt_showCountdown") then {
glt_showCountdown = {
	hintsilent glt_TimerMsg;
};
};

if (isServer) then {
while {true} do {
	_remaining = _timer call glt_timeFormat;
	glt_timerMsg = format ["%1\n\n%2:%3:%4",_msg1, (_remaining select 0), (_remaining select 1), (_remaining select 2)];
	publicVariable "glt_timerMsg";
	if (local player) then {[] call glt_showCountdown};
	_timer = _initial - (time);
	sleep 1;
};
};
glt_timerMsg = _msg2;
publicVariable "glt_timerMsg";
if (local player) then {[] call glt_showCountdown};

Edited by Cookieeater

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
Sign in to follow this  

×