Adding fog during certain hours. (Would this code work, how best to implement it?)

3 posts in this topic

Newbie scripting question here, all advice is welcome.

A friend wants fog to appear in his Exile server during certain hours.

Been playing around in the editor and this seems to work:

_date = date;
// If it's after 9pm, roll in fog over 60 seconds.
if (date select 3 >= 21) then 
	60 setFog [1, 0, 0];  
// If it's after 9am then clear the fog.
else if (date select 3 >= 9) then 
	60 setFog [0, 0, 0];

How would be the best way to implement this into Exile?

Save as customFog.sqf, and add:

execVM "scripts\customFog.sqf";  

to our init.sqf would load the script but, as far as I'm aware, only check the time once.

So how do we keep checking without affecting performance?


UPDATE: Had a thought, could we use waitUntil ?

// Would add the fog at 9pm but never clear it?
waitUntil {date select 3 >= 21}
 // Draw fog code

// Clear it?
waitUntil {date select 3 >= 9}
 // Clear fog code

Would that work? Will play with the Editor in the morning, is 3am here.

Edited by DY357LX

Share this post

Link to post
Share on other sites

@GR8 Do you have any idea How to call this at a certain time in game then reset to new value at a later time. Or even a certain amount a time the server has been up.

Share this post

Link to post
Share on other sites

You will need to use while loops to keep the script checking for the time or the server uptime. 


Something like this could work 

while {date select 3 >= 21}
do {
 // Draw fog code
 // wait
 uiSleep 10;


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.