[Error] Please help me fix this

Scratch

New Member
The error
Code:
13:30:39 "DayZ Epoch: PRELOAD Functions\init [[<No group>:0 (FunctionsManager)],any]"
13:30:39 "DayZ Epoch: MPframework inited"
13:30:39 Error in expression <nd (((_itemChances select _l) select 1) * 100);
for "_k" from 0 to (_weight - 1)>
13:30:39 Error position: <* 100);
for "_k" from 0 to (_weight - 1)>
13:30:39 Error *: Type String, expected Number
13:30:39 File z\addons\dayz_code\init\loot_init.sqf, line 85

The code, I added the line numbers
Code:
78for "_i" from 0 to ((count (_config)) - 1) do {
79    _classname = configName (_config select _i);
80    _itemChances = getArray (_config select _i);
81    _weighted = [];
82    _j = 0;
83    for "_l" from 0 to ((count _itemChances) - 1) do
84    {
85        _weight = round (((_itemChances select _l) 86select 1) * 100);
87        for "_k" from 0 to (_weight - 1) do
88        {
89            _weighted set [_j + _k, _l];
90            //_items set [count _items, 91((_itemChances select _l) select 0)];
92        };
93        _j = _j + _weight;
94    };
95    dayz_CLBase set [count dayz_CLBase, 96_classname];
97    dayz_CLChances set [count dayz_CLChances, 98_weighted];
99};
 
A great man once said,
"Debug a mans code and you fix his one error,
Teach a man to debug his own code and he fixes all his own errors"

If anyone cares I would like to try and leave a bit of information here. Most people here probably would rather fix their own problems than ask and wait for an answer, but the Arma script is often difficult and there is little in the way of a programming manual.

Look carefully at the error, especially this part
Code:
13:30:39 Error *: Type String, expected Number
13:30:39 File z\addons\dayz_code\init\loot_init.sqf, line 85
You can see that it tells you which file and which line (85).

and that is where calamity points out your error. If you understand what the error message is telling you and where to look, I am sure you would have noticed that error yourself. The error messages always show some of the code before the error so you can locate the error in the file.
Code:
13:30:39 Error position: <* 100);
for "_k" from 0 to (_weight - 1)>
13:30:39 Error *: Type String, expected Number
That is the _weight variable because on line 85 you have the incorrect syntax where its supposed to round off the second value of _itemChances (a number) but 86select doesn't compute so it returns a null (a string).
 
Back
Top