Français Solved Modifier la durée d'un traitement

  • Auteur de la discussion Auteur de la discussion ztqh
  • Date de début Date de début
Salut

Voici :
[CODE title="Config_Process.hpp"]class ProcessAction {
class oil {
MaterialsReq[] = {{"oil_unprocessed",1}};
MaterialsGive[] = {{"oil_processed",1}};
Text = "STR_Process_Oil";
ProcessDuration = 28;
NoLicenseCost = -1;
};

class diamond {
MaterialsReq[] = {{"diamond_uncut",1}};
MaterialsGive[] = {{"diamond_cut",1}};
Text = "STR_Process_Diamond";
ProcessDuration = 28;
NoLicenseCost = -1;
};

class heroin {
MaterialsReq[] = {{"heroin_unprocessed",1}};
MaterialsGive[] = {{"heroin_processed",1}};
Text = "STR_Process_Heroin";
ProcessDuration = 28;
NoLicenseCost = -1;
};

class lean {
MaterialsReq[] = {{"euphon",1}};
MaterialsGive[] = {{"lean",1}};
Text = "STR_Process_Lean";
ProcessDuration = 28;
NoLicenseCost = -1;
};

class lsd {
MaterialsReq[] = {{"LSD1",1}};
MaterialsGive[] = {{"LSD2",1}};
Text = "STR_Process_LSD";
ProcessDuration = 28;
NoLicenseCost = -1;
};

class crystalmeth {
MaterialsReq[] = {{"crystalmeth1",1}};
MaterialsGive[] = {{"crystalmeth2",1}};
Text = "STR_Process_crystalmeth";
ProcessDuration = 28;
NoLicenseCost = -1;
};

class sucre {
MaterialsReq[] = {{"sucre1",1}};
MaterialsGive[] = {{"sucre2",1}};
Text = "STR_Process_sucre";
ProcessDuration = 28;
NoLicenseCost = -1;
};

class riz {
MaterialsReq[] = {{"riz1",1}};
MaterialsGive[] = {{"riz2",1}};
Text = "STR_Process_riz";
ProcessDuration = 28;
NoLicenseCost = -1;
};

class chlore {
MaterialsReq[] = {{"chlore1",1}};
MaterialsGive[] = {{"chlore2",1}};
Text = "STR_Process_chlore";
ProcessDuration = 28;
NoLicenseCost = -1;
};

class tabac {
MaterialsReq[] = {{"tabac1",1}};
MaterialsGive[] = {{"tabac2",1}};
Text = "STR_Process_tabac";
ProcessDuration = 28;
NoLicenseCost = -1;
};

class gaz {
MaterialsReq[] = {{"gaz1",1}};
MaterialsGive[] = {{"gaz2",1}};
Text = "STR_Process_gaz";
ProcessDuration = 28;
NoLicenseCost = -1;
};

class alcool {
MaterialsReq[] = {{"alcool1",1}};
MaterialsGive[] = {{"alcool2",1}};
Text = "STR_Process_alcool";
ProcessDuration = 28;
NoLicenseCost = -1;
};

class copper {
MaterialsReq[] = {{"copper_unrefined",1}};
MaterialsGive[] = {{"copper_refined",1}};
Text = "STR_Process_Copper";
ProcessDuration = 28;
NoLicenseCost = -1;
};

class iron {
MaterialsReq[] = {{"iron_unrefined",1}};
MaterialsGive[] = {{"iron_refined",1}};
Text = "STR_Process_Iron";
ProcessDuration = 28;
NoLicenseCost = -1;
};

class sand {
MaterialsReq[] = {{"sand",1}};
MaterialsGive[] = {{"glass",1}};
Text = "STR_Process_Sand";
ProcessDuration = 28;
NoLicenseCost = -1;
};

class salt {
MaterialsReq[] = {{"salt_unrefined",1}};
MaterialsGive[] = {{"salt_refined",1}};
Text = "STR_Process_Salt";
ProcessDuration = 28;
NoLicenseCost = -1;
};

class cocaine {
MaterialsReq[] = {{"cocaine_unprocessed",1}};
MaterialsGive[] = {{"cocaine_processed",1}};
Text = "STR_Process_Cocaine";
ProcessDuration = 28;
NoLicenseCost = -1;
};

class marijuana {
MaterialsReq[] = {{"cannabis",1}};
MaterialsGive[] = {{"marijuana",1}};
Text = "STR_Process_Marijuana";
ProcessDuration = 28;
NoLicenseCost = -1;
};

class cement {
MaterialsReq[] = {{"rock",1}};
MaterialsGive[] = {{"cement",1}};
Text = "STR_Process_Cement";
ProcessDuration = 28;
NoLicenseCost = -1;
};
};
[/CODE]

