Aller au contenu

Système de craft par EdgeKiller


Recommended Posts

Posté(e) (modifié)

Bonsoir tout le monde !

 

Ce soir je vous partage un système de craft que j'ai créer complétement moi même, donc exclusif !

 

Petit aperçu : 

 

https://www.youtube.com/watch?v=BJegFHppdkc

 

A faire :

- Traduire le script en allemand/italien/portugais

- Système de filtrage pour les vêtements/armes etc...

 

 

• Fichier "Functions.h", mettez ceci dans la class "Action" :

class craftAction {};

Dans la class "Config" :

class craftCfg {};

Puis dans la class "Player_Menu" : 

class craft {};
class craft_update {};

• Fichier "dialog\MasterHandler.h", ajoutez :

#include "craft.hpp"

• Fichier "dialog\player_inv.hpp", remplacez :

class ButtonAdminMenu : Life_RscButtonMenu {
	idc = 2021;
	text = "$STR_PM_AdminMenu";
	onButtonClick = "createDialog ""life_admin_menu"";";
	x = 0.1 + (6.25 / 40) + (1 / 250 / (safezoneW / safezoneH));
	y = 0.805;
	w = (6.25 / 40);
	h = (1 / 25);
};

Par :

class ButtonAdminMenu : Life_RscButtonMenu {
	idc = 2021;
	text = "$STR_PM_AdminMenu";
	onButtonClick = "createDialog ""life_admin_menu"";";
	x = 0.1 + (6.25 / 19.8) + (1 / 250 / (safezoneW / safezoneH));
	y = 0.805;
	w = (6.25 / 40);
	h = (1 / 25);
};

Puis en dessous ajoutez ceci :

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);
};

• Fichier "stringtable.xml", ajoutez :

<Package name="Craft">
	<Key ID="STR_CRAFT_Title">
		<Original>Crafting Menu</Original>
		<English>Crafting Menu</English>
		<German>Crafting Menu</German>
		<French>Menu de Crafting</French>
		<Italian>Crafting Menu</Italian>
		<Portuguese>Crafting Menu</Portuguese>
	</Key>
	<Key ID="STR_PM_CraftStats">
		<Original>Object to craft</Original>
 		<English>Object to craft</English>
 		<German>Object to craft</German>
		<French>Objet à crafter</French>
		<Italian>Object to craft</Italian>
		<Portuguese>Object to craft</Portuguese>
	</Key>
	<Key ID="STR_PM_CraftMaterials">
		<Original>Materials needed</Original>
 		<English>Materials needed</English>
 		<German>Materials needed</German>
		<French>Materiaux requis</French>
		<Italian>Materials needed</Italian>
		<Portuguese>Materials needed</Portuguese>
	</Key>
	<Key ID="STR_CRAFT_Button">
		<Original>Craft !</Original>
 		<English>Craft !</English>
 		<German>Craft !</German>
		<French>Craft !</French>
		<Italian>Craft !</Italian>
		<Portuguese>Craft !</Portuguese>
	</Key>
	<Key ID="STR_PM_NoMaterial">
		<Original>You do not have all the required materials !</Original>
 		<English>You do not have all the required materials !</English>
 		<German>You do not have all the required materials !</German>
		<French>Vous n'avez pas tous les matériaux requis !</French>
		<Italian>You do not have all the required materials !</Italian>
		<Portuguese>You do not have all the required materials !</Portuguese>
	</Key>
	<Key ID="STR_CRAFT_Process">
		<Original>You have crafted : %1</Original>
		<English>You have crafted : %1</English>
		<German>You have crafted : %1</German>
		<French>Vous avez crafté : %1</French>
		<Italian>You have crafted : %1</Italian>
		<Portuguese>You have crafted : %1</Portuguese>
	</Key>
</Package>

Et ceci dans le package "Player_Menu" :

<Key ID="STR_PM_Craft">
	<Original>Craft</Original>
	<English>Craft</English>
	<German>Craft</German>
	<French>Craft</French>
	<Italian>Craft</Italian>
	<Portuguese>Craft</Portuguese>
</Key>

• Dans le dossier "dialog" créer un fichier nommé "craft.hpp" :

