Time::advanceClockTimeTo: Difference between revisions
(yay) |
No edit summary |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
{{ClientsideJsFunction}} | |||
{{JSContainer| | |||
==Syntax== | === Summary === | ||
<syntaxhighlight lang="javascript">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 | |||
*'''hour:''' int | === Syntax === | ||
*'''minute:''' int | <syntaxhighlight lang="javascript"> | ||
*'''second:''' int | mp.game.time.advanceClockTimeTo(hour, minute, second); | ||
===Return | </syntaxhighlight> | ||
*''' | |||
==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"> | ||
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 | }} | ||
{{ | |||
== See Also == | |||
{{Time_functions_c}} | |||
[[Category:Clientside API]] | [[Category:Clientside API]] | ||
[[Category:Time API]] | |||
[[Category:TODO: Example]] | [[Category:TODO: Example]] | ||
Latest revision as of 12:37, 10 December 2024
Client-Side Function
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}.`);
});