Help first time Script

Alright now this seems to be happening
Code:
17:48:57 Error in expression <ey","_result","_outcome"];

if (isnight ==false) then {
_key = "CHILD:307:";
_re>
17:48:57   Error position: <==false) then {
_key = "CHILD:307:";
_re>
17:48:57   Error ==: Type Bool, expected Number,String,Object,Side,Group,Text,Config entry,Display (dialog),Control,Team member,Task,Location
17:48:57 File z\addons\dayz_server\init\server_functions.sqf, line 739
17:48:57 Error in expression <ey","_result","_outcome"];

if (isnight ==false) then {
_key = "CHILD:307:";
_re>
17:48:57   Error position: <==false) then {
_key = "CHILD:307:";
_re>
17:48:57   Error Generic error in expression
 
Still getting an error. This thing does not want to comply.
Code:
19:44:20 Error in expression <_date = [2013,8,3,_hour,_minute];
};
}
else (isnight == 1) then {
_date = [2013>
19:44:20   Error position: <else (isnight == 1) then {
_date = [2013>
19:44:20   Error else: Type Bool, expected code
19:44:20 File z\addons\dayz_server\init\server_functions.sqf, line 751
19:44:20 Error in expression <_date = [2013,8,3,_hour,_minute];
};
}
else (isnight == 1) then {
_date = [2013>
19:44:20   Error position: <else (isnight == 1) then {
_date = [2013>
19:44:20   Error Generic error in expression
 
else () then {

should be else {code here}

only if has the (condition)

...

if(condition) then {execute code} else {execute other code};
 
Alright so I'm not getting that error any more.

Code:
    _TimeToNight = 3;         //Time in minutes before night time
    isnight = 0;
    r_DoLoop = true;
    _TimeToNight = _TimeToNight * 60 + 1;                                  //Set time to seconds
    while {r_DoLoop} do {
       
        if (_TimeToNight >= 0) then {                                  //Repeat until time is 0
            _TimeToNight = _TimeToNight - 1;                            //Subtract one second each loop
                        diag_log format["TIMETONIGHT = %1",_timetonight];
        };
        if (_TimeToNight == 0) then { 
                 diag_log format["Nighttime Loop ending"]; 
                 diag_log format["ISNIGHT = %1",isnight]; 
                   isnight = 1;
                   publicVariable "isnight";
                    r_DoLoop = false;                              //End the loop  
                 diag_log format["ISNIGHT = %1",isnight]; 
        };
    sleep 1;
    };

Here's the code, it seems to work right, but if the publicVariable "isnight"; is in there, then I get kicked for publicVariable #0, and I cannot seem to get rid of it in the battleye scripts, I turn the 5's to 1's but they change back when I restart the server.
 
whitelist the publicVariable as following.

!="isnight"

at the end of the corresponding line notified by be.
 
a Condition needs a boolean returned value, so isnight is already a boolean variable, you don't have to compare it with false or true
(isnight == true) is not correct spelled, it should be:

if (isnight) for true
i !(isnight) for false

also you don't need a variable called r_DoLoop
i think so it looks cleaner
Code:
_TimeToNight = 3;         //Time in minutes before night time
isnight = 0;
_TimeToNight = _TimeToNight * 60 + 1;                                  //Set time to seconds
while {true} do {
    if (_TimeToNight == 0) exitWith { //End the loop
        isnight = 1;
        publicVariable "isnight";        
        diag_log format["Nighttime Loop ending"];          
        diag_log format["ISNIGHT = %1",isnight];
    };
    _TimeToNight = _TimeToNight - 1;                            //Subtract one second each loop
    diag_log format["TIMETONIGHT = %1",_timetonight];
    sleep 1;
};
is it important that the change from day to night is accurate to the second?

otherwise the loop don't has to run each second:
Code:
_TimeToNight = 3;         //Time in minutes before night time
isnight = 0;
_TimeToNight = _TimeToNight * 60 + 1;                                  //Set time to seconds
while {true} do {
    if (_TimeToNight < 1) exitWith { //End the loop
        isnight = 1;
        publicVariable "isnight";            
        diag_log format["Nighttime Loop ending"];              
        diag_log format["ISNIGHT = %1",isnight];
    };
    _TimeToNight = _TimeToNight - 5;                            //Subtract one second each loop
    diag_log format["TIMETONIGHT = %1",_timetonight];
    sleep 5;
};
 
Last edited:
@Soul I would do that, but I cannot seem to figure out how to keep that edited, when I restart the server all the BE filters go back to their original state.
 
Alright so I'm trying to update my Battleye filters for both a SetPos we're getting for heli lifting, and for this public variable, but everytime I change it, the files rest after restarts. Any idea why that might be happening?
 
delete all your befilter .txt files except the bans.txt ... if you really feel insecure without them you can put them back in after you are done. But I can guarantee you that the BE filters stop 1 hacker for every 20,000 legitimate players it kicks.
 
Alright I've gotten it to work finally, keeping the BE from changing back, so I'm going to work on seeing if the script will work now.
 
a shorter variant of the loop
Code:
isnight = false;
_TimeToNight = time + 181; //Time in seconds before night time
while {true} do {
    if (_TimeToNight <= time) exitWith { //End the loop
        isnight = true;
        publicVariable "isnight";       
        diag_log "Nighttime Loop ending";         
        //diag_log format["ISNIGHT = %1",isnight];
    };
    //diag_log format["TIMETONIGHT = %1",(_TimeToNight - time)];
    sleep 1;
};
 
Back
Top