bonjour je poste ce message suite a une discussion avec
Maxence sa serait pour modifier le script Farming System je voudrais que l on puisse creer un traitement de virtuel a physique
/*
Maxence
*/
class VirtualToPhysical_Processing {
class ExampleProcess {
object_required = "toolkit";
object_given = "TheProgrammer_cailloux";
text = "Traitement d'un truc";
time = 45;
required_licenses[] = {"license_civ_driver"};
};
};
#include "Config_ProcessVirtToPhysical.hpp"
#include "..\..\script_macros.hpp"
/*
Maxence...
/*
Maxence
*/
class VirtualToPhysical_Processing {
class ExampleProcess {
object_required = "toolkit";
object_given = "TheProgrammer_cailloux";
text = "Traitement d'un truc";
time = 45;
required_licenses[] = {"license_civ_driver"};
};
};
#include "Config_ProcessVirtToPhysical.hpp"
#include "..\..\script_macros.hpp"
/*
Maxence
*/
params ["_target", "_caller", "_actionId", "_type"];
_config = missionConfigFile >> "VirtualToPhysical_Processing";
if (life_action_inUse || (life_is_processing) || (_type isEqualTo "")) exitWith {hint "You cannot process your objects"};
if !(isClass (_config >> _type)) exitWith {};
if (_caller distance _target > 10) exitWith {hint localize "STR_ISTR_Lock_TooFar"};
_exit = false;
_config = _config >> _type;
_materialsRequired = getText (_config >> "object_required");
_materialsGiven = getText (_config >> "object_given");
_upp = getText (_config >> "text");
_time = getNumber (_config >> "time");
_license = getArray (_config >> "required_licenses");
if ((count _license) >= 1) then {
{
if (_x != "") then {
if !(missionNamespace getVariable [_x,false]) exitWith {_exit = true};
};
} forEach _license;
};
if (_exit) exitWith {hint localize "STR_Shop_Veh_NoLicense"};
_amount = ITEM_VALUE(_materialsRequired);
if (_amount isEqualTo 0) exitWith {hint localize "STR_NOTF_NotEnoughItemProcess"};
disableSerialization;
"progressBar" 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;
life_is_processing = true;
life_action_inUse = true;
for "_i" from 0 to 1 step 0 do {
uiSleep (_time / 100);
_cP = _cP + 0.01;
_progress progressSetPosition _cP;
_pgText ctrlSetText format ["%3 (%1%2)...",round(_cP * 100),"%",_upp];
if (_cP >= 1) exitWith {};
if (_caller distance _target > 10) exitWith {
hint localize "STR_Process_Stay";
life_is_processing = false;
};
};
"progressBar" cutText ["","PLAIN"];
if (life_is_processing) then {
_itemSpace = getNumber (configFile >> "cfgWeapons" >> _materialsGiven >> "ItemInfo" >> "mass");
_maxWeightPlayer = 0;
_maxUniform = getContainerMaxLoad uniform player;
_maxVest = getContainerMaxLoad vest player;
_maxBackpack = getContainerMaxLoad backpack player;
if (_maxUniform > 0) then {
_maxWeightPlayer = _maxWeightPlayer + _maxUniform;
};
if (_maxVest > 0) then {
_maxWeightPlayer = _maxWeightPlayer + _maxVest;
};
if (_maxBackpack > 0) then {
_maxWeightPlayer = _maxWeightPlayer + _maxBackpack;
};
_curentMass = (loadVest player * _maxUniform) + (loadBackpack player * _maxBackpack) + (loadUniform player * _maxUniform);
_objectToAdd = _amount;
if (_itemSpace > 0) then {
_objectToAdd = (floor ((_maxWeightPlayer - _curentMass) / _itemSpace)) min _amount;
};
if (_maxWeightPlayer isEqualTo 0) exitWith {hint "Unable to retrieve the player's inventory"};
if (_objectToAdd isEqualTo 0) exitWith {hint localize "STR_NOTF_InvFull"};
[false,_materialsRequired,_objectToAdd] call life_fnc_handleInv;
for "_i" from 1 to _objectToAdd do {
player addItem _materialsGiven;
};
titleText [localize "STR_NOTF_ItemProcess","PLAIN"];
[0] call SOCK_fnc_updatePartial;
};
life_action_inUse = false;
life_is_processing = false;
class processVirtToPhysical {};
this addAction["Traitement d'un truc",life_fnc_processVirtToPhysical,"ExampleProcess"];