Time::setClockTime: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
No edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
SET_CLOCK_TIME(12, 34, 56);
{{ClientsideJsFunction}}
==Syntax==
{{JSContainer|
<syntaxhighlight lang="javascript">mp.game.time.setClockTime(hour, minute, second);</syntaxhighlight>
 
=== Required Arguments ===
=== Summary ===
*'''hour:''' int
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.
*'''minute:''' int
 
*'''second:''' int
=== Syntax ===
===Return value===
*'''Undefined'''
==Example==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
// todo
mp.game.time.setClockTime(hour, minute, second);
</syntaxhighlight>
</syntaxhighlight>
==See also==
 
{{Time_s_function_c}}
=== Required Parameters ===
* '''hour:''' {{RageType|int}} - The hour (0–23).
* '''minute:''' {{RageType|int}} - The minute (0–59).
* '''second:''' {{RageType|int}} - The second (0–59).
 
=== Return Value ===
* '''undefined''' - No value is returned.
 
=== Example ===
This example synchronizes the in-game clock with real-world time:
<syntaxhighlight lang="javascript">
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.");
</syntaxhighlight>
}}
 
== See Also ==
{{Time_functions_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:Time API]]
[[Category:Time API]]
[[Category:TODO: Example]]

Latest revision as of 12:44, 10 December 2024

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