[CODE title="fn_processAction.sqf"]private ["_vendor","_type","_itemInfo","_oldItem","_newItemWeight","_newItem","_oldItemWeight","_cost","_upp","_hasLicense","_itemName","_oldVal","_ui","_progress","_pgText","_cP","_materialsRequired","_materialsGiven","_noLicenseCost","_text","_filter","_totalConversions","_minimumConversions"];
_vendor = [_this,0,objNull,[objNull]] call BIS_fnc_param;
_type = [_this,3,"",[""]] call BIS_fnc_param;
//Error check
if (isNull _vendor || _type isEqualTo "" || (player distance _vendor > 10)) exitWith {};
life_action_inUse = true;//Lock out other actions during processing.

if (isClass (missionConfigFile >> "ProcessAction" >> _type)) then {
_filter = false;
_materialsRequired = M_CONFIG(getArray,"ProcessAction",_type,"MaterialsReq");
_materialsGiven = M_CONFIG(getArray,"ProcessAction",_type,"MaterialsGive");
_noLicenseCost = M_CONFIG(getNumber,"ProcessAction",_type,"NoLicenseCost");
_text = M_CONFIG(getText,"ProcessAction",_type,"Text");
} else {_filter = true;};

if (_filter) exitWith {life_action_inUse = false;};

_itemInfo = [_materialsRequired,_materialsGiven,_noLicenseCost,(localize format ["%1",_text])];
if (count _itemInfo isEqualTo 0) exitWith {life_action_inUse = false;};

//Setup vars.
_oldItem = _itemInfo select 0;
_newItem = _itemInfo select 1;
_cost = _itemInfo select 2;
_upp = _itemInfo select 3;
_exit = false;
if (count _oldItem isEqualTo 0) exitWith {life_action_inUse = false;};

_totalConversions = [];
{
_var = ITEM_VALUE(_x select 0);
if (_var isEqualTo 0) exitWith {_exit = true;};
if (_var < (_x select 1)) exitWith {_exit = true;};
_totalConversions pushBack (floor (_var/(_x select 1)));
} forEach _oldItem;

if (_exit) exitWith {life_is_processing = false; hint localize "STR_NOTF_NotEnoughItemProcess"; life_action_inUse = false;};

if (_vendor in [mari_processor,coke_processor,heroin_processor]) then {
_hasLicense = true;
} else {
_hasLicense = LICENSE_VALUE(_type,"civ");
};

_cost = _cost * (count _oldItem);

_minimumConversions = _totalConversions call BIS_fnc_lowestNum;
_oldItemWeight = 0;
{
_weight = ([_x select 0] call life_fnc_itemWeight) * (_x select 1);
_oldItemWeight = _oldItemWeight + _weight;
} count _oldItem;

_newItemWeight = 0;
{
_weight = ([_x select 0] call life_fnc_itemWeight) * (_x select 1);
_newItemWeight = _newItemWeight + _weight;
} count _newItem;

_exit = false;

if (_newItemWeight > _oldItemWeight) then {
_netChange = _newItemWeight - _oldItemWeight;
_freeSpace = life_maxWeight - life_carryWeight;
if (_freeSpace < _netChange) exitWith {_exit = true;};
private _estConversions = floor(_freeSpace / _netChange);
if (_estConversions < _minimumConversions) then {
_minimumConversions = _estConversions;
};
};

if (_exit) exitWith {hint localize "STR_Process_Weight"; life_is_processing = false; life_action_inUse = false;};

