Da das alte Tutorial doch recht hingeklatscht wirkt habe ich mich dazu entschieden ein neues zu machen.
Durch das Craftingsystem kann man z.B. aus 5 Äpfeln einen Apfelsalat erstellen. Dies erfordert natürlich eine gewisse Konfiguration
Vorab:
Hiermit untersage ich wie immer die Verbreitung dieser Daten und die des von mir verfassten Tutorials in anderen Foren ohne vorher mein Einverständnis dazu einzuholen.
Schritt 1:
öffnet die Datei /Functions.h und fügt dort folgendes unter der "class action" ein ein:
und folgendes unter der "class Player_Menu":
und folgendes unter der "class config":
Schritt 2:
öffnet die Datei /dialog/MasterHandler.h und fügt dort folgendes ein:
Schritt 3:
öffnet die Datei /dialog/player_inv.hpp und fügt dort folgendes unter "class controls" ein:
class ButtonCraft : Life_RscButtonMenu {
idc = 2025;
text = "$STR_PM_Craft";
onButtonClick = "createDialog ""Life_craft"";";
x = 0.1 + (6.25 / 40) + (1 / 250 / (safezoneW / safezoneH));
y = 0.805;
w = (6.25 / 40);
h = (1 / 25);
};
Schritt 4:
öffnet die Datei /stringtable.xml und fügt dort folgendes ein:
<Package name="Craft">
<Key ID="STR_CRAFT_Title">
<Original>Crafting Menu</Original>
<German>Bau Menü</German>
</Key>
<Key ID="STR_PM_CraftStats">
<Original>Object to craft</Original>
<German>Sachen zum bauen</German>
</Key>
<Key ID="STR_PM_CraftMaterials">
<Original>Materials needed</Original>
<German>Benötigte Sachen</German>
</Key>
<Key ID="STR_CRAFT_Button">
<Original>Craft !</Original>
<German>Bauen !</German>
</Key>
<Key ID="STR_PM_NoMaterial">
<Original>You do not have all the required materials !</Original>
<German>Du hast nicht genug davon...!</German>
</Key>
<Key ID="STR_CRAFT_Process">
<Original>You have crafted : %1</Original>
<German>Du hast folgendes hergestellt : %1</German>
</Key>
<Key ID="STR_CRAFT_FILTER_Weapon">
<Original>Weapons</Original>
<German>Waffen</German>
</Key>
<Key ID="STR_CRAFT_FILTER_Uniform">
<Original>Uniforms</Original>
<German>Kleidung</German>
</Key>
<Key ID="STR_CRAFT_FILTER_Backpack">
<Original>Backpacks</Original>
<German>Rucksäcke</German>
</Key>
<Key ID="STR_CRAFT_FILTER_Item">
<Original>Items</Original>
<German>Items</German>
</Key>
<Key ID="STR_CRAFT_AR_Backpack">
<Original>You already have a backpack ! Put it on the ground before crafting a new.</Original>
<German>Du hast bereit einen Rucksack ! Pack den alten erstmal weg.</German>
</Key>
<Key ID="STR_CRAFT_AR_Uniform">
<Original>You already have an uniform ! Put it on the ground before crafting a new.</Original>
<German>Du hast bereits was an ! Mach dich nackt und versuch es nochmal.</German>
</Key>
</Package>
und das im Package "Player_Menu" :
<Key ID="STR_PM_Craft">
<Original>Craft</Original>
<German>Craft</German>
</Key>
Alles anzeigen
Schritt 5:
erstellt die Datei craft.hpp und fügt diese unter /dialog ein:
/*
File: craft.hpp
Description: Crafting System
Created by EdgeKiller
Coder: EdgeKiller
*/
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);
};
};
};
Alles anzeigen
Schritt 6:
erstellt die Datei fn_craftAction.sqf und fügt diese unter /core/actions ein:
/*
File: fn_craftAction.sqf
Author: EdgeKiller
Description:
Master handling for crafting an item.
*/
private["_dialog","_item","_itemInfo","_oldItem","_newItem","_upp","_itemName","_ui","_progress","_pgText","_cP","_allMaterial","_matsNeed","_invSize","_handledItem","_itemFilter","_backpackOldItems","_weight"];
disableSerialization;
_dialog = findDisplay 666;
if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";};
_item = lbData[669,(lbCurSel 669)];
_allMaterial = true;
_itemFilter = lbData[673,(lbCurSel 673)];
_matsNeed = 0;
_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 = [_matsNeed select _i] call life_fnc_varToStr;
_matsNum = _matsNeed select _i+1;
if((missionNamespace getVariable (_matsNeed select _i)) < _matsNum) exitWith {_allMaterial = false;};
};
};
} foreach (_config);
if(!_allMaterial) exitWith {hint localize "STR_PM_NoMaterial";};
//Some checks
if((count _matsNeed) == 0) exitWith {};
if(_itemFilter == "backpack" && backpack player != "") exitWith{
hint localize "STR_CRAFT_AR_Backpack";
};
if(_itemFilter == "uniform" && uniform player != "") exitWith{
hint localize "STR_CRAFT_AR_Uniform";
};
if(_itemFilter == "item") then {
_weight = ([_item] call life_fnc_itemWeight);
};
if(_itemFilter == "item" && (life_carryWeight + _weight) > life_maxWeight) exitWith {
hint localize "STR_NOTF_NoRoom";
};
if(_itemFilter == "weapon" && !(player canAdd _newItem) || currentWeapon player != "") exitWith {
hint localize "STR_NOTF_NoRoom";
};
_oldItem = _matsNeed;
_newItem = _item;
if(_itemFilter == "item") then{
_itemName = [_newItem] call life_fnc_varToStr;
} else {
_itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
_itemName = _itemInfo select 1;
};
_upp = format["Crafting %1",_itemName];
closeDialog 0;
//Setup our progress bar.
5 cutRsc ["life_progress","PLAIN"];
_ui = uiNameSpace 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,1] call life_fnc_varHandle;
if(!([false,_handledItem,_oldItem select _i+1] call life_fnc_handleInv)) exitWith {_removeItemSuccess = false;};
};
if(!_removeItemSuccess) exitWith {5 cutText ["","PLAIN"]; life_is_processing = false;};
[] call life_fnc_p_updateMenu;
life_is_processing = true;
while{true} 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 == "backpack") then{
if(backpack player == "") then{
player addBackpack _newItem;
}else{
hint localize "STR_CRAFT_AR_Backpack";
life_is_processing = false;
};
};
if(_itemFilter == "item") then{
_handledItem = [_newItem,1] call life_fnc_varHandle;
[true,_handledItem,1] call life_fnc_handleInv;
};
if(_itemFilter == "uniform") then{
if(uniform player == "") then{
player addUniform _newItem;
}else{
hint localize "STR_CRAFT_AR_Uniform";
life_is_processing = false;
};
};
if(_itemFilter == "weapon") then{
if(player canAdd _newItem) then{
player addItem _newItem;
} else {
if(currentWeapon player == "") then{
player addWeapon _newItem;
}else{
5 cutText ["","PLAIN"];
for [{_i=0},{_i<_invSize-1},{_i=_i+2}] do {
_handledItem = [_oldItem select _i,1] call life_fnc_varHandle;
[true,_handledItem,_oldItem select _i+1] call life_fnc_handleInv;
};
life_is_processing = false;
};
};
};
5 cutText ["","PLAIN"];
titleText[format[localize "STR_CRAFT_Process",_itemName],"PLAIN"];
life_is_processing = false;
Alles anzeigen
Schritt 7:
erstellt die Datei fn_craft.sqf und fügt diese unter /core/pmenu ein:
/*
File: fn_craft.sqf
Description: Crafting System
Created by EdgeKiller
Coder: EdgeKiller
*/
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;
Alles anzeigen
Schritt 8:
erstellt die Datei fn_craft_update.sqf und fügt diese unter /core/pmenu ein:
/*
File: fn_craft_update.sqf
Description: Crafting System
Created by EdgeKiller
Coder: EdgeKiller
*/
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 = [_matsNeed select _i] call life_fnc_varToStr;
_matsNum = _matsNeed select _i+1;
_struct = _struct + format["%1x %2<br/>",_matsNum,_str];
};
};
} foreach (_config);
if(_struct == "") then
{
_struct = "No material needed";
};
_mats ctrlSetStructuredText parseText format["
<t size='0.8px'>
%1
</t>
",_struct];
Alles anzeigen
Schritt 9:
erstellt die Datei fn_craft_updateFilter.sqf und fügt diese unter /core/pmenu ein:
/*
File: fn_craft_updateFilter.sqf
Description: Crafting System
Created by EdgeKiller
Coder: EdgeKiller
*/
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 = [_x select 0] call life_fnc_varToStr;
_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 = [_matsNeed select _i] call life_fnc_varToStr;
_matsNum = _matsNeed select _i+1;
_struct = _struct + format["%1x %2<br/>",_matsNum,_str];
};
};
} foreach (_config);
_mats ctrlSetStructuredText parseText format["
<t size='0.8px'>
%1
</t>
",_struct];
Alles anzeigen
Schritt 10:
erstellt die Datei fn_craftCfg.sqf und fügt diese unter /core/config ein:
#include <macro.h>
/*
File: fn_craftCfg.sqf
Author: EdgeKiller
Description:
Master configuration file for the crafting menu.
*/
private["_craft","_return"];
_craft = [_this,0,"",[""]] call BIS_fnc_param;
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_P07_F", ["life_inv_goldbar",2,"life_inv_copperr",1]]
];
if(__GETC__(life_adminlevel) > 0) then
{
_return pushBack
["SMG_01_F", ["life_inv_goldbar",6,"life_inv_copperr",3,"life_inv_ironr",3,"life_inv_diamondr",1]];
};
};
case "uniform":
{
_return = [
//[Object classname, [item #1,quantity item #1,item #2,quantity item #2]],]
["U_IG_Guerilla1_1", ["life_inv_goldbar",1]]
];
};
case "backpack":
{
_return = [
//[Object classname, [item #1,quantity item #1,item #2,quantity item #2]],]
["B_Carryall_oli", ["life_inv_goldbar",1]]
];
};
case "item":
{
_return = [
//[Object classname, [item #1,quantity item #1,item #2,quantity item #2]],]
["life_inv_pickaxe", ["life_inv_goldbar",1]],
["life_inv_goldbar", ["life_inv_goldbar",1,"life_inv_copperr",1]]
];
};
};
_return;
Alles anzeigen