Need help?
Create a topic in the appropriate section
Don't write everything in the chat!Take a look at the marketplace
There you can buy
everything related to game serversDon't want a ban?
Please read our rules
Don't disturb the order!Sell or buy?
Use services of the guarantor
We will make your deal safe



-
Similar Content
-
By DrTauren
На сколько я знаю, есть другой скрипт для создания системы крафта на сервер Altis Life, но данная статья позволит сделать это в разы проще. Без необходимости изменять кучу всего.
Установка:
1) Идём в папку core и создаем в ней папку craft. Затем в ней создаём файлы fn_craft.sqf, fn_craft_update.sqf, fn_craft_updateFilter.sqf, fn_craftAction.sqf и fn_craftCfg.sqf
2) В файл fn_craft.sqf вставляем этот код:
private["_dialog","_inv","_itemInfo","_filter"]; //Declare all private variables if(!dialog) then { //Verify if the window is open createDialog "Life_craft"; }; disableSerialization; //Disable Serialization if(life_is_processing) exitWith{ closeDialog 2001; closeDialog 0; }; _dialog = findDisplay 666; //find the craft dialog/window _inv = _dialog displayCtrl 669; //find the listbox of items can be created lbClear _inv; //clear the listbox _filter = _dialog displayCtrl 673; _filter lbAdd localize "STR_CRAFT_FILTER_Weapon"; _filter lbSetData[(lbSize _filter)-1,"weapon"]; _filter lbAdd localize "STR_CRAFT_FILTER_Uniform"; _filter lbSetData[(lbSize _filter)-1,"uniform"]; _filter lbAdd localize "STR_CRAFT_FILTER_Backpack"; _filter lbSetData[(lbSize _filter)-1,"backpack"]; _filter lbAdd localize "STR_CRAFT_FILTER_Item"; _filter lbSetData[(lbSize _filter)-1,"item"]; _filter lbSetCurSel 0; 3) В файл fn_craft_update.sqf вставляем это:
#include "..\..\script_macros.hpp" private["_dialog","_inv","_mats","_item","_struct","_str","_invSize","_matsNeed","_matsNum","_config","_itemFilter"]; //Declare all private variables disableSerialization; //Disable Serialization _dialog = findDisplay 666; //find the craft dialog/window _inv = _dialog displayCtrl 669; //find the listbox of items can be created _mats = _dialog displayCtrl 672; _struct = ""; if ((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";}; _item = lbData[669,(lbCurSel 669)]; _itemFilter = lbData[673,(lbCurSel 673)]; _config = [_itemFilter] call life_fnc_craftCfg; { if (_item == _x select 0) then { _matsNeed = _x select 1; _invSize = count _matsNeed; for [{_i = 0},{_i < _invSize - 1},{_i = _i + 2}] do { _str = M_CONFIG(getText,"VirtualItems",(_matsNeed select _i),"displayName"); _matsNum = _matsNeed select _i+1; _struct = _struct + format["%1x %2<br/>",_matsNum,(localize _str)]; }; }; } foreach (_config); if (_struct == "") then { _struct = "Es wird nichts benötigt"; }; _mats ctrlSetStructuredText parseText format[" <t size='0.8px'> %1 </t> ",_struct]; 4) В fn_craft_updateFilter.sqf:
#include "..\..\script_macros.hpp" disableSerialization; private["_list","_filter","_dialog","_inv","_mats","_filterBox","_item","_itemFilter"]; _dialog = findDisplay 666; //find the craft dialog/window _inv = _dialog displayCtrl 669; //find the listbox of items can be created _mats = _dialog displayCtrl 672; _filterBox = _dialog displayCtrl 673; _itemFilter = lbData[673,(lbCurSel 673)]; lbClear _inv; _struct = ""; _config = [_itemFilter] call life_fnc_craftCfg; { if(_itemFilter == "item") then{ _str = localize M_CONFIG(getText,"VirtualItems",(_x select 0),"displayName"); _inv lbAdd format["%1",_str]; //add a gun to the listbox _inv lbSetData[(lbSize _inv)-1,_x select 0]; //set the data of the gun } else { _itemInfo = [_x select 0] call life_fnc_fetchCfgDetails; _inv lbAdd format["%1",_itemInfo select 1]; //add a gun to the listbox _inv lbSetData[(lbSize _inv)-1,_itemInfo select 0]; //set the data of the gun _inv lbSetPicture[(lbSize _inv)-1,_itemInfo select 2]; }; } foreach (_config); _inv lbSetCurSel 0; _item = lbData[669,(lbCurSel 669)]; _config = [_itemFilter] call life_fnc_craftCfg; { if(_item == _x select 0)then { _matsNeed = _x select 1; _invSize = count _matsNeed; for [{_i = 0},{_i < _invSize - 1},{_i = _i + 2}] do { _str = M_CONFIG(getText,"VirtualItems",(_matsNeed select _i),"displayName"); _matsNum = _matsNeed select _i+1; _struct = _struct + format["%1x %2<br/>",_matsNum,(localize _str)]; }; }; } foreach (_config); _mats ctrlSetStructuredText parseText format[" <t size='0.8px'> %1 </t> ",_struct]; 5) В fn_craftAction.sqf:
#include "..\..\script_macros.hpp" private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight","_weightUsedItems"]; disableSerialization; _dialog = findDisplay 666; if((lbCurSel 669) isEqualTo -1) xitWith {hint localize "STR_ISTR_SelectItemFirst";}; _item = lbData[669,(lbCurSel 669)]; _allaterial = true; _itemFilter = lbData[673,(lbCurSel 673)]; _matsNeed = 0; _config = [_itemFilter] call life_fnc_craftCfg; life_action_inUse = true;//Lock out other actions during processing. { if (_item isEqualTo (_x select 0))then { _matsNeed = _x select 1; _invSize = count _matsNeed; for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do { _matsNum = _matsNeed select _i+1; if ((ITEM_VALUE(_matsNeed select _i)) < _matsNum) then {_allMaterial = false;}; }; }; } foreach (_config); _newItem = _item; diag_log format ["%1",allMaterial]; if (!_allMaterial) exitWith {hint localize "STR_PM_NoMaterial"; life_action_inUse = false;}; //Some checks if ((count _matsNeed) isEqualTo 0) exitWith {life_action_inUse = false;}; if (_itemFilter isEqualTo "backpack" && backpack player != "") exitWith { //hint localize "STR_CRAFT_AR_Backpack"; hint "Remove your backpack before making a new one."; life_action_inUse = false; }; if (_itemFilter isEqualTo "uniform" && uniform player != "") exitWith { //hint localize "STR_CRAFT_AR_Uniform"; hint "Remove your uniform before making a new one."; life_action_inUse = false; }; if (_itemFilter isEqualTo "weapon") then { if (!(player canAdd _newItem) || currentWeapon player != "") exitWith { hint localize "STR_NOTF_NoRoom"; life_action_inUse = false; }; }; if (_itemFilter isEqualTo "item") then { _weight = [_item] call life_fnc_itemWeight; _weightUsedItems = 0; for [{_i=0},{_i<(count _matsNeed)-1},{_i=_i+2}] do { _matsNum = _matsNeed select _i+1; _weightUsedItems = _weightUsedItems + (([(_matsNeed select _i)] call life_fnc_itemWeight) * _matsNum); diag_log format ["%1 - %2",(_matsNeed select _i),_weightUsedItems]; } if ((life_carryWeight - _weightUsedItems + _weight) > life_maxWeight) exitWith { hint localize "STR_NOTF_NoRoom"; life_action_inUse = false; }; }; _oldItem = _matsNeed; if (_itemFilter isEqualTo "item") then { _itemName = localize M_CONFIG(getText,"VirtualItems",_newItem,"displayName"); } else { _itemInfo = [_newItem] call life_fnc_fetchCfgDetails; _itemName = _itemInfo select 1; }; life_is_processing = true; _upp = format["Crafting %1",_itemName]; closeDialog 0; //Setup our progress bar. disableSerialization; 5 cutRsc ["life_progress","PLAIN"]; _ui = uiNamespae getVariable "life_progress"; _progress = _ui displayCtrl 38201; _pgText = _ui displayCtrl 38202; _pgText ctrlSetText format["%2 (1%1)...","%",_upp]; _progress progressSetPosition 0.01; _cP = 0.01; _removeItemSuccess = true; _invSize = count _oldItem; for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do { _handledItem = (_oldItem select _i); if(!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith {_removeItemSuccess = false;}; }; if (!_removeItemSuccess) exitWith {5 cutText ["","PLAIN"]; life_is_processing = false; life_action_inUse = false;}; for "_i" from 0 to 1 step 0 do { sleep 0.3; _cP = _cP + 0.01; _progress progressSetPosition _cP; _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp]; if(_cP >= 1) exitWith {}; }; if (_itemFilter isEqualTo "backpack") then { if(backpack player isEqualTo "") then { player addBackpack _newItem; } else { hint localize "STR_CRAFT_AR_Backpack"; life_is_processing = false; life_action_inUse = false; }; }; if (_itemFilter isEqualTo "uniform") then{ if(uniform player isEqualTo "") then{ player addUniform _newItem; } else { hint localize "STR_CRAFT_AR_Uniform"; life_is_processing = false; life_action_inUse = false; }; }; if (_itemFilter isEqualTo "weapon") then{ if(player canAdd _newItem) then{ player addIem _newItem; } else { if(currentWeapon player isEqualTo "") then{ player addWeapon _newItem; } else { 5 cutText ["","PLAIN"]; for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do { _handledItem = (_oldItem select _i); [true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv; }; life_is_processing = false; life_action_inUse = false; }; }; }; if (_itemFilter isEqualTo "item") then{ _handledItem = _newItem; [true,_handledItem,1] call life_fnc_handleInv; }; 5 cutText ["","PLAIN"]; titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"]; [0] call SOCK_fnc_updatePartial; life_is_processing = false; life_action_inUse = false; 6) В fn_craftCfg.sqf:
#include "..\..\script_macros.hpp" private["_craft","_return"]; _craft = param [0,"",[""]]; if(_craft == "") exitWith {closeDialog 0}; //Bad shop type passed. switch(_craft) do { case "weapon": { _return = [ //[Object classname, [item #1,quantity item #1,item #2,quantity item #2]],] ["hgun_Pistol_01_F", ["diamond_cut",2,"copper_refined",1]], ["SMG_01_F", ["gunbarrel",2,"copper_refined",5,"cloth",3,"diamond_uncut",2]], ["SMG_05_F", ["gunbarrel",1,"cloth",2,"copper_refined",4,"diamond_uncut",1]], ["hgun_PDW2000_F", ["gunbarrel",1,"cloth",1,"copper_refined",3]], ["optic_Aco", ["diamond_cut",2,"glass",2,"iron_refined",1]], ["optic_ACO_grn", ["diamond_cut",2,"glass",2,"iron_refined",1]], ["optic_Holosight", ["diamond_cut",3,"glass",3,"iron_refined",2]] ]; }; case "uniform": { _return = [ //[Object classname, [item #1,quantity item #1,item #2,quantity item #2]],] ["U_BG_leader", ["diamond_cut",5,"cloth",5,"iron_refined",8]] ]; }; case "backpack": { _return = [ //[Object classname, [item #1,quantity item #1,item #2,quantity item #2]],] ["B_Carryall_mcamo", ["diamond_cut",1,"cloth",4,"kevlar",2]] ]; }; case "item": { _return = [ //[Object classname, [item #1,quantity item #1,item #2,quantity item #2]],] ["spikeStrip", ["copper_refined",2]], ["lockpick", ["copper_refined",1]] ]; }; }; _return; 7) Открываем файл functions.hpp и добавляем туда:
class Crafting { file = "core\craft"; class craft {}; class craftAction {}; class craftCfg {}; class craft_update {}; class craft_updateFilter {}; }; 8) Открываем stringtable.xml и добавляем это:
<Package name="Craft"> <Key ID="STR_CRAFT_Title"> <Original>Crafting Menu</Original> </Key> <Key ID="STR_PM_CraftStats"> <Original>Object to craft</Original> </Key> <Key ID="STR_PM_CraftMaterials"> <Original>Materials needed</Original> </Key> <Key ID="STR_CRAFT_Button"> <Original>Craft</Original> </Key> <Key ID="STR_PM_NoMaterial"> <Original>You do not have all the required materials</Original> </Key> <Key ID="STR_CRAFT_Process"> <Original>You have crafted: %1</Original> </Key> <Key ID="STR_CRAFT_FILTER_Weapon"> <Original>Weapons</Original> </Key> <Key ID="STR_CRAFT_FILTER_PWeapon"> <Original>Prim. Weapons</Original> </Key> <Key ID="STR_CRAFT_FILTER_HWeapon"> <Original>Sec. Weapons</Original> </Key> <Key ID="STR_CRAFT_FILTER_Ammo"> <Original>Ammos</Original> </Key> <Key ID="STR_CRAFT_FILTER_Uniform"> <Original>Uniforms</Original> </Key> <Key ID="STR_CRAFT_FILTER_Vest"> <Original>Vests</Original> </Key> <Key ID="STR_CRAFT_FILTER_Backpack"> <Original>Backpacks</Original> </Key> <Key ID="STR_CRAFT_FILTER_Item"> <Original>Items</Original> </Key> <Key ID="STR_CRAFT_AR_Question"> <Original>Would you like to equip this item?</Original> </Key> <Key ID="STR_CRAFT_AR_Backpack"> <Original>If you chose yes your current backpack will be deleted and replaced by the new one else it will spawn on the ground</Original> </Key> <Key ID="STR_CRAFT_AR_PWeapon"> <Original>If you chose yes your prim. weapon will be deleted and replaced by the new one else it will spawn on the ground</Original> </Key> <Key ID="STR_CRAFT_AR_HWeapon"> <Original>If you chose yes your sec. weapon will be deleted and replaced by the new one else it will spawn on the ground</Original> </Key> <Key ID="STR_CRAFT_AR_Uniform"> <Original>If you chose yes your current uniform will be deleted and replaced by the new one else it will spawn on the ground</Original> </Key> <Key ID="STR_CRAFT_AR_Vest"> <Original>If you chose yes your current vest will be deleted and replaced by the new one else it will spawn on the ground</Original> </Key> </Package> 9) Переходим в папку dialog и создаём там файл craft.hpp со следующим содержимым:
class Life_craft { idd = 666; name= "life_craft"; movingEnable = false; enableSimulation = true; onLoad = "[] spawn life_fnc_craft"; class controlsBackground { class Life_RscTitleBackground:Life_RscText { colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", "(profilenamespace getvariable ['GUI_BCG_RGB_A',0.7])"}; idc = -1; x = 0.1; y = 0.2; w = 0.8; h = (1 / 25); }; class MainBackground:Life_RscText { colorBackground[] = {0, 0, 0, 0.7}; idc = -1; x = 0.1; y = 0.2 + (11 / 250); w = 0.8; h = 0.6 - (22 / 250); }; }; class controls { class Title : Life_RscTitle { colorBackground[] = {0, 0, 0, 0}; idc = 667; text = "$STR_CRAFT_Title"; x = 0.1; y = 0.2; w = 0.6; h = (1 / 25); }; class craftListHeader : Life_RscText { idc = 668; colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", 0.5}; text = "$STR_PM_CraftStats"; sizeEx = 0.04; x = 0.105; y = 0.26; w = 0.275; h = 0.04; }; //Craft list class craftList : life_RscListBox { idc = 669; sizeEx = 0.030; onLBSelChanged = "[] spawn life_fnc_craft_update"; x = 0.105; y = 0.31; w = 0.275; h = 0.44; }; //Materials list header class materialListHeader : Life_RscText { idc = 670; colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", 0.5}; text = "$STR_PM_CraftMaterials"; sizeEx = 0.04; x = 0.395; y = 0.26; w = 0.275; h = 0.04; }; //Materials list class materialList : Life_RscControlsGroup { idc = 671; w = 0.275; h = 0.44; x = 0.395; y = 0.30; class Controls { class mats : Life_RscStructuredText { idc = 672; sizeEx = 0.020; text = ""; x = 0; y = 0; w = 0.27; h = 0.44; }; }; }; //FILTER class FilterList : Life_RscCombo { idc = 673; colorBackground[] = {0,0,0,0.7}; onLBSelChanged = "[] call life_fnc_craft_updateFilter"; x = 0.69; y = 0.32; w = (6.25 / 30); h = (1 / 25); }; //Craft button class ButtonCraft : Life_RscButtonMenu { idc = 674; text = "$STR_CRAFT_Button"; colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", 0.5}; onButtonClick = "if(!life_is_processing) then {[] spawn life_fnc_craftAction};"; x = 0.69; y = 0.26; w = (6.25 / 40); h = (1 / 25); }; class CloseButtonKey : Life_RscButtonMenu { idc = -1; text = "$STR_Global_Close"; onButtonClick = "closeDialog 0;"; x = 0.1; y = 0.8 - (1 / 25); w = (6.25 / 40); h = (1 / 25); }; }; }; 10) Открываем файл Masterhandler.hpp и добавляем туда:
#include "craft.hpp" 11) В папке dialogs открываем player_inv.hpp и добавляем код:
class ButtonCrafting: Life_RscButtonMenu { idc = 2025; text = "Crafting"; onButtonClick = "createDialog ""Life_craft"";"; x = 0.1 + (6.25 / 19.8) + (1 / 250 / (safezoneW / safezoneH)); y = 0.805; w = (6.25 / 40); h = (1 / 25); };
Оригинал на английском:
https://www.altisliferpg.com/topic/3964-tutorial-crafting-system/
-
By BanDizel
Как изменить окно с черно из-за которого практически ничего не видно на зеленое ?
Пожалуйста, Войдите или Зарегистрируйтесь, чтобы увидеть это: Вложение.
Пожалуйста, Войдите или Зарегистрируйтесь, чтобы увидеть это: Вложение.
-
-
Our picks
Добрый вечер!
Не так давно создал локальный сервер для DayZ Mod с помощью DayzCC (дабы одному играть).
Проблема в том, что отсутствует журнал.
Пробовал ставить действие 20 на другие клавиши (на других форумах вычитал), думал поможет.
Версия DayZ'а 1.8.5.
Как можно исправить эту проблему, подскажите пожалуйста.
Пожалуйста, Войдите или Зарегистрируйтесь, чтобы увидеть это: Вложение.
Share this post
Link to post
Share on other sites