active ServerTime
%time = getRealTime();
%elapsed = mSub(%time, %serverID.creationTime);
%fixed = mFloatLength(%elapsed * 0.001, 0);
if(%fixed >= 60) {
if(%fixed >= 3600) {
%minutes = %fixed / 60;
%hours = mFloor(%minutes / 60);
%hours = mFloatLength(%hours, 0);
if(%hours == 1) {
return " Server time" SPC %hours SPC "hour ago.";
} else {
if(%hours >= 24) {
%days = mFloatLength(%hours / 24, 0);
if(%hours <= 168) {
%days = mFloatLength(%hours / 24, 0);
%weeks = mFloatLength(%days / 7, 0);
return " Server time" SPC %days SPC "weeks(s) ago.";
}
%days = mFloatLength(%hours / 24, 0);
return " Server time" SPC %days SPC "day(s) ago.";
}
}
} else {
%minutes = %fixed / 60;
return " Server time" SPC mFloatLength(%minutes, 0) SPC "minute(s) ago.";
}
} else {
return " Server time" SPC %fixed SPC "seconds ago.";
}
}
deactive ServerTime
GUI Script
JS_window.extent = "800 480";
JS_window.getObject(1).extent = "782 372";
JS_window.getObject(7).position = "687 440";
JS_window.getObject(11).command = "JS_sortList(13);";
JS_serverList.extent = "765 10";
JS_serverList.columns = "0 34 65 340 385 404 415 445 510 9000 9000 620 9000 9000";
JS_window.add(
new GuiBitmapButtonCtrl() {
profile = "BlockButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "670 34";
extent = "86 19";
minExtent = "8 2";
visible = "1";
command = "JS_sortList(12);";
text = "Server Time";
groupNum = "-1";
buttonType = "PushButton";
bitmap = "base/client/ui/button1";
lockAspectRatio = "0";
alignLeft = "0";
overflowImage = "0";
mKeepCached = "1";
mColor = "255 255 255 255";
wrap = "0";
}
);
package ServerTimeSerialize
{
function ServerSO::serialize(%this)
{
%s = Parent::serialize(%this);
%serv = getField(%s,2);
%h1 = strpos(%serv,"'s ");
%h2 = strpos(%serv,"s' ");
if(%h1 == -1)
%h1 = 999;
else if(%h2 == -1)
%h2 = 999;
if(%h1 < %h2)
{
%host = stripFirstSpaces(stripTrailingSpaces(getSubStr(%serv,0,%h1)));
%sname = stripFirstSpaces(stripTrailingSpaces(getSubStr(%serv,strLen(%server)+3,strLen(%serv)-strLen(%host)-3)));
}
else
{
%h2++;
%server = stripFirstSpaces(stripTrailingSpaces(getSubStr(%serv,0,%h2)));
%sserver = stripFirstSpaces(stripTrailingSpaces(getSubStr(%serv,strLen(%host)+2,strLen(%serv)-strLen(%host)-2)));
}
%chars = "\x09\x21\x22\x23\x24\x25\x26\x27\x28\x29\x40\x60\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99`~!@#$%^&*()-=_+[]{}\\|;:'\",./<>?";
%nch = stripFirstSpaces(stripTrailingSpaces(stripChars(%server,%chars)));
%ncs = stripFirstSpaces(stripTrailingSpaces(stripChars(%sname,%chars)));
return getFields(%s,0,1) TAB %sname TAB getFields(%s,3) TAB %server TAB %nch TAB %ncs;
}
};
activatePackage(ServerTimeSerialize);
function stripFirstSpaces(%str)
{
while(getSubStr(%str,0,1) $= " ")
%str = getSubStr(%str,1,strLen(%str)-1);
return %str;
}
When server start up. It will show server list show the time. how long the server stay up second, minutes, hour, day, week, month and year.
When the server shut down. It will deactive the server time. I did try test it. it not work.