English Not solved Can weapons be crafted as vItems and then converted to normal weapons?

  • Bonjour Visiteur ! Les sujets de cette catégorie sont clos. Si vous souhaitez réouvrir, merci de nous contacter en précisant le lien du post à réouvrir !

    Hello Visiteur ! The topics in this category are closed. If you wish to reopen, please contact us with the link of the post you wish to reopen !
21/6/20
4
0
100
Hello dear members!
I would like to add weapons to the crafting script and wanted to know if it was possible to craft them as a vItem and then convert them into a normal weapon via the inventory.
If so, how and what should I enter here?
.Thanks in advance
 
Hello, if you use Crafting System :

Create a virtual item in your config_vItems.hpp, then in the config_master.hpp of Crafting System create the craft to get this virtual item. Then to transform the vItem to a weapon, in your fn_useItem.sqf, find this line :
Code:
switch (_item) do {
And add below :
Code:
case "VITEM_CLASSNAME": {
    closeDialog 0;
    _itemGive = "WEAPON_CLASSNAME";

    if ((!(player canAdd _itemGive)) && (currentWeapon player != "")) exitWith {
        hint (["STR_NOT_ENOUGHT_SPACE","Max_Settings_Craft","Craft_Localization"] call theprogrammer_core_fnc_localize);
    };

    if (player canAdd _itemGive) then {
        player addItem _itemGive;
    } else {
        player addWeapon _itemGive;
    };
};

Replace VITEM_CLASSNAME by the virtual item class and WEAPON_CLASSNAME by the classname of the weapon to get :)
 
  • Like
Les réactions: Jean-Baptiste
Okay thanks :)
Then add below :
Code:
case (_item isEqualTo "VITEM_CLASSNAME"): {
    closeDialog 0;
    _itemGive = "WEAPON_CLASSNAME";

    if ((!(player canAdd _itemGive)) && (currentWeapon player != "")) exitWith {
        hint (["STR_NOT_ENOUGHT_SPACE","Max_Settings_Craft","Craft_Localization"] call theprogrammer_core_fnc_localize);
    };

    if (player canAdd _itemGive) then {
        player addItem _itemGive;
    } else {
        player addWeapon _itemGive;
    };
};