Jump to content
  • 0

weapon attachments


dodget90

Question

10 answers to this question

Recommended Posts

  • 0

It's in each weapon config in dayz_code.pbo, which must not be edited.
I'm using right-click addon with customized attachAttachment.sqf

Spoiler

/*
    [InputAttachment,OutputWeapon,InputWeapon] call 'Custom\attachAttachment.sqf';
    Modified player_attachAttachment.sqf
*/

#include "\z\addons\dayz_code\util\Player.hpp"

private ["_attachment","_weapon","_newWeapon","_weaponInUse","_muzzle"];

//check if player is on a ladder and if so, exit
if (Player_IsOnLadder()) exitWith {
    closeDialog 0;
    (localize "str_player_21") call dayz_rollingMessages;
};

//name of items
_attachment = _this select 0;
_weapon = _this select 2;
_newWeapon = _this select 1;

//check if player has the attachment
if (!(_attachment in magazines player)) exitWith {
    closeDialog 0;
    localize "str_missingAttachment" call dayz_rollingMessages;
};

//check if player has the weapon
if (!(player hasWeapon _weapon)) exitWith {
    closedialog 0;
    localize "str_AttachmentmissingWeapon" call dayz_rollingMessages;
};

_weaponInUse = (currentWeapon player == _weapon);

call gear_ui_init;
player playActionNow "Medic";

sleep 3;

//remove attachment from inventory and replace weapon
player removeMagazine _attachment;
player removeWeapon _weapon;
player addWeapon _newWeapon;

//close gear
(findDisplay 106) closeDisplay 0;

//Select new weapon if the old was in use
if (_weaponInUse) then {
    _muzzle = (getArray (configFile >> "CfgWeapons" >> _newWeapon >> "muzzles")) select 0;
    if (_muzzle == "this") then
    {
        player selectWeapon _newWeapon;
    }
    else
    {
        player selectWeapon _muzzle;
    };
};

and removeAttachment.sqf

Spoiler

/*
    [OutputAttachment,InputWeapon,OutputWeapon] call 'Custom\removeAttachment.sqf';
    Modified player_removeAttachment.sqf
*/

#include "\z\addons\dayz_code\util\Player.hpp"

private ["_attachment","_weapon","_newWeapon","_weaponInUse","_muzzle"];

//check if player is on a ladder and if so, exit
if (Player_IsOnLadder()) exitWith {
    closeDialog 0;
    (localize "str_player_21") call dayz_rollingMessages;
};

_attachment = _this select 0;
_weapon = _this select 1;
_newWeapon = _this select 2;

//check that player has enough room in inventory
//Remove melee magazines (BIS_fnc_invAdd and BIS_fnc_invSlotsEmpty fix)
false call dz_fn_meleeMagazines;
if ((([player] call BIS_fnc_invSlotsEmpty) select 4) < 1) exitWith {
    closeDialog 0;
    (localize "str_player_24") call dayz_rollingMessages;
    true call dz_fn_meleeMagazines;
};
true call dz_fn_meleeMagazines;

//check that player has the weapon
if (!(player hasWeapon _weapon)) exitWith {
    closeDialog 0;
    (localize "str_AttachmentMissingWeapon3") call dayz_rollingMessages;
};

_weaponInUse = (currentWeapon player == _weapon);

call gear_ui_init;
player playActionNow "Medic";

sleep 3;

//replace weapon and add attachment to inventory
player removeWeapon _weapon;
player addWeapon _newWeapon;
player addMagazine _attachment;

//close gear
(findDisplay 106) closeDisplay 0;

//Select new weapon if the old was in use
if (_weaponInUse) then {
    _muzzle = (getArray (configFile >> "CfgWeapons" >> _newWeapon >> "muzzles")) select 0;
    if (_muzzle == "this") then
    {
        player selectWeapon _newWeapon;
    }
    else
    {
        player selectWeapon _muzzle;
    };
};

to enable attach&detach attachments like these below:

