Français [Crafting System] Voir chaque craft uniquement si tous les objets requis sont dans l'établi

  • Auteur de la discussion Auteur de la discussion Maxence
  • Date de début Date de début

Maxence

Leader
Membre du personnel
22/7/18
4 692
1 009
383
2 300
You really want to know ?
www.the-programmer.com
Bienvenue sur ce tutoriel qui vous permettra de cacher tous les crafts dans les établis pour lesquels le joueur n'a pas tous les objets requis pour les fabriquer lorsqu'il ouvre le menu.
Cela peut servir par exemple à obliger les gens à trouver la recette des crafts pour pouvoir les faire.
Ce tutoriel fait suite à la demande d'aide de A anto carlito

C'est parti !

Dans votre @The_Programmer/addons/crafting_system/client/fn_openWorkBench.sqf supprimez toutes ces lignes :
Code:
{
    _typeConfigPath = _x;
    _itemType = configName _typeConfigPath;

    if (isClass _typeConfigPath) then {
        for "_i" from 0 to (count _typeConfigPath)-1 do {
            _configPath = _typeConfigPath select _i;
            _itemClass = configName _configPath;

            if ((isClass _configPath) && (_itemType in ["vItem","weapon","magazine","vehicle","backpack","uniform"])) then {
                _condition = getText (_configPath >> "condition");
                _condition_result = if (_condition isEqualTo "") then {true} else {call compile _condition};

                if (!isNil "_condition_result") then {
                    if (_condition_result isEqualType true) then {
                        if (_condition_result isEqualTo true) then {
                            _itemResult = getText (_configPath >> "itemGive");
                            _itemName = "";
                            _icon = "";

                            switch (_itemType) do {
                                case "vItem" : {
                                    _itemConfig = missionConfigFile >> "VirtualItems" >> _itemResult;
                                    _itemName = localize (getText (_itemConfig >> "displayName"));
                                    _icon = getText (_itemConfig >> "icon");
                                };

                                case "weapon" : {
                                    _itemInfo = [_itemResult] call life_fnc_fetchCfgDetails;
                                    _itemName = _itemInfo select 1;
                                    _icon = _itemInfo select 2;
                                };

                                case "magazine" : {
                                    _itemInfo = [_itemResult] call life_fnc_fetchCfgDetails;
                                    _itemName = _itemInfo select 1;
                                    _icon = _itemInfo select 2;
                                };

                                case "vehicle" : {
                                    _vehicleInfo = [_itemResult] call life_fnc_fetchVehInfo;
                                    _itemName = _vehicleInfo select 3;
                                    _icon = _vehicleInfo select 2;
                                };

                                case "backpack" : {
                                    _itemInfo = [_itemResult] call life_fnc_fetchCfgDetails;
                                    _itemName = _itemInfo select 1;
                                    _icon = _itemInfo select 2;
                                };

                                case "uniform" : {
                                    _itemInfo = [_itemResult] call life_fnc_fetchCfgDetails;
                                    _itemName = _itemInfo select 1;
                                    _icon = _itemInfo select 2;
                                };

                                default {};
                            };

                            _craftsList lbAdd format ["- %1",_itemName];
                            _craftsList lbSetData [(lbSize _craftsList)-1,str [_itemType,_itemClass]];
                            if !(_icon isEqualTo "") then {
                                _craftsList lbSetPicture [(lbSize _craftsList)-1,_icon];
                            };
                        };
                    };
                };
            } else {
                if ((_itemClass isEqualTo "category_display_name") && ((count _typeConfigPath) > 1)) then {
                    if ((lbSize _craftsList) > 0) then {
                        _craftsList lbAdd "";
                        _craftsList lbSetData [(lbSize _craftsList)-1,"category"];
                    };

                    _craftsList lbAdd format ["%1 :",([(getText (_configPath)),"Max_Settings_Craft","Craft_Localization"] call theprogrammer_core_fnc_localize)];
                    _craftsList lbSetData [(lbSize _craftsList)-1,"category"];
                };
            };
        };
    };
} forEach ("true" configClasses (_config >> "crafts"));
Ensuite, dans votre @The_Programmer/addons/crafting_system/client/fn_workBenchInventory.sqf ajoutez à la fin :
Code:
_fnc_hasAllRequiredItems = {
    params [
        ["_itemType","",[""]],
        ["_itemClass","",[""]],
        ["_etabli",objNull,[objNull]]
    ];

    _itemClassConfig = missionConfigFile >> "Max_Settings_Craft" >> "crafts" >> _itemType >> _itemClass;
    _hasItems = true;

    if !(isClass _itemClassConfig) exitWith {false;};
    _data = (_etabli getVariable ["workbench_inventory",[[],0]]) select 0;

    {
        _hasItem = false;

        _index = [(_x select 0),_data] call max_craft_fnc_index;
        if !(_index isEqualTo -1) then {
            _value = (_data select _index) select 1;
            if (_value >= (_x select 1)) then {_hasItem = true;};
        };

        if !(_hasItem) exitWith {_hasItems = false;};
    } forEach (getArray (_itemClassConfig >> "itemsRequired"));

    _money = getNumber (_itemClassConfig >> "moneyRequired");
    if (_money > 0) then {if (life_cash < _money) then {_hasItems = false;};};

    _hasItems;
};

