Jump to content
IvosH_cz

Virtual arsenal – filtered by side and role - Solved

Recommended Posts

This script was developed for WARMACHINE game mode. Check it out.

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Virtual arsenal - Version for default Arma 3 - NATO vs. CSAT (AAF)

 

FUNCTIONALITY:

No restrictions:

Basic items (map, radio, compass, GPS…), pistols, weapon accessories, ammunition, vests, goggles.

Restricted by side:

West (NATO) / East (CSAT) / Independent (AAF)

Helmets, uniforms, UAV terminals, backpacks.

Restricted by roles:

Based on the players primary and secondary weapons

Assault - All assault rifles, submachine guns.

Sniper - All sniper rifles, Ghillie suits.

Machine gunner – All machine guns.

Missile specialist - All assault rifles, submachine guns and all missile launchers

 

INSTRUCTIONS:

In editor:

Place any object. For example supply box. Add variable name in the object properties.

For west side use - wAmmo

east - eAmmo

independent - iAmmo (not used in this example)

 

add/edit files and folders in the mission folder:

“mission folder”/

description.ext

Spoiler

//load functions

class cfgFunctions 
{
    #include "functions\cfgfunctions.hpp"
};

 

//RESPAWN
respawn = 3; //Base
respawnDelay = 60; //seconds
respawnVehicleDelay = 120; //seconds
respawnOnStart = 1;
respawnTemplates[] = {"Revive","MenuPosition","MenuInventory","Tickets","Spectator"};

 

//LOADOUTS------------------------------------------------------------------------------------------------EDITABLE//
class CfgRespawnInventory 
{
    //regular NATO
    class WEST1 {vehicle = "B_Soldier_A_F";};
    class WEST2 {vehicle = "B_Soldier_AAR_F";};
    class WEST3 {vehicle = "B_Support_AMG_F";};
    class WEST4 {vehicle = "B_Support_AMort_F";};
    class WEST5 {vehicle = "B_Soldier_AAA_F";};
    class WEST6 {vehicle = "B_Soldier_AAT_F";};
    class WEST7 {vehicle = "B_Soldier_AR_F";};
    class WEST8 {vehicle = "B_Medic_F";};
    class WEST9 {vehicle = "B_Engineer_F";};
    class WEST10 {vehicle = "B_Soldier_Exp_F";};
    class WEST11 {vehicle = "B_Soldier_GL_F";};
    class WEST12 {vehicle = "B_Support_GMG_F";};
    class WEST13 {vehicle = "B_Support_MG_F";};
    class WEST14 {vehicle = "B_Support_Mort_F";};
    class WEST15 {vehicle = "B_soldier_M_F";};
    class WEST16 {vehicle = "B_Soldier_AA_F";};
    class WEST17 {vehicle = "B_Soldier_AT_F";};
    class WEST18 {vehicle = "B_Officer_F";};
    class WEST19 {vehicle = "B_Soldier_PG_F";};
    class WEST20 {vehicle = "B_Soldier_Repair_F";};
    class WEST21 {vehicle = "B_Soldier_F";};
    class WEST22 {vehicle = "B_Soldier_LAT_F";};
    class WEST23 {vehicle = "B_Soldier_SL_F";};
    class WEST24 {vehicle = "B_Soldier_TL_F";};
    class WEST25 {vehicle = "B_Soldier_UAV_F";};
    //crew NATO
    class WEST26 {vehicle = "B_Crew_F";}; 
    class WEST27 {vehicle = "B_Helicrew_F";}; 
    class WEST28 {vehicle = "B_Helipilot_F";}; 
    class WEST29 {vehicle = "B_Pilot_F";};
    //divers NATO
    class WEST30 {vehicle = "B_Diver_F";};
    class WEST31 {vehicle = "B_Diver_Exp_F";};
    class WEST32 {vehicle = "B_Diver_TL_F";};
    //special NATO
    class WEST33 {vehicle = "B_Recon_Exp_F";};
    class WEST34 {vehicle = "B_Recon_JTAC_F";};
    class WEST35 {vehicle = "B_Recon_M_F";};
    class WEST36 {vehicle = "B_Recon_Medic_F";};
    class WEST37 {vehicle = "B_Recon_F";};
    class WEST38 {vehicle = "B_Recon_LAT_F";};
    class WEST39 {vehicle = "B_Recon_TL_F";};
    class WEST40 {vehicle = "B_Sniper_F";};
    class WEST41 {vehicle = "B_Spotter_F";};
    //DLC NATO marksmen
    class WEST42 {vehicle = "B_HeavyGunner_F";};
    class WEST43 {vehicle = "B_Recon_Sharpshooter_F";};
    class WEST44 {vehicle = "B_Sharpshooter_F";};
    class WEST45 {vehicle = "B_ghillie_ard_F";};
    class WEST46 {vehicle = "B_ghillie_lsh_F";};
    class WEST47 {vehicle = "B_ghillie_sard_F";};
    //DLC NATO tanks
    class WEST48 {vehicle = "B_soldier_LAT2_F";};

 

