What I have here is basically spaghetti code, somebody else should probably take a look and tell me what I did wrong. It's probably patched together from multiple places (i worked on the same concept for a gamemode)
This should return you a number pertaining to the time of day (0 is ~6AM, 500 is ~6PM I guess, 1000 is ~6AM of the next day)
function getDayTime()
{
%time = $Sim::Time / DayCycle.dayLength + DayCycle.dayOffset;
$DayTime = (%time - mFloor(%time)) *1000;
return $DayTime;
}
This is a method I used to convert that number into a string like "6:00 AM". This might only work for 300 second days but I'm not sure. 24 hour clock is probably less complicated
function getClock()
{
// 41.6666666667 = 1 hour
%hours = (getDayTime() + 249) / 41.5;
%remainder = %hours - mFloor(%hours);
%seconds = (%remainder * 60);
// convert hours to 12 hour clock
if(%hours > 12)
{
%noonString = "PM";
%hours = %hours - 12;
if(%hours > 12)
{
%noonString = "AM";
%hours = %hours - 12;
}
}
else
{
%noonString = "AM";
}
%hourOfDay = mFloor(%hours);
if(%hourOfDay == 0)
{
%hourOfDay = 12;
}
%secondOfHour = mFloor(%seconds);
if(%secondOfHour < 10)
{
%secondOfHour = "0" @ %secondOfHour;
}
%time = %hourOfDay @ ":" @ %secondOfHour SPC %noonString;
return %time;
}
This function just sets the time to 6AM and enables/resets the daycycle
function serverCmdAdvanceDay(%client)
{
if(!%client.isAdmin)
return;
serverCmdEnvGui_SetVar(%client,"DayCycleEnabled",1);
serverCmdEnvGui_SetVar(%client, DayLength, $DayLength);
serverCmdEnvGui_SetVar(%client, DayOffset, 1);
%time = getDayTime() / 1000;
serverCmdEnvGui_SetVar(%client, DayOffset, 1 - %time);
}