Jump to content
Sign in to follow this  
Reapy

Problem with Timer Script

Recommended Posts

I made a trigger script running only on server and communicate minutes/seconds values to clients. So the final time given by the server is the same for all clients.

It's work fine on the ArmA editor but only minutes works on a dedicated server sad_o.gif

Here, how I proceed:

Init.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

"1" ObjStatus "ACTIVE";

obj1=1;

win=0;

TM=0;

TS=0;

FAR SetGroupId ["ALPHA BLUE"];

if (true) exitWith {};

Trigger launch Timer Script on the server when player enter a specific zone:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

Condition: if (isserver) then {nul=[] execVM "scripts\timer.sqf"}

timer.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

if (isServer) then {

T1=time;

TM=0;

while { (win==0) } do {

T2=time;

T3=T2-T1;

TS=T3;

sleep .1;

if ( T3>=60) then {

TM=TM+1;

publicvariable "TM";

TS=0;

publicvariable "TS";

T1=T2;

sleep .1;

};

};

} else {};

If (true) ExitWith {};

When OBJ is success, a trigger launch:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

win=1; publicvariable "win"; TitleText [ format ["Final Time: %1 min. %2 sec.", TM, TS],"PLAIN DOWN"]

A repeating trigger display time to clients during the mission too:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

if (!(isnull player)) then {nul=[] execVM "scripts\clttimer.sqf"}

clttimer.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

while { (win==0) } do {

hint format["Time: %1 min. %2 sec.", TM, TS];

sleep .1;

};

If (true) ExitWith {};

Minutes works on dedicated server, but not the seconds displaying 0

Anyone have an idea ?

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">TM=TM+1;

publicvariable "TM";

TS=TM*60;

publicvariable "TS";

and "} else {};" left out in the open doesn't look pretty.

I'd suggest looking into addPublicVariableEventHandler instead

of clttimer.sqf

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  

×