Spoiler

    ["SCAR_L_CQC","Attach Holo","['Attachment_Holo','SCAR_L_CQC_Holo','SCAR_L_CQC'] execVM 'Custom\attachAttachment.sqf';","true"],
    ["SCAR_L_CQC_Holo","Attach GL","['Attachment_M203','SCAR_L_CQC_EGLM_Holo','SCAR_L_CQC_Holo'] execVM 'Custom\attachAttachment.sqf';","true"],
    ["SCAR_L_CQC_Holo","Remove Holo","['Attachment_Holo','SCAR_L_CQC_Holo','SCAR_L_CQC'] execVM 'Custom\removeAttachment.sqf';","true"],
    ["SCAR_L_CQC_EGLM_Holo","Remove GL","['Attachment_M203','SCAR_L_CQC_EGLM_Holo','SCAR_L_CQC_Holo'] execVM 'Custom\removeAttachment.sqf';","true"],

    ["PKM_DZ","Attach Scope","['Attachment_PSO1','Pecheneg_DZ','PKM_DZ'] execVM 'Custom\attachAttachment.sqf';","true"],
    ["Pecheneg_DZ","Remove Scope","['Attachment_PSO1','Pecheneg_DZ','PKM_DZ'] execVM 'Custom\removeAttachment.sqf';","true"],

    ["m8_tws","Attach Suppressor","['Attachment_Sup556','m8_tws_sd','m8_tws'] execVM 'Custom\attachAttachment.sqf';","true"],
    ["m8_tws_sd","Remove Suppressor","['Attachment_Sup556','m8_tws_sd','m8_tws'] execVM 'Custom\removeAttachment.sqf';","true"],

    ["AK_107_pso","Attach GL","['Attachment_GP25','AK_107_GL_pso','AK_107_pso'] execVM 'Custom\attachAttachment.sqf';","true"],
    ["AK_107_GL_pso","Remove GL","['Attachment_GP25','AK_107_GL_pso','AK_107_pso'] execVM 'Custom\removeAttachment.sqf';","true"],
    ["AK_107_kobra","Attach GL","['Attachment_GP25','AK_107_GL_kobra','AK_107_kobra'] execVM 'Custom\attachAttachment.sqf';","true"],
    ["AK_107_GL_kobra","Remove GL","['Attachment_GP25','AK_107_GL_kobra','AK_107_kobra'] execVM 'Custom\removeAttachment.sqf';","true"],

    ["L85_Holo_DZ","Attach GL","['Attachment_M203','BAF_L85A2_UGL_Holo','L85_Holo_DZ'] execVM 'Custom\attachAttachment.sqf';","true"],
    ["BAF_L85A2_UGL_Holo","Remove GL","['Attachment_M203','BAF_L85A2_UGL_Holo','L85_Holo_DZ'] execVM 'Custom\removeAttachment.sqf';","true"],
    ["BAF_L85A2_RIS_ACOG","Attach GL","['Attachment_M203','BAF_L85A2_UGL_ACOG','BAF_L85A2_RIS_ACOG'] execVM 'Custom\attachAttachment.sqf';","true"],
    ["BAF_L85A2_UGL_ACOG","Remove GL","['Attachment_M203','BAF_L85A2_UGL_ACOG','BAF_L85A2_RIS_ACOG'] execVM 'Custom\removeAttachment.sqf';","true"],
    ["BAF_L85A2_RIS_SUSAT","Attach GL","['Attachment_M203','BAF_L85A2_UGL_SUSAT','BAF_L85A2_RIS_SUSAT'] execVM 'Custom\attachAttachment.sqf';","true"],
    ["BAF_L85A2_UGL_SUSAT","Remove GL","['Attachment_M203','BAF_L85A2_UGL_SUSAT','BAF_L85A2_RIS_SUSAT'] execVM 'Custom\removeAttachment.sqf';","true"],

 

Link to comment
Share on other sites

  • 0
On 12/5/2017 at 1:05 AM, dodget90 said:

whats involved in creating custom weapon attachments? for example, if I wanted to right click my Makarov and attach the pistol flashlight attachment from the weapon trader or add an acog scope to my kar 98 rifle

Unfortunately you can't put whatever you want on whatever gun since they require new models.

@Schalldampferis using click actions by @mudzereli it's one of the dependencies for deploy anything also by mudzereli.

Link to comment
Share on other sites

  • 0
5 hours ago, dodget90 said:

if I'm in the trader's menu buying a weapon and it says on the right what attachments said weapon can have and the font turns blue or green letting me know said attachment fits my weapon, where is the file so I can add my changes in there

https://github.com/EpochModTeam/DayZ-Epoch/blob/master/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_fillBuyableList.sqf#L20-L22

Link to comment
Share on other sites

  • 0
5 hours ago, salival said:

 

if (isText(configFile >> "CfgWeapons" >> _x >> "Attachments" >> _name) or _name in getArray (configFile >> "CfgWeapons" >> _x >> "magazines")) then {
 is this what I'm looking for, do I need to make my own config file for each weapon I modify? , the problem im having is when I go into the weapon menu and say click on the m9 for example, it will show me the weapon name, the magazines it can use and the attachments in this example it says I can use a 9mm Suppressor, if I then buy the weapon and then go back into the traders and select the attachments list then the 9mm suppresor text will be blue if it attaches to my weapon and green if I already have it, but the weapons I have modified still say attachments none in the trader list, what you guys have already helped me with I can right click the weapon in my inventory and attach things no problem there but I cant click on the attachments and attach them that way, I hope I explained this well and I appreciate the help so far I was just wondering if this is possible

Link to comment
Share on other sites

  • 0
19 minutes ago, dodget90 said:

 

if (isText(configFile >> "CfgWeapons" >> _x >> "Attachments" >> _name) or _name in getArray (configFile >> "CfgWeapons" >> _x >> "magazines")) then {
 is this what I'm looking for, do I need to make my own config file for each weapon I modify? , the problem im having is when I go into the weapon menu and say click on the m9 for example, it will show me the weapon name, the magazines it can use and the attachments in this example it says I can use a 9mm Suppressor, if I then buy the weapon and then go back into the traders and select the attachments list then the 9mm suppresor text will be blue if it attaches to my weapon and green if I already have it, but the weapons I have modified still say attachments none in the trader list, what you guys have already helped me with I can right click the weapon in my inventory and attach things no problem there but I cant click on the attachments and attach them that way, I hope I explained this well and I appreciate the help so far I was just wondering if this is possible

I'm unsure if you understand what I was saying, you can't make custom attachments, the attachment system basically swaps out the gun for a different version that has said attachment

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Discord

×
×
  • Create New...