World::time.set: Difference between revisions

From RAGE Multiplayer Wiki
(Init)
 
No edit summary
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__NOTOC__
__TOC__
 
{{ServersideJsFunction}}
 
This function sets time.
This function sets time.


==Params==
{{JSContainer|
<span style="color: green;">'''int'''</span> '''hour''' (0 - 23)<br />
== Syntax ==
<span style="color: green;">'''int'''</span> '''minute''' (0 - 59)<br />
<pre>
<span style="color: green;">'''int'''</span> '''second''' (0 - 59)
mp.world.time.set(hour, minute, second);
</pre>
 
== Required Arguments ==
*{{Required}}'''hour''': {{RageType|Int}} (0 - 23)
*{{Required}}'''minute''': {{RageType|Int}} (0 - 59)
*{{Required}}'''second''': {{RageType|Int}} (0 - 59)


==Example==
==Example==
<syntaxhighlight lang="javascript">
In this example, we will set a custom time via command (e.g. 12:20:10 -> /time 12 20 10).
mp.world.time.set(hour, minute, second);
{{ServersideCode|
</syntaxhighlight>
<pre>
mp.events.addCommand('time', (player, fulltext, hour, minute, second) => mp.world.time.set(hour, minute, second));
</pre>
}}
You can also set time by changing its properties and then call 'set' function without parameters.
{{ServersideCode|
<pre>
mp.events.addCommand('lunchtime', (player)) => {
    mp.world.time.hour = 16;
    mp.world.time.minute = 0;
    mp.world.time.second = 0;
    mp.world.time.set();
});
</pre>
}}
}}


==See Also==
==See Also==
{{World_definition}}
{{World_definition}}

Latest revision as of 23:52, 7 January 2020

Server-Side
Function

 JavaScript



This function sets time.

JavaScript Syntax

Syntax

mp.world.time.set(hour, minute, second);

Required Arguments

  • *hour: Int (0 - 23)
  • *minute: Int (0 - 59)
  • *second: Int (0 - 59)

Example

In this example, we will set a custom time via command (e.g. 12:20:10 -> /time 12 20 10).

Server-Side
mp.events.addCommand('time', (player, fulltext, hour, minute, second) => mp.world.time.set(hour, minute, second));

You can also set time by changing its properties and then call 'set' function without parameters.

Server-Side
mp.events.addCommand('lunchtime', (player)) => {
    mp.world.time.hour = 16;
    mp.world.time.minute = 0;
    mp.world.time.second = 0;
    mp.world.time.set();
});


See Also