Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: MacTavish on Oct 24, 2015, 07:28 PM

Title: [Snippet] Host Time (aka hoston)
Post by: MacTavish on Oct 24, 2015, 07:28 PM
First i will Thank to @Rocky and @Thijn for an useful function GetTimeFormat

I know it isn't hard to made for us but it would be really hard to made for newbies so i made it :)

Main.nut
onScriptLoad()
{
Start <-0;
Start = time();
}

Command:
if (cmd=="hoston")
{
local time_taken = time()-Start;
Message("Server Host Time "+GetTimeFormat(time_taken));
}

function GetTimeFormat( secs )
{
                local nDays, nHours, nMinutes, nMonths, nYears, nTime = "";
nYears = secs/31536000;
secs = secs%31536000;
nMonths = secs/2678400;
secs = secs%2678400;
nDays = secs/86400;
secs = secs%86400;
nHours = secs/3600;
secs = secs%3600;
nMinutes = secs/60;
secs = secs%60;
if( nYears != 0 ) nTime = nTime + nYears + " Year" + (nYears > 1 ? "s":"");
if( nMonths != 0 ) nTime = nTime + (nTime != "" ? ", ":"") + nMonths + " Month" + (nMonths > 1 ? "s":"");
if( nDays != 0 ) nTime = nTime  + (nTime != "" ? ", ":"") + nDays + " Day" + (nDays > 1 ? "s":"");
if( nHours != 0 ) nTime = nTime + (nTime != "" ? ", ":"") + nHours + " Hour" + (nHours > 1 ? "s":"");
if( nMinutes != 0 ) nTime = nTime +  (nTime != "" ? ", ":"") + nMinutes + " Minute" + (nMinutes > 1 ? "s":"");
if( secs != 0 ) nTime = nTime + (nTime != "" ? ", ":"") + secs + " Second" + (secs > 1 ? "s":"");
return nTime;
}

Update: Changed time() with GetTickCount()
Title: Re: [Snippet] Host Time (aka hoston)
Post by: Cool on Oct 24, 2015, 07:31 PM
Good Work
Title: Re: [Snippet] Host Time (aka hoston)
Post by: Thijn on Oct 24, 2015, 08:04 PM
You should use the time() function for this. GetTickCount will stop working after your server has been online for 49.7 days, because of the millisecond accuracy. You're calculating with seconds anyways, so why do the extra calculation.
Title: Re: [Snippet] Host Time (aka hoston)
Post by: Xmair on Oct 25, 2015, 07:26 AM
Good work.
If not DNUS
Title: Re: [Snippet] Host Time (aka hoston)
Post by: KAKAN on Oct 25, 2015, 07:27 AM
Nice work.
But SLC already did it in an easy way :)
Title: Re: [Snippet] Host Time (aka hoston)
Post by: MacTavish on Oct 25, 2015, 09:55 AM
@Thijn i changed to time but i cant test it atm so can you tell me that does it works
Title: Re: [Snippet] Host Time (aka hoston)
Post by: Thijn on Oct 25, 2015, 09:58 AM
Probably, yes.
Title: Re: [Snippet] Host Time (aka hoston)
Post by: SAzEe21 on Oct 25, 2015, 10:37 AM
Great work.
Title: Re: [Snippet] Host Time (aka hoston)
Post by: Mr.Dip 2020 on Dec 16, 2020, 04:41 PM
does this mean we can host our server in the master list?
Title: Re: [Snippet] Host Time (aka hoston)
Post by: Inferno on Dec 16, 2020, 06:35 PM
Quote from: Mr.Dip 2020 on Dec 16, 2020, 04:41 PMdoes this mean we can host our server in the master list?

You just bumped a 5 years old post to ask that?
._.

Host Time is the uptime to check the time since when the server is up / hosted.

To show your server in masterlist, you need announce plugin and port forwarded internet ( if local hosted ) or VPS
Title: Re: [Snippet] Host Time (aka hoston)
Post by: umar4911 on Dec 17, 2020, 04:01 AM
Quote from: Inferno on Dec 16, 2020, 06:35 PM
Quote from: Mr.Dip 2020 on Dec 16, 2020, 04:41 PMdoes this mean we can host our server in the master list?

You just bumped a 5 years old post to ask that?
._.

Host Time is the uptime to check the time since when the server is up / hosted.

To show your server in masterlist, you need announce plugin and port forwarded internet ( if local hosted ) or VPS
O B V I O U S L Y
Title: Re: [Snippet] Host Time (aka hoston)
Post by: MacTavish on Dec 19, 2020, 04:16 PM
Quote from: Inferno on Dec 16, 2020, 06:35 PM
Quote from: Mr.Dip 2020 on Dec 16, 2020, 04:41 PMdoes this mean we can host our server in the master list?

Host Time is the uptime to check the time since when the server is up / hosted.

To show your server in masterlist, you need announce plugin and port forwarded internet ( if local hosted ) or VPS

TOPIC LOCKED