    //regular CSAT
    class EAST1 {vehicle = "O_Soldier_A_F";};
    class EAST2 {vehicle = "O_Soldier_AAR_F";}; 
    class EAST3 {vehicle = "O_Support_AMG_F";}; 
    class EAST4 {vehicle = "O_Support_AMort_F";}; 
    class EAST5 {vehicle = "O_Soldier_AAA_F";}; 
    class EAST6 {vehicle = "O_Soldier_AAT_F";}; 
    class EAST7 {vehicle = "O_Soldier_AR_F";}; 
    class EAST8 {vehicle = "O_Medic_F";}; 
    class EAST9 {vehicle = "O_Engineer_F";}; 
    class EAST10 {vehicle = "O_Soldier_Exp_F";}; 
    class EAST11 {vehicle = "O_Soldier_GL_F";}; 
    class EAST12 {vehicle = "O_Support_GMG_F";}; 
    class EAST13 {vehicle = "O_Support_MG_F";}; 
    class EAST14 {vehicle = "O_Support_Mort_F";}; 
    class EAST15 {vehicle = "O_Soldier_M_F";}; 
    class EAST16 {vehicle = "O_Soldier_AA_F";}; 
    class EAST17 {vehicle = "O_Soldier_AT_F";}; 
    class EAST18 {vehicle = "O_Officer_F";}; 
    class EAST19 {vehicle = "O_Soldier_PG_F";}; 
    class EAST20 {vehicle = "O_Soldier_Repair_F";}; 
    class EAST21 {vehicle = "O_Soldier_F";}; 
    class EAST22 {vehicle = "O_Soldier_LAT_F";}; 
    class EAST23 {vehicle = "O_Soldier_SL_F";}; 
    class EAST24 {vehicle = "O_Soldier_TL_F";}; 
    class EAST25 {vehicle = "O_Soldier_UAV_F";};
    //crew CSAT
    class EAST26 {vehicle = "O_Crew_F";}; 
    class EAST27 {vehicle = "O_Helicrew_F";}; 
    class EAST28 {vehicle = "O_Helipilot_F";}; 
    class EAST29 {vehicle = "O_Pilot_F";};
    //divers CSAT
    class EAST30 {vehicle = "O_Diver_F";};
    class EAST31 {vehicle = "O_Diver_Exp_F";};
    class EAST32 {vehicle = "O_Diver_TL_F";};
    //special CSAT
    class EAST33 {vehicle = "O_Recon_Exp_F";};
    class EAST34 {vehicle = "O_Recon_JTAC_F";};
    class EAST35 {vehicle = "O_Recon_M_F";};
    class EAST36 {vehicle = "O_Recon_Medic_F";};
    class EAST37 {vehicle = "O_Recon_F";};
    class EAST38 {vehicle = "O_Recon_LAT_F";};
    class EAST39 {vehicle = "O_Recon_TL_F";};
    class EAST40 {vehicle = "O_Sniper_F";};
    class EAST41 {vehicle = "O_Spotter_F";};
    //DLC CSAT marksmen
    class EAST42 {vehicle = "O_Sharpshooter_F";};
    class EAST43 {vehicle = "O_HeavyGunner_F";};
    class EAST44 {vehicle = "O_ghillie_lsh_F";};
    class EAST45 {vehicle = "O_ghillie_sard_F";};
    class EAST46 {vehicle = "O_ghillie_ard_F";};
    class EAST47 {vehicle = "O_Pathfinder_F";};
    //DLC CSAT tanks
    class EAST48 {vehicle = "O_soldier_HAT_F";};
    class EAST49 {vehicle = "O_soldier_AHAT_F";};
};

/*

    //regular AAF
    class GUER1 {vehicle = "I_soldier_F";};
    class GUER2 {vehicle = "I_Soldier_A_F";};
    class GUER3 {vehicle = "I_Soldier_GL_F";};
    class GUER4 {vehicle = "I_Soldier_AR_F";};
    class GUER5 {vehicle = "I_Soldier_SL_F";};
    class GUER6 {vehicle = "I_Soldier_TL_F";};
    class GUER7 {vehicle = "I_Soldier_M_F";};
    class GUER8 {vehicle = "I_Soldier_LAT_F";};
    class GUER9 {vehicle = "I_Soldier_AT_F";};
    class GUER10 {vehicle = "I_Soldier_AA_F";};
    class GUER11 {vehicle = "I_medic_F";};
    class GUER12 {vehicle = "I_Soldier_repair_F";};
    class GUER13 {vehicle = "I_Soldier_exp_F";};
    class GUER14 {vehicle = "I_engineer_F";};
    class GUER15 {vehicle = "I_officer_F";};
    class GUER16 {vehicle = "I_soldier_UAV_F";};
    class GUER17 {vehicle = "I_Soldier_AAR_F";};
    class GUER18 {vehicle = "I_Soldier_AAT_F";};
    class GUER19 {vehicle = "I_Soldier_AAA_F";};
    class GUER20 {vehicle = "I_support_MG_F";};
    class GUER21 {vehicle = "I_support_GMG_F";};
    class GUER22 {vehicle = "I_support_Mort_F";};
    class GUER23 {vehicle = "I_support_AMG_F";};
    class GUER24 {vehicle = "I_support_AMort_F";};
    //crew AAF
    class GUER25 {vehicle = "I_crew_F";};
    class GUER26 {vehicle = "I_helipilot_F";};
    class GUER27 {vehicle = "I_helicrew_F";};
    class GUER28 {vehicle = "I_pilot_F";};
    //divers AAF
    class GUER29 {vehicle = "I_diver_F";};
    class GUER30 {vehicle = "I_diver_exp_F";};
    class GUER31 {vehicle = "I_diver_TL_F";};
    //special AAF
    class GUER32 {vehicle = "I_Spotter_F";};
    class GUER33 {vehicle = "I_Sniper_F";};
    //DLC AAF marksmen
    class GUER34 {vehicle = "I_ghillie_lsh_F";};
    class GUER35 {vehicle = "I_ghillie_sard_F";};
    class GUER36 {vehicle = "I_ghillie_ard_F";};
    //DLC AAF tanks
    class GUER37 {vehicle = "I_soldier_LAT2_F";};

*/

