Français Solved Utiliser un objet physique pour ravitailler les stations-service

  • Auteur de la discussion Auteur de la discussion Mathias
  • Date de début Date de début
Statut
N'est pas ouverte pour d'autres réponses.

Mathias

User
22/4/21
43
1
0
300
Usa
Bonjour,

comment faire que pour remplir les station service , il faut un item physique et non virtuel ?
 
Solution
Hello! Je n'ai jamais testé la gestion des objets physiques dans les véhicules, mais théoriquement comme ceci ça devrait fonctionner :

Dans ton @The_Programmer/addons/fuel_station/client/fn_onKeyUpRefuel.sqf, tu peux remplacer :
Code:
_data = _vehicle getVariable ["Trunk",[]];
if ((count _data) isEqualTo 0) then {_vehicle setVariable ["Trunk",[[],0],true]; _data = [];} else {_data = (_data select 0);};

{
    if ((_x select 0) isEqualTo getText (missionConfigFile >> "Max_Settings_FuelStations" >> "fuel_types" >> _configName >> "item_refuel")) exitWith {
        _maxValue = (_x select 1);
    };
} forEach _data;
par :
Code:
_vehCargo = getItemCargo _vehicle;
for "_i" from 0 to ((count _vehCargo) - 1) do {
    _currentItem =...
Hello! Je n'ai jamais testé la gestion des objets physiques dans les véhicules, mais théoriquement comme ceci ça devrait fonctionner :

Dans ton @The_Programmer/addons/fuel_station/client/fn_onKeyUpRefuel.sqf, tu peux remplacer :
Code:
_data = _vehicle getVariable ["Trunk",[]];
if ((count _data) isEqualTo 0) then {_vehicle setVariable ["Trunk",[[],0],true]; _data = [];} else {_data = (_data select 0);};

{
    if ((_x select 0) isEqualTo getText (missionConfigFile >> "Max_Settings_FuelStations" >> "fuel_types" >> _configName >> "item_refuel")) exitWith {
        _maxValue = (_x select 1);
    };
} forEach _data;
par :
Code:
_vehCargo = getItemCargo _vehicle;
for "_i" from 0 to ((count _vehCargo) - 1) do {
    _currentItem = (_vehCargo select 0) select _i;

    if (_currentItem isEqualTo (getText (missionConfigFile >> "Max_Settings_FuelStations" >> "fuel_types" >> _configName >> "item_refuel"))) then {
        _maxValue = (_vehCargo select 1) select _i;
    };
};

Dans ton @The_Programmer/addons/fuel_station/client/fn_refuelLBChanged.sqf, remplace :
Code:
_data = _vehicle getVariable ["Trunk",[]];
if ((count _data) isEqualTo 0) then {_vehicle setVariable ["Trunk",[[],0],true]; _data = [];} else {_data = (_data select 0);};

{
    if ((_x select 0) isEqualTo getText (missionConfigFile >> "Max_Settings_FuelStations" >> "fuel_types" >> _configName >> "item_refuel")) exitWith {
        _range = (_x select 1);
    };
} forEach _data;
par :
Code:
_vehCargo = getItemCargo _vehicle;
for "_i" from 0 to ((count _vehCargo) - 1) do {
    _currentItem = (_vehCargo select 0) select _i;

    if (_currentItem isEqualTo (getText (missionConfigFile >> "Max_Settings_FuelStations" >> "fuel_types" >> _configName >> "item_refuel"))) then {
        _range = (_vehCargo select 1) select _i;
    };
};

Et :
Code:
_data = _vehicle getVariable ["Trunk",[]];
if ((count _data) isEqualTo 0) then {_vehicle setVariable ["Trunk",[[],0],true]; _data = [];} else {_data = (_data select 0);};

{
    if ((_x select 0) isEqualTo (getText (missionConfigFile >> "Max_Settings_FuelStations" >> "fuel_types" >> _configName >> "item_refuel"))) exitWith {
        _range = ((_x select 1) * (getNumber (missionConfigFile >> "Max_Settings_FuelStations" >> "fuel_types" >> _configName >> "liters_per_item_refuel_station")));
    };
} forEach _data;
par :
Code:
_vehCargo = getItemCargo _vehicle;
for "_i" from 0 to ((count _vehCargo) - 1) do {
    _currentItem = (_vehCargo select 0) select _i;

    if (_currentItem isEqualTo (getText (missionConfigFile >> "Max_Settings_FuelStations" >> "fuel_types" >> _configName >> "item_refuel"))) then {
        _range = ((_vehCargo select 1) select _i) * (getNumber (missionConfigFile >> "Max_Settings_FuelStations" >> "fuel_types" >> _configName >> "liters_per_item_refuel_station"));
    };
};

Pour finir, dans ton @The_Programmer/addons/fuel_stations/client/fn_refuelStation.sqf, remplace :
Code:
_data = _vehicle getVariable ["Trunk",[]];
if ((count _data) isEqualTo 0) then {_veh setVariable ["Trunk",[[],0],true]; _data = [];} else {_data = (_data select 0);};

{
    if ((_x select 0) isEqualTo _itemVar) exitWith {
        _fuelNow = (_x select 1);
    };
} forEach _data;
par :
Code:
_vehCargo = getItemCargo _vehicle;
for "_i" from 0 to ((count _vehCargo) - 1) do {
    _currentItem = (_vehCargo select 0) select _i;

    if (_currentItem isEqualTo _itemVar) then {
        _fuelNow = (_vehCargo select 1) select _i;
    };
};

Et :
Code:
_index = [_itemVar,((_vehicle getVariable "Trunk") select 0)] call TON_fnc_index;
_data = (_vehicle getVariable "Trunk") select 0;
_old = _vehicle getVariable "Trunk";

_itemsToRemove = (_fueltoput / getNumber (missionConfigFile >> "Max_Settings_FuelStations" >> "fuel_types" >> _fuelType >> "liters_per_item_refuel_station"));
_weight = ([_itemVar] call life_fnc_itemWeight) * _itemsToRemove;

if (_fuelNow == _itemsToRemove) then {
    _data deleteAt _index;
} else {
    _data set [_index,[_itemVar,(_fuelNow - _itemsToRemove)]];
};
_vehicle setVariable ["Trunk",[_data,(_old select 1) - _weight],true];
par :
Code:
for "_i" from 1 to _itemsToRemove do {
    _vehicle removeItem _itemVar;
};

Dis-moi si ça fonctionne correctement, ou pas :p
 
Solution
Statut
N'est pas ouverte pour d'autres réponses.