Français Solved [Company System] Ajout d'un bouton 'Tout Déposer' dans le stockage entreprise

  • Auteur de la discussion Auteur de la discussion LouisWood
  • Date de début Date de début

LouisWood

User
29/12/19
5
2
2
250
Bonjour, j'ai récemment modifié le menu de stockage de l'entreprise pour qu'il ressemble à ceci :


Dans un premier temps j'ai donc fais l'affichage (en modifiant stockage.hpp et stockage_2.hpp) puis j'ai essayé de rendre les boutons "Tout Déposer"/"Tout Retirer" fonctionnels. J'ai réussi à faire fonctionner le bouton "Tout Récupérer" avec ces deux fichiers :
Le premier fichier fn_stockageAllRetrieve.sqf (pour le stockage commun)
[CODE title="Code"]/*
Author: Maxence Lyon
Altis DEV: https://altisdev.com/user/maxence-lyon
Teamspeak 3: ts.the-programmer.com
Web site: www.the-programmer.com
Steam: « Une Vache Sur CS – Maxence », please leave a message on my profile who says the exact reason before adding me.

Terms of use:
- This file is forbidden unless you have permission from the author. If you have this file without permission to use it please do not use it and do not share it.
- If you have permission to use this file, you can use it on your server however it is strictly forbidden to share it.
- Out of respect for the author please do not delete this information.

License number:
Server's name:
Owner's name:
*/
_entreprise = player getVariable ["current_entreprise",objNull];
if (isNull _entreprise) exitWith {closeDialog 0; hint (["STR_NO_ENTERPRISE","Max_Settings_Entreprise","Entreprise_Localization"] call theprogrammer_core_fnc_localize);};
if !((_entreprise getVariable ["entreprise_stockage_openned_by",player]) isEqualTo player) exitWith {closeDialog 0; hint (["STR_STOCKAGE_IN_USE","Max_Settings_Entreprise","Entreprise_Localization"] call theprogrammer_core_fnc_localize);};

disableSerialization;

if ((lbCurSel 9645) isEqualTo -1) exitWith {hint localize "STR_Global_NoSelection";};
_ctrl = (lbData[9645,(lbCurSel 9645)]);
_num = ctrlText 9648;
if !([_num] call TON_fnc_isnumber) exitWith {hint (["STR_BAD_VALUE","Max_Settings_Entreprise","Entreprise_Localization"] call theprogrammer_core_fnc_localize);};

_num = parseNumber (_num);
if (_num < 1) exitWith {hint (["STR_BAD_VALUE","Max_Settings_Entreprise","Entreprise_Localization"] call theprogrammer_core_fnc_localize);};

_data = _entreprise getVariable ["entreprise_items",[]];
_index = -1;

if ((count _data) > 0) then {
{
if (_ctrl isEqualTo (_x select 0)) exitWith {
_index = _forEachIndex;
};
} forEach _data;
};

if (_index isEqualTo -1) exitWith {};
_value = ((_data select _index) select 1);
if (_num > _value) exitWith {hint localize "STR_MISC_NotEnough"};


//Ce que j'ai ajouté par rapport au fichier fn_stockageRetrieve.sqf

_num2 = [_ctrl] call life_fnc_itemWeight;
_num1 = (floor (((life_maxWeight) - (life_carryWeight)) / _num2));
_num = if (_num1 <= _value) then {_num1} else { _value };

//


_num = [_ctrl,_num,life_carryWeight,life_maxWeight] call life_fnc_calWeightDiff;
if (_num isEqualTo 0) exitWith {hint localize "STR_NOTF_InvFull"};

if ((time - life_action_delay) < 1) exitWith {hint localize "STR_NOTF_ActionDelay";};
life_action_delay = time;

_weight = ([_ctrl] call life_fnc_itemWeight) * _num;

if ([true,_ctrl,_num] call life_fnc_handleInv) then {
if (_num isEqualTo _value) then {
_data deleteAt _index;
} else {
_data set [_index,[_ctrl,(_value - _num)]];
};

_entreprise setVariable ["entreprise_items",_data,true];
[_entreprise] call max_entreprise_fnc_stockageInventory;
[(_entreprise getVariable ["entreprise_id",0]),3,(_entreprise getVariable ["entreprise_items",[]])] remoteExecCall ["max_entreprise_fnc_updateEntreprise",2];

[] call SOCK_fnc_updateRequest;
_ctrl_name = getText (missionConfigFile >> "VirtualItems" >> _ctrl >> "displayName");
hint format [(["STR_SUCCES_RETRIEVE","Max_Settings_Entreprise","Entreprise_Localization"] call theprogrammer_core_fnc_localize),_num,localize _ctrl_name];
} else {
hint localize "STR_NOTF_InvFull";
};
[/CODE]