initServer.sqf

Spoiler

//RESPAWN LOADOUTS (_i=number of loadouts in the description.ext)-----------------------------------------------EDITABLE//
for "_i" from 1 to 41 step 1 do 
{[west, [format ["WEST%1", _i],0,6]] call BIS_fnc_addRespawnInventory;};
for "_i" from 1 to 41 step 1 do 
{[east, [format ["EAST%1", _i],0,6]] call BIS_fnc_addRespawnInventory;};

/*

for "_i" from 1 to 33 step 1 do 
{[independent, [format ["GUER%1", _i],0,6]] call BIS_fnc_addRespawnInventory;};

*/

init.sqf

Spoiler

//preload arsenal (side restrictions)

[wAmmo,west] call wrm_fnc_arsInit;

[eAmmo,east] call wrm_fnc_arsInit;

initPlayerLocal.sqf

Spoiler

//Author: IvosH
waitUntil {!isNull player}; //JIP


//disable save load buttons when Virtual Arsenal opens
[missionNamespace, "arsenalOpened", 
    {
        disableSerialization;
        params ["_display"];
        _display displayAddEventHandler ["keydown", "_this select 3"];
        {(_display displayCtrl _x) ctrlShow false} forEach [44151, 44150, 44146, 44147, 44148, 44149, 44346];
    }
] call BIS_fnc_addScriptedEventHandler;


//save gear when Virtual Arsenal closes
if ("param2" call BIS_fnc_getParamValue == 0) then
{
    [missionNamespace, "arsenalClosed", 
        {    
            [player, [player, "Custom Loadout"]] call BIS_fnc_saveInventory ;
            [player,["player:Custom Loadout"]] call bis_fnc_setrespawninventory;
            hint parseText format ["CUSTOM LOADOUT SAVED<br/><br/>Available in the respawn menu<br/>Default > Custom Loadout"];
        }
    ] call BIS_fnc_addScriptedEventHandler;
};

onPlayerRespawn.sqf

Spoiler

//load weapons to the arsenal (role restrictions)

[] call wrm_fnc_arsenal;

 

“mission folder”/functions

cfgFunctions.hpp

Spoiler

class wrm
{
    tag = "wrm";
    class client
    {
        file = "functions\client";
        class arsInit {};
        class arsenal {};
    };
};

 

“mission folder”/functions/client

fn_arsenal.sqf

Spoiler

/*
    Author: IvosH
    
    Description:
         Load weapons to the virtual arsenal, applies role restrictions by combat role (Assault / Machine gunner / Missile specialist / Sniper)
    
    Parameter(s):
        none
        
    Returns:
        nothing
        
    Dependencies:
        onPlayerRespawn.sqf, wAmmo, eAmmo, iAmmo
        
    Execution:
        [] call wrm_fnc_arsenal;
*/

if (!hasInterface) exitWith {}; //run on the players only


//check side
_box=wAmmo;
if(side player==east)then{_box=eAmmo;};

//if(side player==independent)then{_box=iAmmo;}; //for independent

 

//clear previous weapons in the arsenal

[_box,([_box] call BIS_fnc_getVirtualWeaponCargo)] call BIS_fnc_removeVirtualWeaponCargo;
_weap = []; //weapon array + pistols
_cfgWp= "(getText (_x >> 'cursor') == 'hgun')" configClasses (configFile>>"cfgWeapons");
{
    _wp = configName (_x);
    _weap pushBack _wp;
} forEach _cfgWp;
_sm = []; //submachineguns
_cfgSm= "(getText (_x >> 'cursor') == 'smg')" configClasses (configFile>>"cfgWeapons");
{
    _wp = configName (_x);
    _sm pushBack _wp;
} forEach _cfgSm;
_ar = []; //assault rifles
_cfgAr= "(getText (_x >> 'cursor') == 'arifle')" configClasses (configFile>>"cfgWeapons"); //get array of all weapons
{
    _wp = configName (_x);
    _ar pushBack _wp;
} forEach _cfgAr;
_mg = []; //machineguns
_cfgMg= "(getText (_x >> 'cursor') == 'mg')" configClasses (configFile>>"cfgWeapons");
{
    _wp = configName (_x);
    
    _mg pushBack _wp;
} forEach _cfgMg;
_sn = []; //sniper rifles
_cfgSn= "(getText (_x >> 'cursor') == 'srifle')" configClasses (configFile>>"cfgWeapons");
{
    _wp = configName (_x);
    _sn pushBack _wp;
} forEach _cfgSn;
_at = []; //missile launchers
_cfgAt= "(getText (_x >> 'cursor') == 'missile')||(getText (_x >> 'cursor') == 'rocket')" configClasses (configFile>>"cfgWeapons");
{
    _wp = configName (_x);
    _at pushBack _wp;
} forEach _cfgAt;
//uniforms
_unif=[]; _unf='';
call
{
    if (side player==west) exitWith {_unf='U_B_';};
    if (side player==east) exitWith {_unf='U_O_';};
    if (side player==independent) exitWith {_unf='U_I_';};
};
_cfgUn= "((str _x find _unf >= 0)&&(getText (_x >> 'displayName') find 'Ghillie' >= 0))" configClasses (configFile>>"cfgWeapons");
{
    _wp = configName (_x);
    _unif pushBack _wp;
} forEach _cfgUn;
//check player's role
_rl = 0;
call
{
    if (primaryWeapon player in _mg) exitWith {_rl = 1;};
    if (primaryWeapon player in _sn) exitWith {_rl = 2;};
    if (secondaryWeapon player in _at) exitWith {_rl = 3;};
};

