Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google Log In with Steam Sign In
  • Create Account
Photo

daynight cycle

daynight cycle

  • Please log in to reply
3 replies to this topic

#1
snooop87

snooop87

    100+ Post Club

  • Forum Member
  • 123 posts
  • Country: Country Flag
  • snooop1987

dear community ,  i want to create a day night cycle were you can set the time  like

1H DAy and 10 Min Night , then next morning .......

 

this my first try.....

timeday= 60;
timenight=10;
while{true}do{
	{
	if (isPlayer _x) then {
          _x setVehicleInit "night=true;setDate[2014,03,07,_hours,_minutes]";
           processInitCommands;
[[calculations]] ? 
	};
	} forEach playableunits;
sleep _time;
};

  • DiamIrrameMap likes this



#2
snooop87

snooop87

    100+ Post Club

  • Forum Member
  • 123 posts
  • Country: Country Flag
  • snooop1987

try this now =D and now i will create a Serverside time calculation with publicvariable and every client will get this var and change time every minute .

if(!isServer) exitwith {};

_randomPos = [3707, 3608,0.0014];
_missionRewardRadius = 50000;
_day= 120;
_night=10;
_min=0;
_datehour=0;
_dateMin=0;
_cycleD = 628/_day;
_cycleN = 811/_night;
//max 1439 min

func_settime= {
 setDate[2014,03,07,_datehour + 7,_dateMin];
 _inArea = _randomPos nearEntities _missionRewardRadius;
	{
	if (isPlayer _x) then {
           _x setVehicleInit "setDate[2014,03,07,_datehour + 7,_dateMin]";
           processInitCommands;
	};
	} forEach _inArea;
};

while{true}do 
{
   
    if(_min >628)then{_c=Round(_cycleN);}else{_c=round(_cycleD)};
    if(_min >=1439)then{_min=_min - 1439};
     _min = _min+_c;
     //aufteilen
     if(_min/60 >1)then{_datehour= floor(_min/60)};
     if(_datehour >24)then{_datehour= _datehour -24};
     _dateMin= _min % 60;
      call func_settime;
sleep 60;
};

Edited by snooop87, 03 August 2014 - 08:50 AM.

  • DiamIrrameMap likes this

#3
KiloSwiss

KiloSwiss

    100+ Post Club

  • Forum Member
  • 455 posts
  • Country: Country Flag
Very interesting, I always like Your ideas snooop87

Here are a few hints:

If the servers framerate drops below somewhat around 10/s the sleep command is not accurate any longer.
Clients will most probably not suffer from this problem, since the fps are above 20 (at least for those players who like playable fps and don't play ArmA2 on a x486).

Executing the setdate command on the client can (and will!) cause heavy laggs (depending on their system, playtime and how big the "time jump" is).

Greez KiloSwiss

#4
snooop87

snooop87

    100+ Post Club

  • Forum Member
  • 123 posts
  • Country: Country Flag
  • snooop1987

hey KiloSwiss, i am Working now with  "skipTime " (client default skiploop (synchronize  serverTime on Connect))

 

skiptime 0.00026 <3

One second is roughly 0.00026 hours.

Any calculations must be enclosed in parentheses, e.g. skipTime (_seconds/3600)

Edited by snooop87, 12 August 2014 - 05:42 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users