SetTime: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 4: Line 4:


==Syntax==
==Syntax==
<section name="Server and Client" class="both" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setTime ( int hour, int minute )
bool setTime ( int hour, int minute )
Line 15: Line 14:
==Returns==
==Returns==
Returns ''true'' if the new time was successfully set, ''false'' otherwise.
Returns ''true'' if the new time was successfully set, ''false'' otherwise.
</section>


==Example==
==Example==

Revision as of 12:55, 12 August 2010

This function sets the current GTA time to the given time.

Syntax

bool setTime ( int hour, int minute )

Required Arguments

  • hour: The hour of the new time (range 0-23).
  • minute: The minute of the new time (range 0-59).

Returns

Returns true if the new time was successfully set, false otherwise.

Example

This serverside function sets the time and notifies players.

Click to collapse [-]
Server
function setTimeAndNotify( hour, minute )
	-- set the time first
	setTime ( hour, minute )
	-- format a notification message, adding leading zeros (e.g. 12:03 instead of 12:3)
	local notifyMessage = string.format("Time changed to %02d:%02d!", hour, minute)
	-- output the message
	outputChatBox ( notifyMessage )
end

See Also