Usually when dealing with parameters you need to always check at which index the parameter is before you can get the value. Because this is such a cumbersome method, I decided to make a script that would not require indices anymore, and instead get the code that belongs to the parameter from inside the parameter class (where it should've been imho).
It is very easy to make your parameters compatible with my processParamsArray script so you never have to bother about indices ever again.
The only thing you have to do, besides from copying my script to your folder, is to put a code value in your parameter classes, like so:
class ViewDistance // 0
{
title = "View Distance:";
values[] = { 1200, 1500, 2000, 2500, 3000 };
texts[] = { "1.2 km", "1.5 km", "2 km", "2.5 km", "3km" };
default = 2000;
code = "setViewDistance %1";
};
As you can see in this example the code value here is
setViewDistance %1, but what does the
%1 stand for? If you are not familiar with the
format command, it stands for a placeholder that will be replaced with an actual value later on, in this case a value from the parameters value array (
values[]).
So assuming that the player doesnt change the default setting for this parameter, the value for this parameter will become 2000 because that's what the default is set too. The script then gets this value and replaces the %1 with the param value, so you'll end up with something like this:
setViewDistance 2000.
After the script replaced
%1 with the appropriate value, it then compiles and executes the code.
That's it really, look for more examples in the description.ext
NB. Valid values for parameters are integers, floats and booleans (true=1 and false=0). In Arma 2 1.04 floats malfunction when used in default values.
mk4_processParamsArray 0.1