SetWeather: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
(11 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
This function | {{Server client function}} | ||
This function sets the current [[weather]] to the given valid value. To change the weather gradually, see [[setWeatherBlended]]. | |||
To change the weather gradually, see [[setWeatherBlended]]. | |||
==Syntax== | ==Syntax== | ||
Line 10: | Line 9: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''weatherID''': The new weather | *'''weatherID''': The ID of new [[weather]]. Valid values are 0 to 255 inclusive. | ||
===Returns=== | ===Returns=== | ||
Line 22: | Line 21: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{ | |||
<section class="server" name="Server" show="true"> | |||
This example allows you to change weather with a command. (Anything above 255 resets, so 256 will be 0 and so on) | |||
<syntaxhighlight lang="lua"> | |||
function changeWeather(player, command, weatherID) | |||
if (not weatherID or not tonumber(weatherID)) then --Check if weatherID is a number | |||
outputChatBox("You must enter a valid weather ID number", player, 255, 0, 0) | |||
return false | |||
end | |||
setWeather(weatherID) --Set the weather and let the player know he did it | |||
outputChatBox("Weather successfully changed to ID "..weatherID, player, 0, 255, 0) | |||
end | |||
addCommandHandler("weather", changeWeather) | |||
</syntaxhighlight> | |||
</section> | |||
==See Also== | |||
{{World functions}} | |||
[[ru:setWeather]] |
Latest revision as of 19:09, 21 August 2018
This function sets the current weather to the given valid value. To change the weather gradually, see setWeatherBlended.
Syntax
bool setWeather ( int weatherID )
Required Arguments
- weatherID: The ID of new weather. Valid values are 0 to 255 inclusive.
Returns
Returns true if the weather was set succesfully, false if an invalid weatherID was specified.
Example
This example will change the weather to foggy.
setWeather ( 9 ) outputChatBox ( "Weather changed to foggy!" )
Click to collapse [-]
ServerThis example allows you to change weather with a command. (Anything above 255 resets, so 256 will be 0 and so on)
function changeWeather(player, command, weatherID) if (not weatherID or not tonumber(weatherID)) then --Check if weatherID is a number outputChatBox("You must enter a valid weather ID number", player, 255, 0, 0) return false end setWeather(weatherID) --Set the weather and let the player know he did it outputChatBox("Weather successfully changed to ID "..weatherID, player, 0, 255, 0) end addCommandHandler("weather", changeWeather)
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