Jump to content
  • 0

Weapon Attachment system the easy way


boyd

Question

Hey i can use some help on this, i am using ASC weapon attachment addon which gives you those attachments just like standalone.

What i am doing now is that u right click on the weapon u have on you and select to attach a silencer, then the script checks if u have the actual silencer and then if u do it will upgrade it.

This method is way to complicated and a ton of work, i have got a lot of new weapons as well but to do this for all of them is a pain.

 

What i would like to have is you right click on the silencer in your inventory and select attach to weapon, this will then see what weapon you got and search for a possible upgrade for that weapon and if it is it will switch the weapon and remove the silencer.

 

Now my coding skills are limited this is why i am here asking for help. i would like to get this working because it is a great feature and maybe even could be added to epoch itself.

 

 

This is what i have now found on these forums.

 

 

In Extra_rc.hpp i have to put something like this.

class RH_m4 {
                    class RH_m4_1 {
                            text = "Attach Suppressor";
                            script = "[""RH_m4"",""ItemToolbox"",""ASC_Item_SD_556mm"","""",""RH_m4sd"",""Suppressor Attached""]execVM ""custom\wepmodify\upgrades.sqf"";";
                    };
                    class RH_m4_2 {
                            text = "Attach Grenade Launcher";
                            script = "[""RH_m4"",""ItemToolbox"",""ASC_Item_M203"","""",""RH_m4gl"",""Grenade Launcher Attached""]execVM ""custom\wepmodify\upgrades.sqf"";";
                    };
                    class RH_m4_3 {
                            text = "Attach M203 + SD";
                            script = "[""RH_m4"",""ItemToolbox"",""ASC_Item_M203"",""ASC_Item_SD_556mm"",""RH_m4sdgl"",""M203 + SD Attached""]execVM ""custom\wepmodify\upgrades.sqf"";";
                    };
		    class RH_m4_4 {
                            text = "Attach CCO Sight";
                            script = "[""RH_m4"",""ItemToolbox"",""ASC_Item_Optics_AIM"","""",""RH_m4aim"",""CCO Sight Attached""]execVM ""custom\wepmodify\upgrades.sqf"";";
                    };
		    class RH_m4_5 {
                            text = "Attach Holo Sight";
                            script = "[""RH_m4"",""ItemToolbox"",""ASC_Item_Optics_EoTech"","""",""RH_m4eotech"",""Holo Sight Attached""]execVM ""custom\wepmodify\upgrades.sqf"";";
                    };
		    class RH_m4_6 {
                            text = "Attach ACOG Sight";
                            script = "[""RH_m4"",""ItemToolbox"",""ASC_Item_Optics_ACOG"","""",""RH_m4acog"",""ACOG Sight Attached""]execVM ""custom\wepmodify\upgrades.sqf"";";
                    };
            };

Upgrades.sqf

        /*
            Script by HALV
            usage: parse varibles to the script, example below will Detatch supressor from mk17 and will:
            require toolbox and scrap metal, remove scrap, but leave toolbox
            ["weapon2change",       "toolneeded"(""=nothing),       "magazineneeded/removed"(""=nothing),   "toolremoved"(""=nothing),      "outputweapon",                 "Text"]
            ["SCAR_H_CQC_CCO",      "ItemToolbox",                          "PartGeneric",                                                  "",                                                     "SCAR_H_CQC_CCO_SD",    "Suppressor Attatched"]
    */
    
    _weapon = _this select 0;
    _toolitem = _this select 1;
    _magitem = _this select 2;
    _magitem2 = _this select 3;
    _weapoutput = _this select 4;
    _string = _this select 5;
    
    if(_magitem !="" and !(_magitem in magazines player))exitwith{
            _txt2 = (gettext (configFile >> 'cfgmagazines' >> _magitem >> 'displayName'));
            titleText [format["You need %1 for this",_txt2], "PLAIN DOWN"]; titleFadeOut 5;
    };
    
    if(_toolitem !="" and !(player hasWeapon _toolitem))exitwith{
            _txt1 = (gettext (configFile >> 'cfgweapons' >> _toolitem >> 'displayName'));
            titleText [format["You need %1 for this",_txt1], "PLAIN DOWN"]; titleFadeOut 5;
    };
    
    if(_magitem2 !="" and !(_magitem2 in magazines player))exitwith{
            _txt2 = (gettext (configFile >> 'cfgmagazines' >> _magitem2 >> 'displayName'));
            titleText [format["You need %1 for this",_txt2], "PLAIN DOWN"]; titleFadeOut 5;
    };
     
    closeDialog 0;
     
    //player playActionNow "Medic";
    //[player,"repair",0,false,10] call dayz_zombieSpeak;
    //[player,10,true,(getPosATL player)] spawn player_alertZombies;
    sleep 1;
    player removeWeapon _weapon;
     
    if(_magitem2 !="")then{
            player removeMagazine _magitem2;
    };
     
    if(_magitem !="")then{
            player removeMagazine _magitem;
    };
     
    sleep 2;
    player addWeapon _weapoutput;
    sleep 1;
    player selectWeapon _weapoutput;
    titleText [format["%1",_string], "PLAIN DOWN"]; titleFadeOut 5;

 

downgrades.sqf

 

    /*
            Script by HALV
            usage: parse varibles to the script, example below will Detatch suppressor from mk17 and will:
            require toolbox and scrap metal, remove scrap, but leave toolbox
            ["weapon2change",       "toolneeded",   "magazineadded"(""=nothing),    "tooladded"(""=nothing),        "outputweapon",                 "Text"]
            ["SCAR_H_CQC_CCO",      "ItemToolbox",  "PartGeneric",                                  "",                                                     "SCAR_H_CQC_CCO_SD",    "Suppressor Detatched"]
    */
     
    _weapon = _this select 0;
    _toolitem = _this select 1;
    _magitem = _this select 2;
    _magitem2 = _this select 3;
    _weapoutput = _this select 4;
    _string = _this select 5;
     
    if(_toolitem !="" and !(player hasWeapon _toolitem))exitwith{
            _txt1 = (gettext (configFile >> 'cfgweapons' >> _toolitem >> 'displayName'));
            titleText [format["You need %1 for this",_txt1], "PLAIN DOWN"]; titleFadeOut 5;
    };
     
    closeDialog 0;
    player playActionNow "Medic";
    [player,"repair",0,false,10] call dayz_zombieSpeak;
    [player,10,true,(getPosATL player)] spawn player_alertZombies;
    sleep 2;
    player removeWeapon _weapon;
    sleep 2;
     
    if(_magitem !="")then{
            player addMagazine _magitem;
    };
     
    if(_magitem2 !="")then{
            player addMagazine _magitem2;
    };
     
    player addWeapon _weapoutput;
    sleep 1;
    player selectWeapon _weapoutput;
    titleText [format["%1",_string], "PLAIN DOWN"]; titleFadeOut 5;

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...