08-18-2014, 06:00 PM
Also, time resets on mission load. If someone plays the mission on a non-dedicated server and reloads the saved game, time starts at zero again. It's generally not a good idea to use for anything but relative timing.
The easiest way to make things like this is to use something like
if (isServer) then {
 [] spawn { sleep <time in seconds until weather changes>; execVM "weatherCHange.sqf";};
};
i.e. only run it on the server, and rely on the weather synchronization.
IF you require a local effect (like, playing sound effects), things get a bit more complicated but not too much. In that case I would use
The server side makes the changes here, and the client side reacts. Since a server might be hosted, the hasInterface function checks if this machine has an interface; this works on both dedicated servers as well as headless clients.
Hope this helps
The easiest way to make things like this is to use something like
if (isServer) then {
 [] spawn { sleep <time in seconds until weather changes>; execVM "weatherCHange.sqf";};
};
i.e. only run it on the server, and rely on the weather synchronization.
IF you require a local effect (like, playing sound effects), things get a bit more complicated but not too much. In that case I would use
Code:
// Server only
if (isServer) then {
[] spawn {
CurrentWeather = "thunder";
publicVariable "CurrentWeather";
_changeTime = 60*5; // Five minutes
sleep _changeTime;
CurrentWeather = "clear";
publicVariable "CurrentWeather";
};
};
// Server and clients
if (hasInterface) then {
[] spawn {
if (CurrentWeather == "thunder") then {
// DO some stuff here to make it rain
while {CurrentWeather == "thunder"} do {
sleep 10; // Don't need to check all the time
};
// Weather is no clear, make it so
// <do the stuff to clear weather>
};
};
};
The server side makes the changes here, and the client side reacts. Since a server might be hosted, the hasInterface function checks if this machine has an interface; this works on both dedicated servers as well as headless clients.
Hope this helps
I don't need luck, I have ammo.