Time::advanceClockTimeTo: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
No edit summary
 
Line 1: Line 1:
{{ClientsideJsFunction}}
{{JSContainer|


==Syntax==
=== Summary ===
<syntaxhighlight lang="javascript">mp.game.time.advanceClockTimeTo(hour, minute, second);</syntaxhighlight>
Sets the in-game clock to a specific time by advancing it to the specified hour, minute, and second.
=== Required Arguments ===
 
*'''hour:''' int
=== Syntax ===
*'''minute:''' int
<syntaxhighlight lang="javascript">
*'''second:''' int
mp.game.time.advanceClockTimeTo(hour, minute, second);
===Return value===
</syntaxhighlight>
*'''Undefined'''
 
==Example==
=== Required Parameters ===
* '''hour:''' {{RageType|int}} - The hour to set (0-23).
* '''minute:''' {{RageType|int}} - The minute to set (0-59).
* '''second:''' {{RageType|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:
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
// todo
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}.`);
});
</syntaxhighlight>
</syntaxhighlight>
==See also==
}}
{{Time_s_function_c}}
 
== See Also ==
{{Time_functions_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:Time API]]
[[Category:Time API]]
[[Category:TODO: Example]]
[[Category:TODO: Example]]

Latest revision as of 12:37, 10 December 2024

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