CreativeProduct 2 Posted October 9, 2018 Hello there! I've been working the entire day and just came up with a new idea about an hour ago. I'm having problems reight now in gettin the "correct" item. My Goal is the following: I have stetup an array, which contains weapons, Alternative version of weapons and ultimatively the chance by using this: ["SomeWeapon",["WeaponSKin1","Weaponskin2"],70] Now, the problem is the following, im creating a random number the "general" chance. If the Chance of the weapon is lower, it gets added to an array. Creating a big array with all the weapons with a >70% spawnrate. Now I want to select only the weapon with the highest chance and cant seem to get it. I feel like im pretty close but can't figure it out right now (should take a break sometime soon ;) ). Anyway, thats what I have gotten so far: _chance = 100; _array = []; _selectedWeapon = ""; _pistol = [["hgun_ACPC2_snds_F",["hgun_ACPC2_snds_F"],70],["hgun_Pistol_heavy_01_F",[""],5],["arifle_MXC_Black_F",["arifle_MX_khk_F","arifle_MX_F"],35]]; _weapon = _pistol call BIS_fnc_SelectRandom select 0; { if (_chance <= _x select 2) then {_chance = _x select 2; _array = _array + [[_x select 0,_x select 1]]; _selectedWeapon = _array select ((count _array) - 1);}; sleep 1; hint format ["%1\n%2",_array, _selectedWeapon]; } foreach _pistol; Getting the alternate versions isnt big of the porblem, im currently just stuck with selecting the weapon with the highest chance blew the "general chance". Thanks in Advance, CP~ Share this post Link to post Share on other sites
CreativeProduct 2 Posted October 9, 2018 Oh my. Theres the command sort solving all my problems. /sigh. Share this post Link to post Share on other sites
Harzach 2517 Posted October 9, 2018 As an aside: Quote BIS_fnc_selectRandom Description: Selects one of the arguments at random. There is now a dedicated script command selectRandom, use that instead. And on the selectRandom page you'll see a little something called selectRandomWeighted. 1 Share this post Link to post Share on other sites
CreativeProduct 2 Posted October 11, 2018 On 10.10.2018 at 1:24 AM, Harzach said: As an aside: And on the selectRandom page you'll see a little something called selectRandomWeighted. Now, since i got it working so far, im wondering how that "weightet" system works. If we have for an example a value of 35 and a second value of lets say 1, how would the Chance be calculated? Would the 1% be 1/36? Thanks for helping me out, got a thanks from me! ~CP Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted October 11, 2018 1 hour ago, CreativeProduct said: Now, since i got it working so far, im wondering how that "weightet" system works. If we have for an example a value of 35 and a second value of lets say 1, how would the Chance be calculated? Would the 1% be 1/36? Thanks for helping me out, got a thanks from me! ~CP 35? Try reading the wiki entry. Cheers Share this post Link to post Share on other sites
CreativeProduct 2 Posted October 11, 2018 2 hours ago, Grumpy Old Man said: 35? Try reading the wiki entry. Cheers I would have never thought about reading the wiki! Thanks a lot! Cheers. Share this post Link to post Share on other sites