Le second fichier fn_stockageAllRetrieve2.sqf (pour le stockage privé)
[CODE title="Code"]/*
Author: Maxence Lyon
Altis DEV: https://altisdev.com/user/maxence-lyon
Teamspeak 3: ts.the-programmer.com
Web site: www.the-programmer.com
Steam: « Une Vache Sur CS – Maxence », please leave a message on my profile who says the exact reason before adding me.

Terms of use:
- This file is forbidden unless you have permission from the author. If you have this file without permission to use it please do not use it and do not share it.
- If you have permission to use this file, you can use it on your server however it is strictly forbidden to share it.
- Out of respect for the author please do not delete this information.

License number:
Server's name:
Owner's name:
*/
_entreprise = player getVariable ["current_entreprise",objNull];
if (isNull _entreprise) exitWith {closeDialog 0; hint (["STR_NO_ENTERPRISE","Max_Settings_Entreprise","Entreprise_Localization"] call theprogrammer_core_fnc_localize);};
if !((_entreprise getVariable ["entreprise_stockage2_openned_by",player]) isEqualTo player) exitWith {closeDialog 0; hint (["STR_STOCKAGE_IN_USE","Max_Settings_Entreprise","Entreprise_Localization"] call theprogrammer_core_fnc_localize);};

disableSerialization;
if ((lbCurSel 9745) isEqualTo -1) exitWith {hint localize "STR_Global_NoSelection";};
_ctrl = lbData[9745,(lbCurSel 9745)];
_num = ctrlText 9748;
if !([_num] call TON_fnc_isnumber) exitWith {hint (["STR_BAD_VALUE","Max_Settings_Entreprise","Entreprise_Localization"] call theprogrammer_core_fnc_localize);};

_num = parseNumber(_num);
if (_num < 1) exitWith {hint (["STR_BAD_VALUE","Max_Settings_Entreprise","Entreprise_Localization"] call theprogrammer_core_fnc_localize);};

_data = _entreprise getVariable ["entreprise_items_2",[]];
_index = -1;

if ((count _data) > 0) then {
{
if (_ctrl isEqualTo (_x select 0)) exitWith {
_index = _forEachIndex;
};
} forEach _data;
};

if (_index isEqualTo -1) exitWith {};
_value = ((_data select _index) select 1);
if (_num > _value) exitWith {hint localize "STR_MISC_NotEnough"};


//Ce que j'ai ajouté par rapport au fichier fn_stockageRetrieve2.sqf

_num2 = [_ctrl] call life_fnc_itemWeight;
_num1 = (floor (((life_maxWeight) - (life_carryWeight)) / _num2));
_num = if (_num1 <= _value) then {_num1} else { _value };

//


_num = [_ctrl,_num,life_carryWeight,life_maxWeight] call life_fnc_calWeightDiff;
if (_num isEqualTo 0) exitWith {hint localize "STR_NOTF_InvFull"};

_weight = ([_ctrl] call life_fnc_itemWeight) * _num;

if ([true,_ctrl,_num] call life_fnc_handleInv) then {
if (_num isEqualTo _value) then {
_data deleteAt _index;
} else {
_data set [_index,[_ctrl,(_value - _num)]];
};
_entreprise setVariable ["entreprise_items_2",_data,true];
[_entreprise] call max_entreprise_fnc_stockageInventory2;

[(_entreprise getVariable ["entreprise_id",0]),9,(_entreprise getVariable ["entreprise_items_2",[]])] remoteExecCall ["max_entreprise_fnc_updateEntreprise",2];
[] call SOCK_fnc_updateRequest;
} else {
hint localize "STR_NOTF_InvFull";
};
[/CODE]

Là ou ça ne fonctionne pas c'est pour le bouton "Tout Déposer" (les fichiers correspondants aux boutons sont "fn_stockageAllSell.sqf" et "fn_stockageAllSell2.sqf"). Je suis parti des fichiers fn_stockageSell.sqf et fn_stockageSell2.sqf (qui sont les fichiers correspondants aux boutons "Déposer") mais je suis bloqué je ne sais pas quoi modifier/rajouter pour les faire fonctionner. J'avais une "piste" avec ces deux lignes :
_num2 = [_ctrl] call life_fnc_itemWeight; //Pour avoir le poids de l'item
_num1 = (floor (((_maxWeight) - (_used)) / _num2)); //Pour savoir combien il reste de place dans l'inventaire de l'entreprise
Mais je n'ai pas trouvé comment les implémenter dans les fichiers pour déposer tout les items d'un seul coup.

Est ce que quelqu'un aurait une idée s'il vous plaît ?
 
  • Like
Les réactions: Zomblard
Solution
Yop!

Pour mettre le nombre d'items de type _ctrl que le joueur a dans son inventaire dans la variable _num, remplace :
Code:
_num = ctrlText 9649;
if !([_num] call TON_fnc_isnumber) exitWith {hint (["STR_BAD_VALUE","Max_Settings_Entreprise","Entreprise_Localization"] call theprogrammer_core_fnc_localize);};

_num = parseNumber (_num);
par :
Code:
_num = missionNamespace getVariable [format ["life_inv_%1",getText (missionConfigFile >> "VirtualItems" >> _ctrl >> "variable")],0];
Yop!

Pour mettre le nombre d'items de type _ctrl que le joueur a dans son inventaire dans la variable _num, remplace :
Code:
_num = ctrlText 9649;
if !([_num] call TON_fnc_isnumber) exitWith {hint (["STR_BAD_VALUE","Max_Settings_Entreprise","Entreprise_Localization"] call theprogrammer_core_fnc_localize);};

_num = parseNumber (_num);
par :
Code:
_num = missionNamespace getVariable [format ["life_inv_%1",getText (missionConfigFile >> "VirtualItems" >> _ctrl >> "variable")],0];
 
  • Love
Les réactions: LouisWood
Solution