//ghillie suit
call 
{
    if (_rl == 0) exitWith {_weap=_weap+_ar+_sm;[_box,_unif] call BIS_fnc_removeVirtualItemCargo;};
    if (_rl == 1) exitWith {_weap=_weap+_mg;[_box,_unif] call BIS_fnc_removeVirtualItemCargo;};
    if (_rl == 2) exitWith {_weap=_weap+_sn;[_box,_unif,false,false] call BIS_fnc_addVirtualItemCargo;};
    if (_rl == 3) exitWith {_weap=_weap+_ar+_sm+_at;[_box,_unif] call BIS_fnc_removeVirtualItemCargo;};
};

//add weapons to arsenal
[_box,_weap,false,false] call BIS_fnc_addVirtualWeaponCargo;

fn_arsInit.sqf

Spoiler

/*
    Author: IvosH
    
    Description:
        Preloads virtual arsenal, applies side restrictions
    
    Parameter(s):
        0: OBJECT ammobox
        1: SIDE    
        
    Returns:
        nothing
        
    Dependencies:
        init.sqf
        
    Execution:
        [] call wrm_fnc_arsInit;
*/
if (!hasInterface) exitWith {}; //run on the players only
_box=_this select 0;
_sde=_this select 1;

[_box,([_box] call BIS_fnc_getVirtualItemCargo)] call BIS_fnc_removeVirtualItemCargo; //remove items - side switch
[_box,([_box] call BIS_fnc_getVirtualBackpackCargo)] call BIS_fnc_removeVirtualBackpackCargo;
[_box,true,false,false] call BIS_fnc_addVirtualMagazineCargo; //add all Magazines to the arsenal
//check player's side
_uav=""; _unif=[]; _hlm=[]; _s1='';_s2='';_s3='';
call
{
    if (_sde==west) exitWith 
    {
        _uav="B_UavTerminal";
        _cfgUn= "((str _x find 'U_B_' >= 0)&&(getText (_x >> 'displayName') find 'Ghillie' == -1))" configClasses (configFile>>"cfgWeapons");
        {
            _wp = configName (_x);
            _unif pushBack _wp;
        } forEach _cfgUn;
        _hlm=['HelmetB','Crew_B','Heli_B','Fighter_B','SpecB'];
        _s1='[CSAT]';_s2='[AAF]';_s3='[IDAP]';
    };
    if (_sde==east) exitWith 
    {
        _uav="O_UavTerminal";
        _cfgUn= "((str _x find 'U_O_' >= 0)&&(getText (_x >> 'displayName') find 'Ghillie' == -1))" configClasses (configFile>>"cfgWeapons");
        {
            _wp = configName (_x);
            _unif pushBack _wp;
        } forEach _cfgUn;
        _hlm=['HelmetO','Crew_O','Heli_O','Fighter_O','SpecO','LeaderO'];
        _s1='[NATO]';_s2='[AAF]';_s3='[IDAP]';
    };
    if (_sde==independent) exitWith 
    {
        _uav="I_UavTerminal";
        _cfgUn= "((str _x find 'U_I_' >= 0)&&(str _x find '_C_' == -1)&&(str _x find '_G_' == -1)&&(getText (_x >> 'displayName') find 'Ghillie' == -1))" configClasses (configFile>>"cfgWeapons");
        {
            _wp = configName (_x);
            _unif pushBack _wp;
        } forEach _cfgUn;
        _hlm=['HelmetI','Crew_I','Heli_I','Fighter_I'];
        _s1='[CSAT]';_s2='[NATO]';_s3='[IDAP]';
    };
};
//items
_itms=["Binocular","Medikit","FirstAidKit","ToolKit","MineDetector","ItemCompass","ItemGPS","ItemMap","ItemRadio","ItemWatch","Rangefinder",_uav];
{
    _cr=_x;
    _cfgIt= "(getText (_x >> '_generalMacro') find _cr >= 0)" configClasses (configFile>>"cfgWeapons");
    {
        _it = configName (_x);
        _itms pushBack _it;
    } forEach _cfgIt;
} forEach ['optic_','acc_','muzzle_','bipod_','NVGoggles','Laserdesignator','V_'];
_ggl=[]; //googles
_cfgGl= "true" configClasses (configFile>>"cfgGlasses");
{
    _wp = configName (_x);
    _ggl pushBack _wp;
} forEach _cfgGl;
_helm=[]; //helmets
{
    _tp=_x;
    _cfgHl= "((str _x find 'H_' >= 0)&&(str _x find _tp >= 0))" configClasses (configFile>>"cfgWeapons");
    {
        _wp = configName (_x);
        _helm pushBack _wp;
    } forEach _cfgHl;
} forEach _hlm;
_itms=_itms+_ggl+_unif+_helm;
[_box,_itms,false,false] call BIS_fnc_addVirtualItemCargo; //add Items to the arsenal
//backpacks
_back=[];
_cfgBp= "((getText (_x >> 'vehicleClass') == 'Backpacks')&&(getText (_x >> 'displayName') find _s1 ==-1)&&(getText (_x >> 'displayName') find _s2 ==-1)&&(getText (_x >> 'displayName') find _s3 ==-1))" configClasses (configFile>>"cfgVehicles");
{
    _wp = configName (_x);
    _back pushBack _wp;
} forEach _cfgBp;
[_box,_back,false,false] call BIS_fnc_addVirtualBackpackCargo; //add Backpacks to the arsenal

 

