SetTime: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 4: | Line 4: | ||
==Syntax== | ==Syntax== | ||
<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. | ||
==Example== | ==Example== | ||
<section name="Example 1" class="server" show="true"> | |||
This serverside function sets the time and notifies players. | This serverside function sets the time and notifies players. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function setTimeAndNotify( hour, minute ) | function setTimeAndNotify( hour, minute ) | ||
Line 29: | Line 27: | ||
outputChatBox ( notifyMessage ) | outputChatBox ( notifyMessage ) | ||
end | end | ||
</syntaxhighlight> | |||
</section> | |||
<section name="Example 2" class="client" show="true"> | |||
This example freeze the time. | |||
<syntaxhighlight lang="lua"> | |||
addEventHandler( 'onClientRender', root, | |||
function( ) | |||
setTime( 1, 0 ) | |||
end | |||
) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> |
Latest revision as of 07:46, 4 November 2020
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
Click to collapse [-]
Example 1This serverside function sets the time and notifies players.
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
Click to collapse [-]
Example 2This example freeze the time.
addEventHandler( 'onClientRender', root, function( ) setTime( 1, 0 ) 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