paramsArray: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Wikilink JIP)
m (Obsolete and uncategorized page linked to the full description)
Line 1: Line 1:
If ''class Params'' is defined in [[description.ext]], a simple "Parameters" GUI becomes available in Multiplayer which allows the host (or admin on dedicated server) to define custom mission parameters before mission start. These params will become available to all mission scripts via [[paramsArray]] variable, which contains [[Array]] of values selected via "Parameters" GUI.
#redirect [[Arma_3_Mission_Parameters]]
 
<gallery>
File:params.png|"Parameters" GUI
File:params_options.png|Available Options
File:params_edit.png|Editing Options
</gallery>
 
<syntaxhighlight lang="javascript">class Params
{
class paramsArray_select_0
{
title = "Item 1"; //item name
texts[] = {"One","Two","Three"}; //item text options (visible)
values[] = {1,2,3}; //item value options (can only be integers)
default = 1; //actual value (in values[]) to be set as default
};
class paramsArray_select_1
{
title = "Item 2";
texts[] = {"Ten","Twenty","Thirty"};
values[] = {10,20,30};
default = 20;
};
class paramsArray_select_2
{
title = "Item 3";
texts[] = {"One Hundred","Two Hundred","Three Hundred"};
values[] = {100,200,300};
default = 300;
};
//default value of paramsArray is [1,20,300]
};</syntaxhighlight>
 
[[paramsArray]] is available on all computers and is [[Join In Progress|JIP]] compatible. It gets set only once on mission start. Even though admin can select different options after mission start, the value of [[paramsArray]] will remain the same as it was on mission start. Anyone can see "Parameters" GUI if it is available, but only admin or host can edit it. Players will only see default options selected when exploring "Parameters" GUI, even if host/admin changed them.
 
'''Practical example of setting mission time of the day on mission start'''
 
''description.ext part'':
 
<syntaxhighlight lang="javascript">class Params
{
class Hours
{
title = "Mission Time / Hours";
texts[] = { \
"00","01","02","03","04","05", \
"06","07","08","09","10","11", \
"12","13","14","15","16","17", \
"18","19","20","21","22","23" \
};
values[] = { \
0,1,2,3,4,5,6,7,8,9, \
10,11,12,13,14,15,16, \
17,18,19,20,21,22,23 \
};
default = 12;
};
class Minutes
{
title = "Mission Time / Minutes";
texts[] = {"00","10","20","30","40","50"};
values[] = {0,10,20,30,40,50};
default = 0;
};
};</syntaxhighlight>
 
''init.sqf part'':
 
<code>[[if]] ([[isServer]]) [[then]] {
_date = [[date]];
_date [[set]] [3, [[paramsArray]] [[select]] 0];
_date [[set]] [4, [[paramsArray]] [[select]] 1];
[[setDate]] _date;
};</code>

Revision as of 15:58, 25 March 2014