Home FiveM Creating a Custom Weather and Time Control System on a FiveM Server

Creating a Custom Weather and Time Control System on a FiveM Server

Last updated on Feb 13, 2025

In this tutorial, you'll learn how to create a custom weather and time control system for your FiveM server using the VolticHost Game Panel. This system enables administrators to dynamically change the in-game weather and time via chat commands, enhancing the immersive roleplay experience. 🚀


📌 Prerequisites

  • A FiveM server purchased at VolticHost.com

  • Access to the VolticHost Game Panel

  • Basic knowledge of Lua scripting and FiveM resource management

  • Familiarity with file editing via the File Manager


1️⃣ First Step - Creating Your Weather and Time Control Resource

  1. Log in to VolticHost Game Panel.

  2. Navigate to the File Manager from the main dashboard.

  3. Go to the /resources/ directory.

  4. Create a new folder named weather_time_control.

  5. Inside the weather_time_control folder, create a new file named fxmanifest.lua and add the following content:

    fx_version 'cerulean'
    game 'gta5'
    
    author 'YourName'
    description 'Custom Weather and Time Control System'
    version '1.0.0'
    
    client_script 'weather_time_control_client.lua'
    server_script 'weather_time_control_server.lua'
    
  6. Create two additional files in the same folder: weather_time_control_client.lua and weather_time_control_server.lua.

Resource folder and manifest created successfully!


2️⃣ Next Step - Uploading and Editing the Script Files

A. Server-Side Script (weather_time_control_server.lua)

  1. Open weather_time_control_server.lua for editing and paste the following code:

    -- weather_time_control_server.lua
    
    RegisterCommand("setweather", function(source, args, rawCommand)
        local weather = args[1]
        if not weather then
            TriggerClientEvent('chat:addMessage', source, { args = { "Weather Control", "Usage: /setweather [weatherType]" } })
            return
        end
    
        -- Broadcast the weather change to all players
        TriggerClientEvent("weather_time_control:setWeather", -1, weather)
        TriggerClientEvent('chat:addMessage', source, { args = { "Weather Control", "Weather changed to " .. weather } })
    end, true)
    
    RegisterCommand("settime", function(source, args, rawCommand)
        local hour = tonumber(args[1])
        local minute = tonumber(args[2])
        if hour == nil or minute == nil then
            TriggerClientEvent('chat:addMessage', source, { args = { "Time Control", "Usage: /settime [hour] [minute]" } })
            return
        end
    
        -- Broadcast the time change to all players
        TriggerClientEvent("weather_time_control:setTime", -1, hour, minute)
        TriggerClientEvent('chat:addMessage', source, { args = { "Time Control", "Time set to " .. hour .. ":" .. minute } })
    end, true)
    
  2. Save the file.

B. Client-Side Script (weather_time_control_client.lua)

  1. Open weather_time_control_client.lua for editing and paste the following code:

    -- weather_time_control_client.lua
    
    RegisterNetEvent("weather_time_control:setWeather")
    AddEventHandler("weather_time_control:setWeather", function(weather)
        SetWeatherTypeNowPersist(weather)
        SetWeatherTypeNow(weather)
        SetOverrideWeather(weather)
        print("Weather set to " .. weather)
    end)
    
    RegisterNetEvent("weather_time_control:setTime")
    AddEventHandler("weather_time_control:setTime", function(hour, minute)
        NetworkOverrideClockTime(hour, minute, 0)
        print("Time set to " .. hour .. ":" .. minute)
    end)
    
  2. Save the file.

Server and client scripts uploaded and saved successfully!


3️⃣ Next Step - Adding the Resource to Your Server Configuration

  1. In the VolticHost Game Panel, open the server.cfg file from your FiveM server's root directory.

  2. Add the following line to start your new resource:

    start weather_time_control
    
  3. Save the changes.

Resource added to server configuration successfully!


4️⃣ Next Step - Testing and Refining Your Weather & Time Control System

  1. Restart your server from the VolticHost Game Panel to load the new resource.

  2. Join your server and open the in-game chat/console.

  3. Test the weather command by typing:

    /setweather CLEAR
    

    (Replace CLEAR with any valid weather type like RAIN, FOGGY, etc.)

  4. Test the time command by typing:

    /settime 15 30
    

    This should set the in-game time to 3:30 PM.

  5. Verify that the changes are reflected in-game and adjust your script if necessary.

Weather and time control system tested and refined successfully!


🎉 Conclusion

You have now successfully created a custom weather and time control system on your FiveM server using the VolticHost Game Panel! Enhance your roleplay environment by dynamically adjusting weather and time to suit your server's narrative. 🚀

For more assistance, contact VolticHost Support.