Skip to main content

Gameplay::setWeatherTypeOverTime

This function transitions the weather from one weather type to another over the specified amount of time in seconds.

For example, it is now EXTRASUNNY. The weather is now transitioning to THUNDER over 60 minutes. Rain will slowly start and clouds will slowly form over the time of 1 hour, rather than it being instant like World::weather

You only have to specify the new weather.

Syntax​

mp.game.gameplay.setWeatherTypeOverTime(weatherType, time);

Required Arguments​

  • weatherType: String
  • time: float

Return value​

  • Undefined

Example​

This example will call the client-side event 'transitionWeather' for the every player, to synchronise the weather. This gradually transitions the weather over x seconds, not milliseconds.

Client-Side

//newWeather - string, any of weather / timeTaken - time taken to transition from old weather to new weather in seconds

mp.events.add('transitionWeather', (newWeather, timeTaken) => {
mp.game.gameplay.setWeatherTypeOverTime(newWeather, timeTaken);
});

Server-Side

//In a setweather command for example with params 'params.weather' and 'params.time'

mp.players.forEach((player) => {
player.call('transitionWeather', [params.weather, params.time])
});