Time::advanceClockTimeTo

From RAGE Multiplayer Wiki
Revision as of 12:37, 10 December 2024 by Shr0x (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Client-Side
Function

 JavaScript



JavaScript Syntax


Summary

Sets the in-game clock to a specific time by advancing it to the specified hour, minute, and second.

Syntax

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

Required Parameters

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

Return Value

  • undefined - This function does not return a value.

Example

The following example sets the time to a specified value via event trigger:

mp.events.add("settime", (player, _, hour, minute, second) => {
    hour = parseInt(hour) || 0;
    minute = parseInt(minute) || 0;
    second = parseInt(second) || 0;

    mp.game.time.advanceClockTimeTo(hour, minute, second);
    mp.gui.chat.push(`The time has been set to ${hour}:${minute}:${second}.`);
});


See Also