setDate: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Some wiki formatting)
 
(70 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma |= Game name
|game1= ofpe
|version1= 1.00


|1.00|= Game version
|game2= arma1
|version2= 1.00


|arg= local |= Arguments in MP
|game3= arma2
|version3= 1.00


|eff= local |= Effects in MP
|game4= arma2oa
|version4= 1.50


|exec= server|= Exec
|game5= tkoh
____________________________________________________________________________________________
|version5= 1.00


| Sets the actual mission date and time. |= Description
|game6= arma3
____________________________________________________________________________________________
|version6= 0.50


| '''setDate''' [year, month, day, hour, minute] |= Syntax
|eff= local


|p1= [year, month, day, hour, minute]: [[Array]] |= Parameter 1
|gr1= Mission Information


| [[Nothing]] |= Return value
|gr2= Environment
____________________________________________________________________________________________
 
|x1= <code>[[setDate]] [1986, 2, 25, 16, 0];  //(4:00pm February 25, 1986)</code> |= Example 1
|x2= Set real date: <code>//postInit = 1;
[[if]] ([[isServer]]) [[then]] {
[[waitUntil]] {[[time]] > 0};
[[setDate]] ([[missionStart]] [[select]] [0,5]);
};</code> |= Example 2
____________________________________________________________________________________________


| [[date]], [[skipTime]], [[numberToDate]], [[dateToNumber]] |= See also
|descr= Sets mission date and time. Players joining after mission start will get the current server [[date]] including the year.
{{Feature|important|
While the game creates February 29th in a leap year, it removes December 31st.<br>
For example, <sqf inline>setDate [1980,12,31,12,0]</sqf> will result in the game jumping to [1981,1,1,12,0] as 1980 is a leap year.
}}


|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: <sqf inline>[[2001,6,22,12,0]] remoteExec ["setDate"];</sqf>.
}}
}}


<h3 style="display:none">Notes</h3>
|s1= [[setDate]] date
<dl class="command_description">
<!-- Note Section BEGIN -->


<dd class="notedate">18:52, 6 October 2007 (CEST)
|p1= date: [[Array]] format [[Date]]
<dt class="note">'''[[User:Doolittle|Doolittle]]'''
<dd class="note">This command is special in that it is "smart". If you add 120 minutes, for example, it will actually advance hours by 2, and so on.


<dd class="notedate">10:00, 7/12/2010 (BST)
|r1= [[Nothing]]
<dt class="note">'''[[User:Alpha|Alpha]]'''
<dd class="note">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.


<dd class="notedate">21:35, 31 October 2011 (EET)
|x1= <sqf>setDate [1986, 2, 25, 16, 0]; // 4:00pm February 25, 1986</sqf>
<dt class="note">'''[[User:Osmo|Osmo]]'''
<dd class="note">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.


<dd class="notedate">10 September 2013 (EET)
|x2= <sqf>
<dt class="note">'''[[User:Killzone_Kid|Killzone_Kid]]'''
// Set the real date:
<dd class="note">This command is JIP compatible. Players joining after mission start will get current server [[date]] set up.
if (isServer) then
{
waitUntil { time > 0 };
[systemTime select [0, 5]] remoteExec ["setDate"];
};
</sqf>


|x3= Using [[setDate]] with an incorrect (like negative or exceeding) value will still work properly:
<sqf>
private _date = date;
_date set [3, 25]; // set hour to 25
setDate _date; // date = next day 1am
</sqf>


<!-- Note Section END -->
|seealso= [[date]] [[skipTime]] [[numberToDate]] [[dateToNumber]]
</dl>
}}


<h3 style="display:none">Bottom Section</h3>
{{Note
[[Category:Scripting Commands|SETDATE]]
|user= Alpha
[[Category:Scripting Commands OFP Elite |SETDATE]]
|timestamp= 20121207111000
[[Category:Scripting Commands ArmA|SETDATE]]
|text= 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.
[[Category:Command_Group:_Mission_Information|SETDATE]]
}}
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:Join In Progress|{{uc:{{PAGENAME}}}}]]


<!-- CONTINUE Notes -->
{{Note
<dl class="command_description">
|user= Osmo
<dd class="notedate">Posted on October 4, 2014 - 17:43 (UTC)</dd>
|timestamp= 20111031210700
<dt class="note">[[User:MulleDK13|MulleDK13]]</dt>
|text= 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.
<dd class="note">
}}
Since an unknown version of ARMA 3, this command now has global effect when executed on the server.
</dd>
</dl>
<!-- DISCONTINUE Notes -->


<!-- CONTINUE Notes -->
{{Note
<dl class="command_description">
|user= MulleDK13
<dd class="notedate">Posted on February 5, 2015 - 06:38 (UTC)</dd>
|timestamp= 20141004174300
<dt class="note">[[User:Ozdeadmeat|Ozdeadmeat]]</dt>
|text= Since an unknown version of {{arma3}}, this command now has global effect when executed on the server.
<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.
[http://feedback.arma3.com/view.php?id=22583 Feedback_Link]
</dd>
</dl>
<!-- DISCONTINUE Notes -->


<!-- CONTINUE Notes -->
{{Note
<dl class="command_description">
|user= OOKexOo
<dd class="notedate">Posted on April 23, 2017 - 02:58 (UTC)</dd>
|timestamp= 20170423025800
<dt class="note">[[User:OOKexOo|OOKexOo]]</dt>
|text= 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.
<dd class="note">
<sqf>[[], { setDate [1986, 2, 25, 16, 0] }] remoteExec ["call", 0, "JIP_id_setDate"];</sqf>  
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>
}}
<code>[[], {[[setDate]] [1986, 2, 25, 16, 0]}] [[remoteExec]] ["[[call]]",0,"JIP_id_setDate"];</code>  
</dd>
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 11:21, 26 November 2023

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.
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 the game jumping to [1981,1,1,12,0] as 1980 is a leap 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"];.
Groups:
Mission InformationEnvironment

Syntax

Syntax:
setDate date
Parameters:
date: Array format Date
Return Value:
Nothing

Examples

Example 1:
setDate [1986, 2, 25, 16, 0]; // 4:00pm February 25, 1986
Example 2:
// Set the real date: if (isServer) then { waitUntil { time > 0 }; [systemTime select [0, 5]] remoteExec ["setDate"]; };
Example 3:
Using setDate with an incorrect (like negative or exceeding) value will still work properly:
private _date = date; _date set [3, 25]; // set hour to 25 setDate _date; // date = next day 1am

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
Alpha - c
Posted on Dec 07, 2012 - 11:10 (UTC)
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.
Osmo - c
Posted on Oct 31, 2011 - 21:07 (UTC)
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.
MulleDK13 - c
Posted on Oct 04, 2014 - 17:43 (UTC)
Since an unknown version of Arma 3, this command now has global effect when executed on the server.
OOKexOo - c
Posted on Apr 23, 2017 - 02:58 (UTC)
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"];