mudzereli Posted July 12, 2014 Report Share Posted July 12, 2014 Hey guys, I've been working on a script that allows players to take off weapon attachments from one weapon and put them on another. Hopefully some other people also enjoy it or find it useful. Weapon Attachment Mod 1.1.0 all of this information is available in an easier-to-read format on github pages >> note: This addon has been thoroughly tested but only on a low population server. if you have any issues on a high population server, let me know and I will try to address them. This addon lets players remove weapon mods from their weapons and apply them to other weapons. For example, you can take an ACOG scope off of an M4A1 and put it on a SA58, or add Gold Paint to a revolver, etc. It only works with existing weapon combos (you can't put a silencer on a DMR or anything like that) For an example, check out this imgur gallery or this video on twitch.tv: Features: configurable so you set your own combinations easy to use, just right click and remove or add the part admin list for adding modifications without the item note: Due to the way saving data works, unattached weapon modifications do not save across server restarts, so the player must attach the part to a weapon again before it will save. Players are notified of this whenever they remove a modification from a weapon or whenever they have their weapon mod inventory open. Installation download the files extract the addons and overwrites folder from the downloaded zip file into your mission file root add this line to the end of your mission file init.sqf. call compile preprocessFileLineNumbers "addons\wmod\init.sqf"; edit addons\wmod\config.sqf if you want to configure some options such as what guns it works with etc. Configuration note: Configuration instructions are easier to read on github. To edit the configuration options, open addons\wmod\conifg.sqf Some of the more complex configuration options are shown below (others are in the config.sqf) DZE_WEAPON_MODS array format DZE_WEAPON_MODS = [ [_attachment,_base,_upgrade], [_attachment,_base,_upgrade], [... more info here ...] ]; DZE_WEAPON_MODS array arguments parameter | description | type | example --------------|---------------------------------------------------------------------|--------|-------- _attachment | the name of the weapon attachment | string | "GP25 GL" _base | the classname that the attachment is put on to | string | "AK_74" _upgrade | the classname the item becomes after the attachment is put on | string | "AK_74_GL" DZE_WEAPON_MOD_COMBINE array format DZE_WEAPON_MOD_COMBINE = [ [_combined,_attachments], [_combined,_attachments], [... more info here ...] ]; DZE_WEAPON_MOD_COMBINE arguments parameter | description | type | example --------------|---------------------------------------------------------------------|--------|-------- _combined | the name of the attachment to combine the other attachments into | string | "CCO Sight" _attachments | array of attachments to combine into the combined attachment | array | ["Kobra Sight"] Issues/FAQ Users get kicked for publicvariable restriction #0 find your battleye filter directory open publicvariable.txt the first line should say 5 "" (... other stuff ...) change it to 5 "" !"DZE_WMOD_INVENTORY" (... other stuff ...) Change Log version|change -------|------- 1.1.0 | unused mods now persist after logout (but not server restart) | better inventory management system | more configurable options 1.0.1 | bug fix for removing attachments 1.0.0 | first release Brockie, calamity, MasterHiggins and 2 others 5 Link to comment Share on other sites More sharing options...
Boncz92 Posted July 12, 2014 Report Share Posted July 12, 2014 Lets say i take off my silencer... can i add it to my dmr? and also when its taken off do i get a item saying its a silencer? Link to comment Share on other sites More sharing options...
redcloud78 Posted July 12, 2014 Report Share Posted July 12, 2014 Does it just spawn in existing weapons or... something ive always wanted to see for a weird reason is the enfield with a scope top it off golden (no bullet drop on the enfield) Link to comment Share on other sites More sharing options...
mudzereli Posted July 12, 2014 Author Report Share Posted July 12, 2014 it only works with existing items/weapons. For example you can build a plain M4A1 up to like a M4A1 Holo SD Camo, or take a silencer off a PP Bizon and put it on a Makarov, but not take the silencer off of a M9 and put it on a DMR or anything like that. It does NOT give you any real items, this is why the users are warned that the attachments are not saved between logins/restarts. If I could find a way to add this I would, but you can't add new items in a mission file. The only other option would be to save it to the database (which would require more modification by server owners) or use some sort of placeholder item/cash out method. Link to comment Share on other sites More sharing options...
Creep Posted July 12, 2014 Report Share Posted July 12, 2014 The saving would be possible with 500+ calls for sure.. not that easy but possible, anyways a little suggestion :) try to add some sort of scrollmenu to the traders to buy the attachments ;) EDIT: Iam constantly getting "weapon modification interrupted" have a clear install of yours like your instructions says.. any special reason forthis? If I set myself to admin it actually works, but otherwise I cant add or remove anything Link to comment Share on other sites More sharing options...
Darihon Posted July 12, 2014 Report Share Posted July 12, 2014 Nice! Link to comment Share on other sites More sharing options...
calamity Posted July 12, 2014 Report Share Posted July 12, 2014 I added only the "wmod" dir to addons folder since I already use your deploy bike I added the call compile preprocessFileLineNumbers "addons\wmod\init.sqf"; but I too keep getting the "weapon modification interrupted" How would I add this to your deploy bike script ??? Link to comment Share on other sites More sharing options...
Creep Posted July 12, 2014 Report Share Posted July 12, 2014 I found the reason for the bug: fnc_wmod_hasWeaponModInventory = { private["_inventory","_mod"]; _mod = _this; _inventory = player getVariable["WeaponModInventory",[]]; ((_mod in _inventory) || ((getPlayerUID player) in DZE_WEAPON_MOD_ADMINS)) <- this line is causing it }; You need to do a check if the Weapon you want to detach a mod from is in your inventory Link to comment Share on other sites More sharing options...
STENCHOVDETH Posted July 12, 2014 Report Share Posted July 12, 2014 Hello Mudzereli, I would like to make a request if I may. That request being that you combine all 3 of the excellent addons that you have made [Deploy Bike/Suicide/Weapon Mod] into one script that works for all. Link to comment Share on other sites More sharing options...
mudzereli Posted July 12, 2014 Author Report Share Posted July 12, 2014 Or you give them items like ItemGeneric that acts like a silencer? If you are talking about giving a variant of a base item then I did not know that was possible. I tried to do it and could not load an item from the missionConfigFile. If you are talking about using placeholder items then yes it's possible but you would either need to count all the attachments as the same currency and add them to that item, or use 7-8 items as placeholders, which i don't think there are really enough free items to do that. The saving would be possible with 500+ calls for sure.. not that easy but possible, anyways a little suggestion :) try to add some sort of scrollmenu to the traders to buy the attachments ;) EDIT: Iam constantly getting "weapon modification interrupted" have a clear install of yours like your instructions says.. any special reason forthis? If I set myself to admin it actually works, but otherwise I cant add or remove anything I added only the "wmod" dir to addons folder since I already use your deploy bike I added the call compile preprocessFileLineNumbers "addons\wmod\init.sqf"; but I too keep getting the "weapon modification interrupted" How would I add this to your deploy bike script ??? I found the reason for the bug: fnc_wmod_hasWeaponModInventory = { private["_inventory","_mod"]; _mod = _this; _inventory = player getVariable["WeaponModInventory",[]]; ((_mod in _inventory) || ((getPlayerUID player) in DZE_WEAPON_MOD_ADMINS)) <- this line is causing it }; You need to do a check if the Weapon you want to detach a mod from is in your inventory This script uses a new version of the click handler so most likely if you guys are having issues you need to update the overwrites folder too (and possibly the deploy / suicide script if you havent updated them in a few days). Were you getting any RPT errors? I released 1.0.1 which fixes the removing bug. if you want to see the change you can see on github. It was checking to see if you had the weapon mod in your "mod inventory" to do the removal of a weapon mods. Hello Mudzereli, I would like to make a request if I may. That request being that you combine all 3 of the excellent addons that you have made [Deploy Bike/Suicide/Weapon Mod] into one script that works for all. I will think about the best way to do this, but this may make it easier for everyone, including myself. The reason I didn't do that in the first place is that all the scripts are so different but I agree, it may be best to do this. STENCHOVDETH 1 Link to comment Share on other sites More sharing options...
Creep Posted July 12, 2014 Report Share Posted July 12, 2014 There arent any RPT errors its the logic of the script itself the overall function triggers if the animation is finished && the function for checking if the mod is in the inventory (or your are and admin) the scriptslogic will also search for the mod you want want to detach, but you wont have it in your inventory if its the first use of the script spawn -> no mods in inventory -> detach silencer -> script searches for (_mod in _inventory) but there is no silencer yet -> finish script with else handling its already fixxed in your new one as I can see so no worries Link to comment Share on other sites More sharing options...
mudzereli Posted July 12, 2014 Author Report Share Posted July 12, 2014 The saving would be possible with 500+ calls for sure.. not that easy but possible, Saving to db is not the hard part. I want to be able to do it with minimal modification from the server admin and without adding new fields to the DB. I am working on a method that will save one of each weapon mod (but you will lose the rest) upon logout/restarts Creep 1 Link to comment Share on other sites More sharing options...
mudzereli Posted July 12, 2014 Author Report Share Posted July 12, 2014 There arent any RPT errors its the logic of the script itself the overall function triggers if the animation is finished && the function for checking if the mod is in the inventory (or your are and admin) the scriptslogic will also search for the mod you want want to detach, but you wont have it in your inventory if its the first use of the script spawn -> no mods in inventory -> detach silencer -> script searches for (_mod in _inventory) but there is no silencer yet -> finish script with else handling i responded to your earlier post above. It was bug that didn't handle removal properly. The function you are talking about is fine, but it was trying to check for the weapon mod even if you are removing a mod from another item (which it shouldnt have been doing). Thanks for pointing it out though, it helped me pinpoint the problem. Creep 1 Link to comment Share on other sites More sharing options...
Creep Posted July 12, 2014 Report Share Posted July 12, 2014 NVM Link to comment Share on other sites More sharing options...
mudzereli Posted July 13, 2014 Author Report Share Posted July 13, 2014 Hi all, I've updated the script to 1.1.0. The inventory is now managed a bit better (optional display in the form of hint message which pauses infistar's debug while it's on). Also the inventory saves across logouts (but NOT server restarts). I can't find any way to make it save to DB without having a custom hiveext.dll. 500 calls only seem to be able to get data but not create it. planned for future is some sort of trader-type feature Link to comment Share on other sites More sharing options...
redcloud78 Posted July 13, 2014 Report Share Posted July 13, 2014 The sd ammo is not added to certain weapons like pdw and m9 when you add silencer Link to comment Share on other sites More sharing options...
mudzereli Posted July 16, 2014 Author Report Share Posted July 16, 2014 The sd ammo is not added to certain weapons like pdw and m9 when you add silencer I can see where you are coming from but I don't really have any plans to add this ATM because its more focused just around the weapons. Link to comment Share on other sites More sharing options...
Phobix Posted July 17, 2014 Report Share Posted July 17, 2014 if we already have custom versions of some of the files, should we redirect some of your calls or can they just be loaded as is? Link to comment Share on other sites More sharing options...
Phobix Posted July 17, 2014 Report Share Posted July 17, 2014 Also, I think I am having a conflict with another mod that uses the same click code that you do. I am getting black screen where I can hear myself move around. The mod in question is Here is your code in ui_Select_slot.sqf { private["_classname","_text","_execute","_condition"]; _classname = _x select 0; _text = _x select 1; _execute = _x select 2; _condition = _x select 3; // if the clicked item matches, then assign the script call and display text if(_item == _classname && (call compile _condition)) then { _menu = _parent displayCtrl (1600 + _numActions); _menu ctrlShow true; _height = _height + (0.025 * safezoneH); uiNamespace setVariable ['uiControl', _control]; _menu ctrlSetText _text; _menu ctrlSetEventHandler ["ButtonClick",_execute]; _numActions = _numActions + 1; }; } forEach DZE_CLICK_ACTIONS; and here is his in the same file _erc_cfgActions = (missionConfigFile >> "WaTd" >> _item); _erc_numActions = (count _erc_cfgActions); if (isClass _erc_cfgActions) then { for "_j" from 0 to (_erc_numActions - 1) do { _menu = _parent displayCtrl (1600 + _j + _numActions); _menu ctrlShow true; _config = (_erc_cfgActions select _j); _text = getText (_config >> "text"); _script = getText (_config >> "script"); _height = _height + (0.025 * safezoneH); uiNamespace setVariable ['uiControl', _control]; _menu ctrlSetText _text; _menu ctrlSetEventHandler ["ButtonClick",_script]; }; }; Link to comment Share on other sites More sharing options...
mudzereli Posted July 17, 2014 Author Report Share Posted July 17, 2014 Also, I think I am having a conflict with another mod that uses the same click code that you do. I am getting black screen where I can hear myself move around. The mod in question is Here is your code in ui_Select_slot.sqf { private["_classname","_text","_execute","_condition"]; _classname = _x select 0; _text = _x select 1; _execute = _x select 2; _condition = _x select 3; // if the clicked item matches, then assign the script call and display text if(_item == _classname && (call compile _condition)) then { _menu = _parent displayCtrl (1600 + _numActions); _menu ctrlShow true; _height = _height + (0.025 * safezoneH); uiNamespace setVariable ['uiControl', _control]; _menu ctrlSetText _text; _menu ctrlSetEventHandler ["ButtonClick",_execute]; _numActions = _numActions + 1; }; } forEach DZE_CLICK_ACTIONS; and here is his in the same file _erc_cfgActions = (missionConfigFile >> "WaTd" >> _item); _erc_numActions = (count _erc_cfgActions); if (isClass _erc_cfgActions) then { for "_j" from 0 to (_erc_numActions - 1) do { _menu = _parent displayCtrl (1600 + _j + _numActions); _menu ctrlShow true; _config = (_erc_cfgActions select _j); _text = getText (_config >> "text"); _script = getText (_config >> "script"); _height = _height + (0.025 * safezoneH); uiNamespace setVariable ['uiControl', _control]; _menu ctrlSetText _text; _menu ctrlSetEventHandler ["ButtonClick",_script]; }; }; this should get it to work 1) don't modify my ui_selectSlot file at all (skip this part of WATD) 2) open overwrites\click_actions\config.sqf 3) put this in DZE_CLICK_ACTIONS array (so if it were the only thing in there it would look like this) DZE_CLICK_ACTIONS = [ ["ItemZombieParts","Smear Guts on you","[] execVM ""custom\walkamongstthedead\smear_guts.sqf"";","true"], ["ItemWaterbottle","Wash zombie guts","[] execVM ""custom\walkamongstthedead\usebottle.sqf"";","true"] ]; Link to comment Share on other sites More sharing options...
calamity Posted July 17, 2014 Report Share Posted July 17, 2014 Also, I think I am having a conflict with another mod that uses the same click code that you do. I am getting black screen where I can hear myself move around. The mod in question is Here is your code in ui_Select_slot.sqf I just added them together like this works great.... } forEach DZE_CLICK_ACTIONS; //### END MODIFIED CODE: extra click actions // Walking dead _erc_cfgActions = (missionConfigFile >> "WaTd" >> _item); _erc_numActions = (count _erc_cfgActions); if (isClass _erc_cfgActions) then { for "_j" from 0 to (_erc_numActions - 1) do { _menu = _parent displayCtrl (1600 + _j + _numActions); _menu ctrlShow true; _config = (_erc_cfgActions select _j); _text = getText (_config >> "text"); _script = getText (_config >> "script"); _height = _height + (0.025 * safezoneH); uiNamespace setVariable ['uiControl', _control]; _menu ctrlSetText _text; _menu ctrlSetEventHandler ["ButtonClick",_script]; }; }; // walking dead end _pos set [3,_height]; //hint format["Obj: %1 \nHeight: %2\nPos: %3",_item,_height,_grpPos]; _group ctrlShow true; ctrlSetFocus _group; _group ctrlSetPosition _pos; _group ctrlCommit 0; }; and add DZE_CLICK_ACTIONS = [ ["ItemZombieParts","Smear Guts on you","[] execVM ""custom\walkamongstthedead\smear_guts.sqf"";","true"], ["ItemWaterbottle","Wash zombie guts","[] execVM ""custom\walkamongstthedead\usebottle.sqf"";","true"] ]; Link to comment Share on other sites More sharing options...
mudzereli Posted July 17, 2014 Author Report Share Posted July 17, 2014 I just added them together like this works great.... } forEach DZE_CLICK_ACTIONS; //### END MODIFIED CODE: extra click actions // Walking dead _erc_cfgActions = (missionConfigFile >> "WaTd" >> _item); _erc_numActions = (count _erc_cfgActions); if (isClass _erc_cfgActions) then { for "_j" from 0 to (_erc_numActions - 1) do { _menu = _parent displayCtrl (1600 + _j + _numActions); _menu ctrlShow true; _config = (_erc_cfgActions select _j); _text = getText (_config >> "text"); _script = getText (_config >> "script"); _height = _height + (0.025 * safezoneH); uiNamespace setVariable ['uiControl', _control]; _menu ctrlSetText _text; _menu ctrlSetEventHandler ["ButtonClick",_script]; }; }; // walking dead end _pos set [3,_height]; //hint format["Obj: %1 \nHeight: %2\nPos: %3",_item,_height,_grpPos]; _group ctrlShow true; ctrlSetFocus _group; _group ctrlSetPosition _pos; _group ctrlCommit 0; }; and add DZE_CLICK_ACTIONS = [ ["ItemZombieParts","Smear Guts on you","[] execVM ""custom\walkamongstthedead\smear_guts.sqf"";","true"],["ItemWaterbottle","Wash zombie guts","[] execVM ""custom\walkamongstthedead\usebottle.sqf"";","true"]]; you should be able to skip the whole ui_selectSlot part and just do that bottom part and add DZE_CLICK_ACTIONS = [ ["ItemZombieParts","Smear Guts on you","[] execVM ""custom\walkamongstthedead\smear_guts.sqf"";","true"],["ItemWaterbottle","Wash zombie guts","[] execVM ""custom\walkamongstthedead\usebottle.sqf"";","true"]]; Link to comment Share on other sites More sharing options...
Goon Posted July 18, 2014 Report Share Posted July 18, 2014 Hi i have you blood / and build script working fine thank you for your work, but soon as i added this one i got kicked from my server, #0 "DZE_WMOD_INVENTORY" = [<null-object>,true] Would you have any idea's. many thanks keith Link to comment Share on other sites More sharing options...
mudzereli Posted July 18, 2014 Author Report Share Posted July 18, 2014 Hi i have you blood / and build script working fine thank you for your work, but soon as i added this one i got kicked from my server, #0 "DZE_WMOD_INVENTORY" = [<null-object>,true] Would you have any idea's. many thanks keith try this -- should fix it: https://github.com/mudzereli/DayZEpochWeaponMods#issuesfaq Link to comment Share on other sites More sharing options...
redcloud78 Posted July 18, 2014 Report Share Posted July 18, 2014 instead of calling from bottom of mission init could i call from my custom compiles instead like so? Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now