SetTime: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(Added sections, minor fixes, replaced example) |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | {{Server client function}} | ||
This function sets the current time to the given time | This function sets the current GTA time to the given time. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">setTime ( int hour, int minute )</syntaxhighlight> | <section name="Server and Client" class="both" show="true"> | ||
<syntaxhighlight lang="lua"> | |||
bool setTime ( int hour, int minute ) | |||
</syntaxhighlight> | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''hour''': The hour of the new time (range 0-23) | *'''hour''': The hour of the new time (range 0-23). | ||
*'''minute''': The minute of the new time (range 0-59) | *'''minute''': The minute of the new time (range 0-59). | ||
==Returns== | ==Returns== | ||
Returns ''true'' if | Returns ''true'' if the new time was successfully set, ''false'' otherwise. | ||
</section> | |||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> setTime ( | This serverside function sets the time and notifies players. | ||
<section name="Example" class="server" show="true"> | |||
<syntaxhighlight lang="lua"> | |||
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 | |||
</syntaxhighlight> | |||
</section> | |||
==See Also== | ==See Also== | ||
{{World functions}} | {{World functions}} |
Revision as of 19:40, 26 August 2007
This function sets the current GTA time to the given time.
Syntax
Click to collapse [-]
Server and Clientbool 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 [-]
Examplefunction 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
- areTrafficLightsLocked
- getAircraftMaxHeight
- getAircraftMaxVelocity
- getCloudsEnabled
- getFarClipDistance
- getFogDistance
- getGameSpeed
- getGravity
- getHeatHaze
- getInteriorSoundsEnabled
- getJetpackMaxHeight
- getMinuteDuration
- getMoonSize
- getOcclusionsEnabled
- getRainLevel
- getSunColor
- getSunSize
- getTime
- getTrafficLightState
- getWeather
- getWindVelocity
- getSkyGradient
- getPlayerBlurLevel
- getZoneName
- isGarageOpen
- removeWorldModel
- resetFarClipDistance
- resetFogDistance
- resetHeatHaze
- resetMoonSize
- resetRainLevel
- resetSkyGradient
- resetSunColor
- resetSunSize
- resetWindVelocity
- restoreAllWorldModels
- restoreWorldModel
- setAircraftMaxHeight
- setAircraftMaxVelocity
- setCloudsEnabled
- setFarClipDistance
- setFogDistance
- setGameSpeed
- setGarageOpen
- setGravity
- setHeatHaze
- setInteriorSoundsEnabled
- setMinuteDuration
- setMoonSize
- setOcclusionsEnabled
- setRainLevel
- setSkyGradient
- setSunColor
- setSunSize
- setTime
- setTrafficLightState
- setTrafficLightsLocked
- setWeather
- setWeatherBlended
- setWindVelocity
- setJetpackMaxHeight
- setPlayerBlurLevel