Time::setClockTime

From RAGE Multiplayer Wiki

Client-Side
Function

 JavaScript



JavaScript Syntax


Summary

Sets the in-game clock to a specific hour, minute, and second. This function is useful for synchronizing game time with real-world or custom timelines.

Syntax

mp.game.time.setClockTime(hour, minute, second);

Required Parameters

  • hour: int - The hour (0–23).
  • minute: int - The minute (0–59).
  • second: int - The second (0–59).

Return Value

  • undefined - No value is returned.

Example

This example synchronizes the in-game clock with real-world time:

const syncTime = () => {
    const date = new Date();
    mp.game.time.setClockTime(date.getHours(), date.getMinutes(), date.getSeconds());
};
setInterval(syncTime, 2000); // Update clock every 2 seconds
mp.gui.chat.push("The in-game time is now synchronized with real-world time.");


See Also