RHS version here

  • Thanks 4

Share this post


Link to post
Share on other sites

Small update

UAV terminals names was incorrect.

Tested also with CUP mod and works. (only weapons, all RHS stuff will need more conditions in the fn_arsInit.sqf)

  • Like 2

Share this post


Link to post
Share on other sites

Update 27.11.2018

Instructions and scripts updated. Works properly for hosted and dedicated servers. Send me feedback. Thank you.

Share this post


Link to post
Share on other sites

Virtual arsenal - Version for RHS_USAF vs. RHS_AFRF

 

INSTRUCTIONS:

In editor:

Place any object. For example supply box. Add variable name in the object properties.

For west side (USAF) use - wAmmo

east (AFRF) - eAmmo

 

add/edit files and folders in the mission folder:

“mission folder”/

description.ext

Spoiler

//load functions

class cfgFunctions 
{
    #include "functions\cfgfunctions.hpp"
};

 

//RESPAWN
respawn = 3; //Base
respawnDelay = 60; //seconds
respawnVehicleDelay = 120; //seconds
respawnOnStart = 1;
respawnTemplates[] = {"Revive","MenuPosition","MenuInventory","Tickets","Spectator"};

 

//LOADOUTS------------------------------------------------------------------------------------------------EDITABLE//

class CfgRespawnInventory 
{
    //USMC (west)
    class WEST1 {vehicle = "rhsusf_usmc_marpat_wd_stinger";};
    class WEST2 {vehicle = "rhsusf_usmc_marpat_wd_smaw";};
    class WEST3 {vehicle = "rhsusf_usmc_marpat_wd_javelin_assistant";};
    class WEST4 {vehicle = "rhsusf_usmc_marpat_wd_javelin";};
    class WEST5 {vehicle = "rhsusf_usmc_marpat_wd_autorifleman_m249";};
    class WEST6 {vehicle = "rhsusf_usmc_marpat_wd_autorifleman";};
    class WEST7 {vehicle = "rhsusf_usmc_marpat_wd_autorifleman_m249_ass";};
    class WEST8 {vehicle = "rhsusf_usmc_marpat_wd_rifleman_m590";};
    class WEST9 {vehicle = "rhsusf_usmc_marpat_wd_engineer";};
    class WEST10 {vehicle = "rhsusf_usmc_marpat_wd_crewman";};
    class WEST11 {vehicle = "rhsusf_usmc_marpat_wd_combatcrewman";};
    class WEST12 {vehicle = "rhsusf_usmc_marpat_wd_marksman";};
    class WEST13 {vehicle = "rhsusf_usmc_marpat_wd_driver";};
    class WEST14 {vehicle = "rhsusf_usmc_marpat_wd_explosives";};
    class WEST15 {vehicle = "rhsusf_usmc_marpat_wd_fso";};
    class WEST16 {vehicle = "rhsusf_usmc_marpat_wd_grenadier";};
    class WEST17 {vehicle = "rhsusf_usmc_marpat_wd_grenadier_m32";};
    class WEST18 {vehicle = "rhsusf_usmc_marpat_wd_gunner";};
    class WEST19 {vehicle = "rhsusf_usmc_marpat_wd_helicrew";};
    class WEST20 {vehicle = "rhsusf_usmc_marpat_wd_helipilot";};
    class WEST21 {vehicle = "rhsusf_usmc_marpat_wd_jfo";};
    class WEST22 {vehicle = "rhsusf_usmc_marpat_wd_machinegunner";};
    class WEST23 {vehicle = "rhsusf_usmc_marpat_wd_machinegunner_ass";};
    class WEST24 {vehicle = "rhsusf_usmc_marpat_wd_officer";};
    class WEST25 {vehicle = "rhsusf_usmc_marpat_wd_rifleman_light";};
    class WEST26 {vehicle = "rhsusf_usmc_marpat_wd_riflemanat";}; 
    class WEST27 {vehicle = "rhsusf_usmc_marpat_wd_rifleman";}; 
    class WEST28 {vehicle = "rhsusf_usmc_marpat_wd_rifleman_m4";}; 
    class WEST29 {vehicle = "rhsusf_usmc_marpat_wd_rifleman_law";};
    class WEST30 {vehicle = "rhsusf_usmc_marpat_wd_sniper_m110";};
    class WEST31 {vehicle = "rhsusf_usmc_marpat_wd_sniper";};
    class WEST32 {vehicle = "rhsusf_usmc_marpat_wd_spotter";};
    class WEST33 {vehicle = "rhsusf_usmc_marpat_wd_sniper_M107";};
    class WEST34 {vehicle = "rhsusf_usmc_marpat_wd_squadleader";};
    class WEST35 {vehicle = "rhsusf_usmc_marpat_wd_teamleader";};
    class WEST36 {vehicle = "rhsusf_usmc_marpat_wd_uav";};
    //RECON
    class WEST37 {vehicle = "rhsusf_usmc_recon_marpat_wd_machinegunner_m249";};
    class WEST38 {vehicle = "rhsusf_usmc_recon_marpat_wd_machinegunner_m249_fast";};
    class WEST39 {vehicle = "rhsusf_usmc_recon_marpat_wd_machinegunner_m249_lite";};
    class WEST40 {vehicle = "rhsusf_usmc_recon_marpat_wd_autorifleman";};
    class WEST41 {vehicle = "rhsusf_usmc_recon_marpat_wd_autorifleman_fast";};
    class WEST42 {vehicle = "rhsusf_usmc_recon_marpat_wd_autorifleman_lite";};
    class WEST43 {vehicle = "rhsusf_usmc_recon_marpat_wd_grenadier_m32";};
    class WEST44 {vehicle = "rhsusf_usmc_recon_marpat_wd_machinegunner";};
    class WEST45 {vehicle = "rhsusf_usmc_recon_marpat_wd_marksman";};
    class WEST46 {vehicle = "rhsusf_usmc_recon_marpat_wd_marksman_fast";};
    class WEST47 {vehicle = "rhsusf_usmc_recon_marpat_wd_marksman_lite";};
    class WEST48 {vehicle = "rhsusf_usmc_recon_marpat_wd_officer";};
    class WEST49 {vehicle = "rhsusf_usmc_recon_marpat_wd_rifleman";};
    class WEST50 {vehicle = "rhsusf_usmc_recon_marpat_wd_rifleman_fast";};
    class WEST51 {vehicle = "rhsusf_usmc_recon_marpat_wd_rifleman_lite";};
    class WEST52 {vehicle = "rhsusf_usmc_recon_marpat_wd_rifleman_at";};
    class WEST53 {vehicle = "rhsusf_usmc_recon_marpat_wd_rifleman_at_fast";};
    class WEST54 {vehicle = "rhsusf_usmc_recon_marpat_wd_rifleman_at_lite";};
    class WEST55 {vehicle = "rhsusf_usmc_recon_marpat_wd_sniper_M107";};
    class WEST56 {vehicle = "rhsusf_usmc_recon_marpat_wd_teamleader";};
    class WEST57 {vehicle = "rhsusf_usmc_recon_marpat_wd_teamleader_fast";};
    class WEST58 {vehicle = "rhsusf_usmc_recon_marpat_wd_teamleader_lite";};
    //pilot
    class WEST59 {vehicle = "rhsusf_airforce_jetpilot";};
    
