setDate: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " \{\{GameCategory *\| *arma1 *\| *(New )?Scripting Commands\}\}" to "")
m (Text replacement - "<dd class="note">([^}]*)<code>([^<]*)<\/code>" to "<dd class="note">$1<sqf>$2</sqf>")
(22 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{RV|type=command
{{RV|type=command


|game1= arma1
|game1= ofpe
|version1= 1.00
|version1= 1.00
|game2= arma1
|version2= 1.00
|game3= arma2
|version3= 1.00
|game4= arma2oa
|version4= 1.50
|game5= tkoh
|version5= 1.00
|game6= arma3
|version6= 0.50


|eff= local
|eff= local
Line 14: Line 29:
|mp= {{Feature|arma3 |Clients' local date is [[Multiplayer Scripting#Join In Progress|automatically and periodically synchronised]] with the server date.<br>
|mp= {{Feature|arma3 |Clients' local date is [[Multiplayer Scripting#Join In Progress|automatically and periodically synchronised]] with the server date.<br>
In order to change the date without waiting for automatic synchronisation, use remote execution: {{ic|[<nowiki/>[2001,6,22,12,0]] [[remoteExec]] ["setDate"];}}}}
In order to change the date without waiting for automatic synchronisation, use remote execution: {{ic|[<nowiki/>[2001,6,22,12,0]] [[remoteExec]] ["setDate"];}}}}
{{Feature | Warning | While the game creates February 29th in a leap year, it removes December 31st. For example [[setDate]] [1980,12,31,12,0] will result in game jumping to [1981,1,1,12,0] as 1980 is a leap year.}}


|s1= [[setDate]] date
|s1= [[setDate]] date
Line 21: Line 37:
|r1= [[Nothing]]
|r1= [[Nothing]]


|x1= <code>[[setDate]] [1986, 2, 25, 16, 0]; {{cc|4:00pm February 25, 1986}}</code>
|x1= <sqf>setDate [1986, 2, 25, 16, 0]; // 4:00pm February 25, 1986</sqf>


|x2=  
|x2= <sqf>// Set the real date (MP only):// postInit {{= 1;}}
<code>{{cc|Set the real date (MP only):}}{{cc|postInit {{=}} 1;}}
if (isServer) then
[[if]] ([[isServer]]) [[then]]
{
{
[[waitUntil]] {[[time]] > 0};
waitUntil {time > 0};
[<nowiki/>[[missionStart]] [[select]] [0,5]] [[remoteExec]] ["setDate"];
[missionStart select [0,5]] remoteExec ["setDate"];
};</code>
};</sqf>


|seealso= [[date]], [[skipTime]], [[numberToDate]], [[dateToNumber]]
|seealso= [[date]] [[skipTime]] [[numberToDate]] [[dateToNumber]]
}}
}}


Line 50: Line 65:
<dd class="note">
<dd class="note">
Since an unknown version of {{arma3}}, this command now has global effect when executed on the server.
Since an unknown version of {{arma3}}, this command now has global effect when executed on the server.
</dd>
<dt><dt>
<dd class="notedate">Posted on February 5, 2015 - 06:38 (UTC)</dd>
<dt class="note">[[User:Ozdeadmeat|Ozdeadmeat]]</dt>
<dd class="note">
Arma 3 1.38.128937- Leapyear BUG - setdate [2016,12,31,23,59] yields an ingame date of the 1st of January 2017. If left to tick over from the 30th of December it ticks to 1st January skipping the 31st of December entirely.
</dd>
</dd>


Line 63: Line 71:
<dt class="note">[[User:OOKexOo|OOKexOo]]</dt>
<dt class="note">[[User:OOKexOo|OOKexOo]]</dt>
<dd class="note">
<dd class="note">
Regarding execution in the middle of a session, the post of [[User:MulleDK13|MulleDK13]] is not entirely true. If you don't change the year, you are perfectly fine when executing the command on the server only. However, the server does not sync the year. Hence, if you do change the year, you have to execute the command on the server, clients and JIP to account for the missing sync. e.g.<br>
Regarding execution in the middle of a session, the post of [[User:MulleDK13|MulleDK13]] is not entirely true. If you don't change the year, you are perfectly fine when executing the command on the server only. However, the server does not sync the year. Hence, if you do change the year, you have to execute the command on the server, clients and JIP to account for the missing sync. e.g.
<code>[[], {[[setDate]] [1986, 2, 25, 16, 0]}] [[remoteExec]] ["[[call]]",0,"JIP_id_setDate"];</code>  
<sqf>[[], {setDate [1986, 2, 25, 16, 0]}] remoteExec ["call",0,"JIP_id_setDate"];</sqf>  
</dd>
</dd>


</dl>
</dl>
{{GameCategory|ofpe|Scripting Commands}}
{{GameCategory|arma2|Scripting Commands}}
{{GameCategory|arma3|Scripting Commands}}
{{GameCategory|tkoh|Scripting Commands}}

Revision as of 11:57, 13 May 2022

Hover & click on the images for description

Description

Description:
Sets mission date and time. Players joining after mission start will get the current server date including the year.
Multiplayer:
Arma 3
Clients' local date is automatically and periodically synchronised with the server date.
In order to change the date without waiting for automatic synchronisation, use remote execution: [[2001,6,22,12,0]] remoteExec ["setDate"];
While the game creates February 29th in a leap year, it removes December 31st. For example setDate [1980,12,31,12,0] will result in game jumping to [1981,1,1,12,0] as 1980 is a leap year.
Groups:
Mission InformationEnvironment

Syntax

Syntax:
setDate date
Parameters:
date: Date - format [year, month, day, hour, minute]
Return Value:
Nothing

Examples

Example 1:
setDate [1986, 2, 25, 16, 0]; // 4:00pm February 25, 1986
Example 2:
// Set the real date (MP only):// postInit Template:= 1; if (isServer) then { waitUntil {time > 0}; [missionStart select [0,5]] remoteExec ["setDate"]; };

Additional Information

See also:
date skipTime numberToDate dateToNumber

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
10:00, 7/12/2010 (BST)
Alpha
This command sets the date for the southern hemisphere only, i.e. when the map is in northern hemisphere a date [2010,12,7,17,0] is in day light and and date [2010,6,7,17,0] is in darkness.
21:35, 31 October 2011 (EET)
Osmo
In multiplayer, the effect of this command is local, not global. The date from the server is synchronized with clients when they join the game (including start of the mission and joining in progress). E.g. if this command is executed on server in the init.sqf before the mission starts, every client will be synchronized with server as mission is started. However, if you run this command in the middle of the mission, effect is local.
Posted on October 4, 2014 - 17:43 (UTC)
MulleDK13
Since an unknown version of Arma 3, this command now has global effect when executed on the server.
Posted on April 23, 2017 - 02:58 (UTC)
OOKexOo
Regarding execution in the middle of a session, the post of MulleDK13 is not entirely true. If you don't change the year, you are perfectly fine when executing the command on the server only. However, the server does not sync the year. Hence, if you do change the year, you have to execute the command on the server, clients and JIP to account for the missing sync. e.g.
[[], {setDate [1986, 2, 25, 16, 0]}] remoteExec ["call",0,"JIP_id_setDate"];