Armanda551 2 Posted July 19, 2018 im outputting all near weapons but i have a problem i use forEach (position player nearObjects 999999999) to get all objects with _x but the problem is it shows everything houses etc. i try to filter it only on weapons but that doesnt work. (i found it online) _kids = [(configfile >> "CfgWeapons"),0] call BIS_fnc_returnChildren; _cnt = count kids; _hitName = getText (_kids select 0 >> "name"); if (_x in [_hitName]) then { //output }; Anyone has an idea Thanks anyways Share this post Link to post Share on other sites
HazJ 1289 Posted July 20, 2018 999999999??? wtf... You need to get weapon holders. Try searching before posting as well. Not that old and will give you a start. I also wouldn't use that number. If you need to get whole map, use: https://community.bistudio.com/wiki/worldSize 1 Share this post Link to post Share on other sites
gokitty1199 225 Posted July 20, 2018 should get you in the ballpark, gets all the weapons around the player and stores their actual names in _wepList. do not use this often and please keep it under 99999 as it is very resource intensive. if you want to change the type that it searches for then just remove it from the if statement such as "MissleLauncher _wepList = []; _wepScan = nearestObjects [player, [ "GroundWeaponHolder", "GroundWeaponHolder_Scripted", "Library_WeaponHolder", "WeaponHolder", "WeaponHolder_Single_F", "WeaponHolder_Single_limited_item_F", "WeaponHolder_Single_limited_magazine_F", "WeaponHolder_Single_limited_weapon_F", "WeaponHolderSimulated", "WeaponHolderSimulated_Scripted"], 99999]; { _tmp = weaponsItemsCargo _x; _class = ((_tmp select 0) select 0); _obj = (_class call BIS_fnc_itemType) select 1; if (_obj isEqualTo "AssaultRifle" || _obj isEqualTo "SniperRifle" || _obj isEqualTo "HandGun" || _obj isEqualTo "MachineGun"|| _obj isEqualTo "MissleLauncher") then { _name = getText (configFile >> "cfgWeapons" >> _class >> "displayname"); _wepList pushBack _name; }; } forEach _wepScan; 2 Share this post Link to post Share on other sites
HazJ 1289 Posted July 20, 2018 And ditch 99999 lol https://community.bistudio.com/wiki/worldSize 1 Share this post Link to post Share on other sites
gokitty1199 225 Posted July 20, 2018 1 minute ago, HazJ said: And ditch 99999 lol https://community.bistudio.com/wiki/worldSize hes right. use 100000 1 1 Share this post Link to post Share on other sites
HazJ 1289 Posted July 20, 2018 What I'm wondering is... How does it check a high value distance say 999999999 lol if an actual terrain size is less than so? i assume it just exits...? Also... No need for multiple || when you can just use in command. if (_obj isEqualTo "AssaultRifle" || _obj isEqualTo "SniperRifle" || _obj isEqualTo "HandGun" || _obj isEqualTo "MachineGun"|| _obj isEqualTo "MissleLauncher") then if (_obj in ["AssaultRifle", "SniperRifle", "HandGun", "MachineGun", "MissleLauncher") then 2 Share this post Link to post Share on other sites
gokitty1199 225 Posted July 20, 2018 2 minutes ago, HazJ said: What I'm wondering is... How does it check a high value distance say 999999999 lol if an actual terrain size is less than so? i assume it just exits...? Also... No need for multiple || when you can just use in command. if (_obj isEqualTo "AssaultRifle" || _obj isEqualTo "SniperRifle" || _obj isEqualTo "HandGun" || _obj isEqualTo "MachineGun"|| _obj isEqualTo "MissleLauncher") then if (_obj in ["AssaultRifle", "SniperRifle", "HandGun", "MachineGun", "MissleLauncher") then sorry excuse my c++ habits good sir 1 1 Share this post Link to post Share on other sites
Larrow 2828 Posted July 20, 2018 3 hours ago, gokitty1199 said: if (_obj isEqualTo "AssaultRifle" || _obj isEqualTo "SniperRifle" || _obj isEqualTo "HandGun" || _obj isEqualTo "MachineGun"|| _obj isEqualTo "MissleLauncher") then 3 hours ago, HazJ said: Also... No need for multiple || when you can just use in command. if (_obj in ["AssaultRifle", "SniperRifle", "HandGun", "MachineGun", "MissleLauncher"]) then Added missing ] in quoted code. Have to keep in mind that in or isEqualTo are case sensitive. _wepList = []; { _wepList append ( weaponCargo _x select { getNumber( configFile >> "CfgWeapons" >> _x >> "type" ) in [ 1, 2, 4 ] } ); } forEach nearestObjects [ player, [ "WeaponHolder", "WeaponHolderSimulated" ], worldSize ]; Type of 1, 2 or 4 are primary, handgun and secondary respectively, so can be used to filter for weapons of a specific slot and avoids any case sensitive errors. WeaponHolder and WeaponHolderSimulated is enough to cover all classes of holders, as these are the two base classes. But again do you really need to know about weaponHolders that could be worldSize away from the player? Seems a little extreme. 3 Share this post Link to post Share on other sites
Grumpy Old Man 3550 Posted July 20, 2018 4 hours ago, HazJ said: What I'm wondering is... How does it check a high value distance say 999999999 lol if an actual terrain size is less than so? i assume it just exits...? Also... No need for multiple || when you can just use in command. if (_obj isEqualTo "AssaultRifle" || _obj isEqualTo "SniperRifle" || _obj isEqualTo "HandGun" || _obj isEqualTo "MachineGun"|| _obj isEqualTo "MissleLauncher") then if (_obj in ["AssaultRifle", "SniperRifle", "HandGun", "MachineGun", "MissleLauncher") then _obj = "AssaultRifle"; (_obj isEqualTo "AssaultRifle" || _obj isEqualTo "SniperRifle" || _obj isEqualTo "HandGun" || _obj isEqualTo "MachineGun"|| _obj isEqualTo "MissleLauncher") //best case, first condition matches: 0.0018ms _obj = "AssaultRifle"; (_obj in ["AssaultRifle","SniperRifle","HandGun","MachineGun","MissleLauncher"]) //0.001ms, roughly twice as fast Also you could pull weaponholders from the vehicles array, they're automatically stored in there. No need to use nearestObjects unless I'm missing something. nearestObjects [ player, [ "WeaponHolder", "WeaponHolderSimulated" ], worldSize ] //1.1507ms with 80 weaponholders in VR map (vehicles select {_x isKindOf "WeaponHolderSimulated" OR {_x isKindOf "WeaponHolder"}}) //0.0804ms with 80 weaponholders in VR map I also believe that any weapon holder created from killed units is a simulated one, so no need to retrieve the regular "WeaponHolder". Cheers 4 Share this post Link to post Share on other sites
Armanda551 2 Posted July 20, 2018 Thanks to everyone hope not me many people can learn about this post Share this post Link to post Share on other sites