paramsArray: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(done, feel free to edit and expand)
m (Wikilink JIP)
Line 33: Line 33:
};</syntaxhighlight>
};</syntaxhighlight>


[[paramsArray]] is available on all computers and is 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.
[[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'''
'''Practical example of setting mission time of the day on mission start'''

Revision as of 22:15, 22 March 2014

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.

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]
};

paramsArray is available on all computers and is 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:

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;
	};
};

init.sqf part:

if (isServer) then { _date = date; _date set [3, paramsArray select 0]; _date set [4, paramsArray select 1]; setDate _date; };