    //VMF (east)
    class EAST1 {vehicle = "rhs_vmf_flora_at";};
    class EAST2 {vehicle = "rhs_vmf_flora_crew";};
    class EAST3 {vehicle = "rhs_vmf_flora_armoredcrew";};
    class EAST4 {vehicle = "rhs_vmf_flora_combatcrew";};
    class EAST5 {vehicle = "rhs_vmf_flora_crew_commander";};
    class EAST6 {vehicle = "rhs_vmf_flora_driver";};
    class EAST7 {vehicle = "rhs_vmf_flora_driver_armored";};
    class EAST8 {vehicle = "rhs_vmf_flora_efreitor";};
    class EAST9 {vehicle = "rhs_vmf_flora_engineer";};
    class EAST10 {vehicle = "rhs_vmf_flora_grenadier_rpg";};
    class EAST11 {vehicle = "rhs_vmf_flora_strelok_rpg_assist";};
    class EAST12 {vehicle = "rhs_vmf_flora_junior_sergeant";};
    class EAST13 {vehicle = "rhs_vmf_flora_machinegunner";};
    class EAST14 {vehicle = "rhs_vmf_flora_machinegunner_assistant";};
    class EAST15 {vehicle = "rhs_vmf_flora_marksman";};
    class EAST16 {vehicle = "rhs_vmf_flora_medic";};
    class EAST17 {vehicle = "rhs_vmf_flora_officer";};
    class EAST18 {vehicle = "rhs_vmf_flora_officer_armored";};
    class EAST19 {vehicle = "rhs_vmf_flora_rifleman";};
    class EAST20 {vehicle = "rhs_vmf_flora_grenadier";};
    class EAST21 {vehicle = "rhs_vmf_flora_LAT";};
    class EAST22 {vehicle = "rhs_vmf_flora_RShG2";};
    class EAST23 {vehicle = "rhs_vmf_flora_sergeant";};
    class EAST24 {vehicle = "rhs_vmf_flora_aa";};
    //PILOT
    class EAST25 {vehicle = "rhs_pilot";};
    class EAST26 {vehicle = "rhs_pilot_combat_heli";};
    class EAST27 {vehicle = "rhs_pilot_tan";};
    //RECON
    class EAST28 {vehicle = "rhs_vmf_recon_arifleman";};
    class EAST29 {vehicle = "rhs_vmf_recon_efreitor";};
    class EAST30 {vehicle = "rhs_vmf_recon_machinegunner_assistant";};
    class EAST31 {vehicle = "rhs_vmf_recon_marksman";};
    class EAST32 {vehicle = "rhs_vmf_recon_marksman_vss";};
    class EAST33 {vehicle = "rhs_vmf_recon_medic";};
    class EAST34 {vehicle = "rhs_vmf_recon_officer";};
    class EAST35 {vehicle = "rhs_vmf_recon_officer_armored";};
    class EAST36 {vehicle = "rhs_vmf_recon_rifleman";};
    class EAST37 {vehicle = "rhs_vmf_recon_rifleman_akms";};
    class EAST38 {vehicle = "rhs_vmf_recon_rifleman_l";};
    class EAST39 {vehicle = "rhs_vmf_recon_rifleman_asval";};
    class EAST40 {vehicle = "rhs_vmf_recon_grenadier";};
    class EAST41 {vehicle = "rhs_vmf_recon_rifleman_lat";};
    class EAST42 {vehicle = "rhs_vmf_recon_rifleman_scout_akm";};
    class EAST43 {vehicle = "rhs_vmf_recon_rifleman_scout";};
    class EAST44 {vehicle = "rhs_vmf_recon_grenadier_scout";};
    class EAST45 {vehicle = "rhs_vmf_recon_arifleman_scout";};
    class EAST46 {vehicle = "rhs_vmf_recon_sergeant";};
};

