SetWeather

From Wiki G1R-MP G1 Remake Multiplayer
Revision as of 09:12, 8 August 2026 by QCherry (talk | contribs) (Automatyczna aktualizacja dokumentacji funkcji)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

setWeather

Changes the authoritative weather and replicates it to every connected player.

Syntax

bool setWeather(string weather [, int transitionMs = 3000])

Parameters

Name Type Required Description
weather string yes One of sunny, cloudy, rain1, rain2, or rain3.
transitionMs int no Transition duration from 0 to 300000 milliseconds. Defaults to 3000; 0 applies an immediate transition.

Returns

Returns true when the weather name and transition are accepted; otherwise returns false.

Examples

Example 1

Create a five-second transition into a storm:

if not setWeather("rain3", 5000) then
    outputDebugString("The server rejected the weather change")
end

Example 2

Register a simple sunny-weather command:

addCommandHandler("sunny", function(playerId)
    if setWeather("sunny", 3000) then
        outputChatBox("Clear weather enabled.", playerId)
    end
end)

Notes

  • Available only in server-side resource scripts.
  • The new state is retained for late joiners.
  • A successful change increments the weather revision and triggers onWeatherChange.