/*
	File: craft.hpp
	Description: Crafting System
	Created by 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;
		};

		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;
		};

		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;
		};

		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;
				};
			};
		};

		class ButtonCraft : Life_RscButtonMenu {
			idc = 672;
			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);
		};
	};
};

• Dans le dossier "core/actions", créer un fichier nommé "fn_craftAction.sqf" :

/*
	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"];

disableSerialization;

_dialog = findDisplay 666;
if((lbCurSel 669) == -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";};
_item = lbData[669,(lbCurSel 669)];
_allMaterial = true;

_matsNeed = 0;

if(!(player canAdd _item)) exitWith {hint localize "STR_NOTF_NoRoom";};

_config = ["weapon"] 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 select 1);

if(!_allMaterial) exitWith {hint localize "STR_PM_NoMaterial";};

//Error checking
if((count _matsNeed) == 0) exitWith {};




//Setup vars.
_oldItem = _matsNeed;
_newItem = _item;

_itemInfo = [_newItem] call life_fnc_fetchCfgDetails;
_itemName = _itemInfo select 1;

_upp = format["Crafting %1",_itemName];




//Some more checks
if((count _oldItem) == 0) exitWith {};

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 {};
};

_invSize = count _oldItem;

if(!(player addItem _item)) exitWith {
	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;

• Dans le dossier "core/pmenu", créer un fichier nommé "fn_craft.sqf" :

/*
	File: fn_craft.sqf
	Description: Crafting System
	Created by EdgeKiller
    Coder: EdgeKiller
*/
private["_dialog","_inv","_config","_itemInfo"]; //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


_config = ["weapon"] call life_fnc_craftCfg;
{
	_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 select 1);

• Dans le dossier "core/pmenu", créer un fichier nommé "fn_craft_update.sqf" :

/*
	File: fn_craft_update.sqf
	Description: Crafting System
	Created by EdgeKiller
    Coder: EdgeKiller
*/
private["_dialog","_inv","_mats","_item","_struct","_str","_invSize","_matsNeed","_matsNum","_config"]; //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)];


_config = ["weapon"] 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 select 1);

if(_struct == "") then
{
	_struct = "No material needed";
};

_mats ctrlSetStructuredText parseText format["
<t size='0.8px'>
%1
</t>
",_struct];

• Pour finir dans le dossier "core/config", créer un fichier "fn_craftCfg.sqf" :

#include <macro.h>
/*
	File: fn_craftCfg.sqf
	Author: EdgeKiller

	Description:
	Master configuration file for the crafting menu.

*/
private["_craft"];
_craft = [_this,0,"",[""]] call BIS_fnc_param;
if(_craft == "") exitWith {closeDialog 0}; //Bad shop type passed.

switch(_craft) do
{
	case "weapon":
	{
		switch(true) do
		{
			default
			{
				["Weapons",
					[
						//[Object classname, [item #1,quantity item #1,item #2,quantity item #2]],]
						["hgun_P07_F", ["life_inv_goldbar",2,"life_inv_copperr",1]],
						["SMG_01_F", ["life_inv_goldbar",6,"life_inv_copperr",3,"life_inv_ironr",3,"life_inv_diamondr",1]]

					]
				];
			};
		};
	};
};

Il s'agit du fichier du config, qui comprend donc les crafts, le script fonctionne pour les armes/habits/accessoires, tous les items de Arma 3. Il y a deux exmples de craft, je pense qu'il est assez facil de comprendre comment ca marche, donc je ne vais pas vous l'expliquer !

 

Crédits : EdgeKiller

 

Si vous utilisez ce système, merci de mettre les crédits :)

 

ENJOY !

Modifié par edgekiller
  • Upvote 1
Posté(e)

Salut, je vien ici pour te dire grand bravo pour ce que tu a fait, j'ai trouvé ton post sur un autre poste ( altisdev ).

 

et trouvé se site la sur ta page d info de ta chaine youtube :)

 

J'ai suivi tes tutos d altislife qui mont beaucoup aidé, et ton script est juste magnifique mec, je les mis sur mon serveur, et comme promit je mettrai le droit d auteur en tout gros sur l intro de mon serveur (Script réaliser par EdgeKiller ) et dans les description car franchement je peut pas me permettre de pas le faire apres ce que tu a fait juste énorme le boulot respect mec.

 

tout fonctionne niquel mise a part dans l interface les mot ne s'affiche pas, apres j'ai peu etre oublié un truck.

 

Encore une fois bravo pour ton boulot, 1er script que j'ai vut d'aussi bien fait.

  • 1 month later...
Posté(e)

Alors pour moi, j'ai fait tout ce que tu as dit, et le problèmes, c'est que Craft est a la place de Sync Data, et la case Craft est noire.

Dès que je clique dessus, sa m'affiche: Resource Life_Craft not found.

Help plz :)

Veuillez vous connecter pour commenter

Vous pourrez laisser un commentaire après vous êtes connecté.



Connectez-vous maintenant
×
×
  • Créer...