initServer.sqf

Spoiler

//RESPAWN LOADOUTS (_i=number of loadouts in the description.ext)-----------------------------------------------EDITABLE//
for "_i" from 1 to 59 step 1 do 
{[west, [format ["WEST%1", _i],6,-1]] call BIS_fnc_addRespawnInventory;};
for "_i" from 1 to 46 step 1 do 
{[east, [format ["EAST%1", _i],6,-1]] call BIS_fnc_addRespawnInventory;};

init.sqf

Spoiler

//preload arsenal (side restrictions)

[wAmmo,west] call wrm_fnc_arsInit;

[eAmmo,east] call wrm_fnc_arsInit;

initPlayerLocal.sqf

Spoiler

//Author: IvosH
waitUntil {!isNull player}; //JIP


//disable save load buttons when Virtual Arsenal opens
[missionNamespace, "arsenalOpened", 
    {
        disableSerialization;
        params ["_display"];
        _display displayAddEventHandler ["keydown", "_this select 3"];
        {(_display displayCtrl _x) ctrlShow false} forEach [44151, 44150, 44146, 44147, 44148, 44149, 44346];
    }
] call BIS_fnc_addScriptedEventHandler;


//save gear when Virtual Arsenal closes
if ("param2" call BIS_fnc_getParamValue == 0) then
{
    [missionNamespace, "arsenalClosed", 
        {    
            [player, [player, "Custom Loadout"]] call BIS_fnc_saveInventory ;
            [player,["player:Custom Loadout"]] call bis_fnc_setrespawninventory;
            hint parseText format ["CUSTOM LOADOUT SAVED<br/><br/>Available in the respawn menu<br/>Default > Custom Loadout"];
        }
    ] call BIS_fnc_addScriptedEventHandler;
};

onPlayerRespawn.sqf

Spoiler

//load weapons to the arsenal (role restrictions)

[] call wrm_fnc_arsenal;

 

“mission folder”/functions

cfgFunctions.hpp

Spoiler

class wrm
{
    tag = "wrm";
    class client
    {
        file = "functions\client";
        class arsInit {};
        class arsenal {};
    };
};

 

“mission folder”/functions/client

fn_arsenal.sqf

Spoiler

/*
    Author: IvosH
    
    Description:
        Load weapons to virtual arsenal, applies role restrictions
    
    Parameter(s):
        none
        
    Returns:
        nothing
        
    Dependencies:
        onPlayerRespawn.sqf
        
    Execution:
        [] call wrm_fnc_arsenal;
*/
if (!hasInterface) exitWith {}; //run on the players only
//weapons
_box=wAmmo; 
if(side player==east)then{_box=eAmmo;};

[_box,([_box] call BIS_fnc_getVirtualWeaponCargo)] call BIS_fnc_removeVirtualWeaponCargo; //clear previous weapons in the arsenal
_weap = []; //weapon array + pistols
_cfgWp= "((getText (_x >> 'cursor') == 'hgun')&&((getText(_x >> 'dlc')=='RHS_USAF')||(getText(_x >> 'dlc')=='RHS_AFRF')))" configClasses (configFile>>"cfgWeapons");
{
    _wp = configName (_x);
    _weap pushBack _wp;
} forEach _cfgWp;
_sm = []; //submachineguns
_cfgSm= "((getText (_x >> 'cursor') == 'smg')&&((getText(_x >> 'dlc')=='RHS_USAF')||(getText(_x >> 'dlc')=='RHS_AFRF')))" configClasses (configFile>>"cfgWeapons");
{
    _wp = configName (_x);
    _sm pushBack _wp;
} forEach _cfgSm;
_ar = []; //assault rifles
_cfgAr= "((getText (_x >> 'cursor') == 'arifle')&&((getText(_x >> 'dlc')=='RHS_USAF')||(getText(_x >> 'dlc')=='RHS_AFRF')))" configClasses (configFile>>"cfgWeapons"); //get array of all weapons
{
    _wp = configName (_x);
    _ar pushBack _wp;
} forEach _cfgAr;
_mg = []; //machineguns
_cfgMg= "((getText (_x >> 'cursor') == 'mg')&&((getText(_x >> 'dlc')=='RHS_USAF')||(getText(_x >> 'dlc')=='RHS_AFRF')))" configClasses (configFile>>"cfgWeapons");
{
    _wp = configName (_x);
    
    _mg pushBack _wp;
} forEach _cfgMg;
_sn = []; //sniper rifles
_cfgSn= "((getText (_x >> 'cursor') == 'srifle')&&((getText(_x >> 'dlc')=='RHS_USAF')||(getText(_x >> 'dlc')=='RHS_AFRF')))" configClasses (configFile>>"cfgWeapons");
{
    _wp = configName (_x);
    _sn pushBack _wp;
} forEach _cfgSn;
_at = []; //missile launchers
_cfgAt= "(((getText (_x >> 'cursor') == 'missile')||(getText (_x >> 'cursor') == 'rocket'))&&((getText(_x >> 'dlc')=='RHS_USAF')||(getText(_x >> 'dlc')=='RHS_AFRF')))" configClasses (configFile>>"cfgWeapons");
{
    _wp = configName (_x);
    _at pushBack _wp;
} forEach _cfgAt;

