GetRealTime

From Multi Theft Auto: Wiki
Revision as of 12:58, 28 November 2007 by Lil Toady (talk | contribs) (New page: __NOTOC__ {{Server client function}} This function gets the real server time and returns it in a table ==Syntax== <syntaxhighlight lang="lua">table getCTime()</syntaxhighlight> ===Returns=== Returns a ''table'' o...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This function gets the real server time and returns it in a table

Syntax

table getCTime()

Returns

Returns a table of substrings with different time format, false otherwise.

Member Meaning Range
tm_sec seconds after the minute 0-61*
tm_min minutes after the hour 0-59
tm_hour hours since midnight 0-23
tm_mday day of the month 1-31
tm_mon months since January 0-11
tm_year years since 1900
tm_wday days since Sunday 0-6
tm_yday days since January 1 0-365
tm_isdst Daylight Saving Time flag
  • tm_sec is generally 0-59. Extra range to accommodate for leap seconds in certain systems.

Example

Click to collapse [-]
Server

This example gives the specified weapons to the given player, while the weapons are a string in the form: 'weaponId,ammo;weaponId2,ammo2;weaponId3,ammo3;..'. This is especially for data read from a .map file attribute.

function showtime ()
	local time = getCTime()
	local hours = time.tm_hour
	local minutes = time.tm_min
	outputChatBox ( "Local Time: "..hours..":"..minutes )
end

See Also