//Setup our progress bar.
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;

if (_hasLicense) then {
for "_i" from 0 to 1 step 0 do {
uiSleep (getNumber (missionConfigFile >> "ProcessAction" >> _type >> "ProcessDuration"));
_cP = _cP + 0.01;
_progress progressSetPosition _cP;
_pgText ctrlSetText format ["%3 (%1%2)...",round(_cP * 100),"%",_upp];
if (_cP >= 1) exitWith {};
if (player distance _vendor > 10) exitWith {};
};
if (player distance _vendor > 10) exitWith {hint localize "STR_Process_Stay"; "progressBar" cutText ["","PLAIN"]; life_is_processing = false; life_action_inUse = false;};

{
[false,(_x select 0),((_x select 1)*(_minimumConversions))] call life_fnc_handleInv;
} count _oldItem;

{
[true,(_x select 0),((_x select 1)*(_minimumConversions))] call life_fnc_handleInv;
} count _newItem;

"progressBar" cutText ["","PLAIN"];
if (_minimumConversions isEqualTo (_totalConversions call BIS_fnc_lowestNum)) then {hint localize "STR_NOTF_ItemProcess";} else {hint localize "STR_Process_Partial";};
life_is_processing = false; life_action_inUse = false;
} else {
if (CASH < _cost) exitWith {hint format [localize "STR_Process_License",[_cost] call life_fnc_numberText]; "progressBar" cutText ["","PLAIN"]; life_is_processing = false; life_action_inUse = false;};

for "_i" from 0 to 1 step 0 do {
uiSleep (getNumber (missionConfigFile >> "ProcessAction" >> _type >> "ProcessDuration"));
_cP = _cP + 0.01;
_progress progressSetPosition _cP;
_pgText ctrlSetText format ["%3 (%1%2)...",round(_cP * 100),"%",_upp];
if (_cP >= 1) exitWith {};
if (player distance _vendor > 10) exitWith {};
};

if (player distance _vendor > 10) exitWith {hint localize "STR_Process_Stay"; "progressBar" cutText ["","PLAIN"]; life_is_processing = false; life_action_inUse = false;};
if (CASH < _cost) exitWith {hint format [localize "STR_Process_License",[_cost] call life_fnc_numberText]; "progressBar" cutText ["","PLAIN"]; life_is_processing = false; life_action_inUse = false;};

{
[false,(_x select 0),((_x select 1)*(_minimumConversions))] call life_fnc_handleInv;
} count _oldItem;

{
[true,(_x select 0),((_x select 1)*(_minimumConversions))] call life_fnc_handleInv;
} count _newItem;

"progressBar" cutText ["","PLAIN"];
if (_minimumConversions isEqualTo (_totalConversions call BIS_fnc_lowestNum)) then {hint localize "STR_NOTF_ItemProcess";} else {hint localize "STR_Process_Partial";};
CASH = CASH - _cost;
[0] call SOCK_fnc_updatePartial;
life_is_processing = false;
life_action_inUse = false;
};
[/CODE]

Merci d'avance !
 
Dernière édition:
Pourtant la modif me semble ok et ça fonctionne bien chez moi :unsure:
Est-ce que tu as bien sauvegardé ton Config_Process.hpp ?

Pour débuger tu peux ajouter à la ligne 7 de ton fn_processAction.sqf :
Code:
systemChat format ["DEBUG sleep : %1",(getNumber (missionConfigFile >> "ProcessAction" >> _type >> "ProcessDuration"))];
Dis-moi ce qui est écrit dans le chat quand tu lances le traitement
 
Hello !

Est ce que tu peux supprimer cette ligne :
_pgText ctrlSetText format ["%3 (%1%2)...",round(_cP * 100),"%",_upp];
Et mettre ceci a la place ?
Code:
_pgText ctrlSetText format ["%3 (%1%2)...%4",round(_cP * 100),"%",_upp, (getNumber (missionConfigFile >> "ProcessAction" >> _type >> "ProcessDuration"))];
Et tu nous envoie un screen de ton écran quand tu traites ?