Results 1 to 2 of 2

Thread: Problem with Timer Script

  1. #1
    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


    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">
    &#34;1&#34; ObjStatus &#34;ACTIVE&#34;;

    obj1=1;
    win=0;
    TM=0;
    TS=0;

    FAR SetGroupId &#91;&#34;ALPHA BLUE&#34;&#93;;

    if &#40;true&#41; exitWith {};
    [/QUOTE]

    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&#58; if &#40;isserver&#41; then {nul=&#91;&#93; execVM &#34;scripts&#92;timer.sqf&#34;}
    [/QUOTE]

    timer.sqf:
    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
    if &#40;isServer&#41; then {

    T1=time;
    TM=0;

    while { &#40;win==0&#41; } do {

    T2=time;
    T3=T2-T1;
    TS=T3;
    sleep .1;

    if &#40; T3&#62;=60&#41; then {

    TM=TM+1;
    publicvariable &#34;TM&#34;;
    TS=0;
    publicvariable &#34;TS&#34;;
    T1=T2;
    sleep .1;
    };
    };

    } else {};


    If &#40;true&#41; ExitWith {};
    [/QUOTE]

    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 &#34;win&#34;; TitleText &#91; format &#91;&#34;Final Time&#58; %1 min. %2 sec.&#34;, TM, TS&#93;,&#34;PLAIN DOWN&#34;&#93;
    [/QUOTE]

    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 &#40;&#33;&#40;isnull player&#41;&#41; then {nul=&#91;&#93; execVM &#34;scripts&#92;clttimer.sqf&#34;}
    [/QUOTE]

    clttimer.sqf:
    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
    while { &#40;win==0&#41; } do {
    hint format&#91;&#34;Time&#58; %1 min. %2 sec.&#34;, TM, TS&#93;;
    sleep .1;
    };

    If &#40;true&#41; ExitWith {};
    [/QUOTE]

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

    Anyone have an idea ?

  2. #2
    <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 &#34;TM&#34;;
    TS=TM*60;
    publicvariable &#34;TS&#34;;[/QUOTE]

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

    I&#39;d suggest looking into addPublicVariableEventHandler instead
    of clttimer.sqf
    1 IQ away from licking windows, drooling since 1966.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •