From Multi Theft Auto: Wiki
Jump to navigation Jump to search

This function sets the current weather to the given valid value. To change the weather gradually, see setWeatherBlended.


bool setWeather ( int weatherID )

Required Arguments

  • weatherID: The ID of new weather. Valid values are 0 to 255 inclusive.


Returns true if the weather was set succesfully, false if an invalid weatherID was specified.


This example will change the weather to foggy.

setWeather ( 9 )
outputChatBox ( "Weather changed to foggy!" )

Click to collapse [-]

This 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
	setWeather(weatherID) --Set the weather and let the player know he did it
	outputChatBox("Weather successfully changed to ID "..weatherID, player, 0, 255, 0)
addCommandHandler("weather", changeWeather)

See Also