GetTime: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 10: | Line 10: | ||
==Example== | ==Example== | ||
These two examples adds the command ''gettime'' which outputs the local game time and the server game time. | |||
<section name="Client" class="client" show="true"> | <section name="Client" class="client" show="true"> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function currentTime() | function currentTime() | ||
local hour, minutes = getTime() | local hour, minutes = getTime() | ||
outputChatBox( "The current time is "..hour..":"..minutes ) | outputChatBox( "The current game time is "..hour..":"..minutes ) | ||
end | |||
addCommandHandler("gettime", currentTime) | |||
</syntaxhighlight> | |||
</section> | |||
<section name="Server" class="server" show="true"> | |||
<syntaxhighlight lang="lua"> | |||
function currentTime(sourcePlayer) | |||
local hour, minutes = getTime() | |||
outputChatBox( "The current game time (server) is "..hour..":"..minutes, sourcePlayer ) | |||
end | end | ||
addCommandHandler("gettime", currentTime) | addCommandHandler("gettime", currentTime) |
Revision as of 09:16, 5 April 2012
This function is used to get the current time in the game. If you want to get the real server time, use getRealTime.
Syntax
int int getTime ()
Returns
Returns two ints that represent hours and minutes.
Example
These two examples adds the command gettime which outputs the local game time and the server game time.
Click to collapse [-]
Clientfunction currentTime() local hour, minutes = getTime() outputChatBox( "The current game time is "..hour..":"..minutes ) end addCommandHandler("gettime", currentTime)
Click to collapse [-]
Serverfunction currentTime(sourcePlayer) local hour, minutes = getTime() outputChatBox( "The current game time (server) is "..hour..":"..minutes, sourcePlayer ) end addCommandHandler("gettime", currentTime)
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