I like to share this piece of code shoing how to add all available weapons defined by a certain type to an array.
The code can run client or server side.
//Config
_allWeaponTypes = ["AssaultRifle","MachineGun","SniperRifle","Shotgun","Rifle","SubmachineGun","HandGun"];
// Other types (if you like them to include): GrenadeLauncher,Launcher,MissileLauncher,Mortar,RocketLauncher
//Full List: https://community.bistudio.com/wiki/BIS_fnc_itemType -> section Weapon
_allBannedWeapons=[]; //add banned weapons (eg M107_epoch), make shure to use the base version of the weapon
//Main Script
_baseWeapons = [];
_wpList = (configFile >> "cfgWeapons") call BIS_fnc_getCfgSubClasses;
{
if (getnumber (configFile >> "cfgWeapons" >> _x >> "scope") == 2) then {
_itemType = _x call bis_fnc_itemType;
if (((_itemType select 0) == "Weapon") && ((_itemType select 1) in _allWeaponTypes)) then {
_baseName = _x call BIS_fnc_baseWeapon;
if (!(_baseName in _baseWeapons) && !(_baseName in _allBannedWeapons)) then {
_baseWeapons = _baseWeapons + [_baseName];
};
};
};
} foreach _wpList;
_baseWeapons will have for instance 51 weapons in vanilla epoch, 171 with @mas addon
Question
Sharkking
I like to share this piece of code shoing how to add all available weapons defined by a certain type to an array.
The code can run client or server side.
_baseWeapons will have for instance 51 weapons in vanilla epoch, 171 with @mas addon
may someone find it useful.
Link to comment
Share on other sites
5 answers to this question
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now