_craftsList = _display displayCtrl 6941;
lbClear _craftsList;

{
    _typeConfigPath = _x;
    _itemType = configName _typeConfigPath;

    if (isClass _typeConfigPath) then {
        for "_i" from 0 to (count _typeConfigPath)-1 do {
            _configPath = _typeConfigPath select _i;
            _itemClass = configName _configPath;

            if ((isClass _configPath) && (_itemType in ["vItem","weapon","magazine","vehicle","backpack","uniform"])) then {
                _condition = getText (_configPath >> "condition");
                _condition_result = if (_condition isEqualTo "") then {true} else {call compile _condition};

                if (!isNil "_condition_result") then {
                    if (_condition_result isEqualType true) then {
                        if (_condition_result isEqualTo true) then {
                            _itemResult = getText (_configPath >> "itemGive");
                            _itemName = "";
                            _icon = "";

                            switch (_itemType) do {
                                case "vItem" : {
                                    _itemConfig = missionConfigFile >> "VirtualItems" >> _itemResult;
                                    _itemName = localize (getText (_itemConfig >> "displayName"));
                                    _icon = getText (_itemConfig >> "icon");
                                };

                                case "weapon" : {
                                    _itemInfo = [_itemResult] call life_fnc_fetchCfgDetails;
                                    _itemName = _itemInfo select 1;
                                    _icon = _itemInfo select 2;
                                };

                                case "magazine" : {
                                    _itemInfo = [_itemResult] call life_fnc_fetchCfgDetails;
                                    _itemName = _itemInfo select 1;
                                    _icon = _itemInfo select 2;
                                };

                                case "vehicle" : {
                                    _vehicleInfo = [_itemResult] call life_fnc_fetchVehInfo;
                                    _itemName = _vehicleInfo select 3;
                                    _icon = _vehicleInfo select 2;
                                };

                                case "backpack" : {
                                    _itemInfo = [_itemResult] call life_fnc_fetchCfgDetails;
                                    _itemName = _itemInfo select 1;
                                    _icon = _itemInfo select 2;
                                };

                                case "uniform" : {
                                    _itemInfo = [_itemResult] call life_fnc_fetchCfgDetails;
                                    _itemName = _itemInfo select 1;
                                    _icon = _itemInfo select 2;
                                };

                                default {};
                            };

                            if ([_itemType,_itemClass,_workbench] call _fnc_hasAllRequiredItems) then {
                                _craftsList lbAdd format ["- %1",_itemName];
                                _craftsList lbSetData [(lbSize _craftsList)-1,str [_itemType,_itemClass]];
                                if !(_icon isEqualTo "") then {
                                    _craftsList lbSetPicture [(lbSize _craftsList)-1,_icon];
                                };
                            };
                        };
                    };
                };
            } else {
                if ((_itemClass isEqualTo "category_display_name") && ((count _typeConfigPath) > 1)) then {
                    if ((lbSize _craftsList) > 0) then {
                        _craftsList lbAdd "";
                        _craftsList lbSetData [(lbSize _craftsList)-1,"category"];
                    };

                    _craftsList lbAdd format ["%1 :",([(getText (_configPath)),"Max_Settings_Craft","Craft_Localization"] call theprogrammer_core_fnc_localize)];
                    _craftsList lbSetData [(lbSize _craftsList)-1,"category"];
                };
            };
        };
    };
} forEach ("true" configClasses (missionConfigFile >> "Max_Settings_Craft" >> "crafts"));

Et voila !