SetMinuteDuration: Difference between revisions
Jump to navigation
Jump to search
(New page: __NOTOC__ {{Client function}} Sets the real-world duration of an ingame minute. The GTA default is 1000. ==Syntax== <syntaxhighlight lang="lua"> bool setMinuteDuration ( int milliseconds ) </syntaxhighlight> ===Req...) |
mNo edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{ | {{Server client function}} | ||
Sets the real-world duration of an ingame minute. The GTA default is 1000. | Sets the real-world duration of an ingame minute. The GTA default is 1000. | ||
Line 17: | Line 17: | ||
This example will make the ingame time correspond to the real-world time of the server. | This example will make the ingame time correspond to the real-world time of the server. | ||
Server | <section class="server" name="Server" show="true"> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function syncRealTime(player) | function syncRealTime(player) | ||
Line 40: | Line 40: | ||
addEventHandler("onPlayerJoin", getRootElement(), playerJoin) | addEventHandler("onPlayerJoin", getRootElement(), playerJoin) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
Client | <section class="client" name="Client" show="true"> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function syncRealTime(h, m) | function syncRealTime(h, m) | ||
Line 53: | Line 54: | ||
addEventHandler("doSyncRealTime", getRootElement(), syncRealTime) | addEventHandler("doSyncRealTime", getRootElement(), syncRealTime) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{ | {{World_functions}} |
Revision as of 13:10, 30 May 2009
Sets the real-world duration of an ingame minute. The GTA default is 1000.
Syntax
bool setMinuteDuration ( int milliseconds )
Required Arguments
- milliseconds: the new duration of an ingame minute
Returns
Returns true if successful, false otherwise.
Example
This example will make the ingame time correspond to the real-world time of the server.
Click to collapse [-]
Serverfunction syncRealTime(player) -- get the current real time and send it to the player local realtime = getRealTime() triggerClientEvent(player, "doSyncRealTime", getRootElement(), realtime.hour, realtime.minute) end function resourceStart() -- when the resource starts, send the real time to all players currently in the server local players = getElementsByType("player") for i,player in ipairs(players) do syncRealTime(player) end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), resourceStart) function playerJoin() -- send the real time to joining players syncRealTime(source) end addEventHandler("onPlayerJoin", getRootElement(), playerJoin)
Click to collapse [-]
Clientfunction syncRealTime(h, m) -- set the ingame time setTime(h, m) -- make ingame time progress at the same rate as real time (60 seconds per minute) setMinuteDuration(60000) end -- attach the above function to the doSyncRealTime event addEvent("doSyncRealTime", true) addEventHandler("doSyncRealTime", getRootElement(), syncRealTime)
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