//check player's role
_rl = 0;
call
{
    if (primaryWeapon player in _mg) exitWith {_rl = 1;};
    if (primaryWeapon player in _sn) exitWith {_rl = 2;};
    if (secondaryWeapon player in _at) exitWith {_rl = 3;};
};
call 
{
    if (_rl == 0) exitWith {_weap=_weap+_ar+_sm;};
    if (_rl == 1) exitWith {_weap=_weap+_mg;};
    if (_rl == 2) exitWith {_weap=_weap+_sn;};
    if (_rl == 3) exitWith {_weap=_weap+_ar+_sm+_at;};
};
[_box,_weap,false,false] call BIS_fnc_addVirtualWeaponCargo; //add weapons to arsenal

fn_arsInit.sqf

Spoiler

/*
    Author: IvosH
    
    Description:
        Preloads virtual arsenal, applies side restrictions
    
    Parameter(s):
        0: OBJECT ammobox
        1: SIDE    
        
    Returns:
        nothing
        
    Dependencies:
        init.sqf
        
    Execution:
        [] call wrm_fnc_arsInit;
*/
if (!hasInterface) exitWith {}; //run on the players only
_box=_this select 0;
_dlce=_this select 1;

[_box,([_box] call BIS_fnc_getVirtualItemCargo)] call BIS_fnc_removeVirtualItemCargo; //remove items - side switch
[_box,([_box] call BIS_fnc_getVirtualBackpackCargo)] call BIS_fnc_removeVirtualBackpackCargo;
[_box,true,false,false] call BIS_fnc_addVirtualMagazineCargo; //add all Magazines to the arsenal

//check player's side
_uav=""; _dlc='';
call
{
    if (_dlce==west) exitWith 
    {
        _uav="B_UavTerminal";
        _dlc='RHS_USAF';
    };
    if (_dlce==east) exitWith 
    {
        _uav="O_UavTerminal";
        _dlc='RHS_AFRF';
    };
    if (_dlce==independent) exitWith 
    {
        _uav="I_UavTerminal";
        _dlc='RHS_GREF';
    };
};

//items ALL
_itms=["Binocular","Medikit","FirstAidKit","ToolKit","MineDetector","ItemCompass","ItemGPS","ItemMap","ItemRadio","ItemWatch","Rangefinder",_uav];
{
    _cr=_x;
    _cfgIt= "((str _x find 'rhs' >= 0)&&(getText (_x >> '_generalMacro') find _cr >= 0))" configClasses (configFile>>"cfgWeapons");
    {
        _it = configName (_x);
        _itms pushBack _it;
    } forEach _cfgIt;
} forEach ['optic_','acc_','muzzle_','bipod_','NVGoggles','Laserdesignator','Rangefinder','Binocular'];

_unif=[]; //uniforms
_cfgUn= "((str _x find 'rhs_uniform' >= 0)&&(getText(_x >> 'dlc')==_dlc))" configClasses (configFile>>"cfgWeapons");
{
    _wp = configName (_x);
    _unif pushBack _wp;
} forEach _cfgUn;

_ggl=[]; //googles
_cfgGl= "true" configClasses (configFile>>"cfgGlasses");
{
    _wp = configName (_x);
    _ggl pushBack _wp;
} forEach _cfgGl;

_helm=[]; //helmets, vests
{
    _cr=_x;
    _cfgIt= "((getText (_x >> '_generalMacro') find _cr >= 0)&&(getText(_x >> 'dlc')==_dlc))" configClasses (configFile>>"cfgWeapons");
    {
        _it = configName (_x);
        _helm pushBack _it;
    } forEach _cfgIt;
} forEach ['H_HelmetB','Vest_Camo_Base'];
_itms=_itms+_ggl+_unif+_helm;
[_box,_itms,false,false] call BIS_fnc_addVirtualItemCargo; //add Items to the arsenal

//backpacks
_back=[];
_cfgBp= "((getText (_x >> 'vehicleClass') == 'Backpacks')&&(getText(_x >> 'dlc')==_dlc))" configClasses (configFile>>"cfgVehicles");
{
    _wp = configName (_x);
    _back pushBack _wp;
} forEach _cfgBp;
[_box,_back,false,false] call BIS_fnc_addVirtualBackpackCargo; //add Backpacks to the arsenal

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×