Epoch/Sources/epoch_code/compile/vehicles/EPOCH_client_VehicleMaintananceDo.sqf

142 lines
4.3 KiB
Plaintext
Raw Normal View History

2017-07-31 16:28:18 +00:00
/*
Author: He-Man - Ignatz-Gaming
Contributors:
Description:
Repair / replac and remove Vehicle-parts
Licence:
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
Github:
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/vehicles/EPOCH_client_VehicleMaintananceDo.sqf
*/
private ["_secondlocalcheck","_repairarrays","_config","_VehicleRepairs","_reqiredMat","_searchname","_line","_returnmat"];
params ["_veh","_do","_hitpointname"];
_hitpointname = tolower _hitpointname;
2017-07-31 16:28:18 +00:00
_secondlocalcheck = false;
_returnmat = "";
_repairarrays = [];
_config = 'CfgEpochClient' call EPOCH_returnConfig;
_VehicleRepairs = getArray (_config >> "VehicleRepairs");
if (isnull _veh) exitwith {
2017-09-27 19:33:38 +00:00
['Error - No Vehicle found',5] call Epoch_message;
2017-07-31 16:28:18 +00:00
};
if !(alive _veh) exitwith {
2017-09-27 19:33:38 +00:00
['Error - Vehicle already dead',5] call Epoch_message;
2017-07-31 16:28:18 +00:00
};
if (EPOCH_Vehicle_MaintainLock) exitwith {};
EPOCH_Vehicle_MaintainLock = true;
switch _do do {
case 'repair': {
2018-05-14 18:00:29 +00:00
_reqiredMat = "NONE";
2017-07-31 16:28:18 +00:00
_searchname = _hitpointname;
if (["glass",_hitpointname] call Bis_fnc_instring) then {
2017-07-31 16:28:18 +00:00
_searchname = "glass";
};
{
_x params ["_name","","","_repairmat"];
_name = tolower _name;
2017-07-31 16:28:18 +00:00
if (_searchname isequalto _name) exitwith {
_reqiredMat = _repairmat;
};
} foreach _VehicleRepairs;
2018-05-14 18:00:29 +00:00
if (_reqiredMat isequalto "NONE") exitwith {
2017-09-27 19:33:38 +00:00
['Error - Can not find required Material',5] call Epoch_message;
2017-07-31 16:28:18 +00:00
};
2018-05-14 18:00:29 +00:00
if (!(_reqiredMat in (magazines player)) && !(_reqiredMat isequalto "")) exitwith {
2017-07-31 16:28:18 +00:00
_line = format ['You need %1 to repair',_reqiredMat call EPOCH_itemDisplayName];
2017-09-27 19:33:38 +00:00
[_line,5] call Epoch_message;
2017-07-31 16:28:18 +00:00
};
2018-05-14 18:00:29 +00:00
if !(_reqiredMat isequalto "") then {
player removemagazine _reqiredMat;
};
2017-07-31 16:28:18 +00:00
if (_hitpointname isequalto "glass") then {
{
if (["glass",tolower _x] call Bis_fnc_instring) then {
_repairarrays pushback [_x,0];
};
} foreach ((getAllHitPointsDamage _veh) select 0);
}
else {
_repairarrays pushback [_hitpointname,0];
};
};
case 'replace': {
2018-05-14 18:00:29 +00:00
_reqiredMat = "NONE";
2017-07-31 16:28:18 +00:00
_searchname = _hitpointname;
if (["glass", _hitpointname] call Bis_fnc_instring) then {
2017-07-31 16:28:18 +00:00
_searchname = "glass";
};
{
_x params ["_name","","","","_replacemat"];
_name = tolower _name;
2017-07-31 16:28:18 +00:00
if (_searchname isequalto _name) exitwith {
_reqiredMat = _replacemat;
};
} foreach _VehicleRepairs;
2018-05-14 18:00:29 +00:00
if (_reqiredMat isequalto "NONE") exitwith {
2017-09-27 19:33:38 +00:00
['Error - Can not find required Material',5] call Epoch_message;
2017-07-31 16:28:18 +00:00
};
2018-05-14 18:00:29 +00:00
if (!(_reqiredMat in (magazines player)) && !(_reqiredMat isequalto "")) exitwith {
2017-07-31 16:28:18 +00:00
_line = format ['You need %1 to repair',_reqiredMat call EPOCH_itemDisplayName];
2017-09-27 19:33:38 +00:00
[_line,5] call Epoch_message;
2017-07-31 16:28:18 +00:00
};
2018-05-14 18:00:29 +00:00
if !(_reqiredMat isequalto "") then {
player removemagazine _reqiredMat;
};
2017-07-31 16:28:18 +00:00
if (_hitpointname isequalto "glass") then {
{
if (["glass",tolower _x] call Bis_fnc_instring) then {
_repairarrays pushback [_x,0];
};
} foreach ((getAllHitPointsDamage _veh) select 0);
}
else {
_repairarrays pushback [_hitpointname,0];
};
};
case 'remove': {
if !(local _veh) exitwith {
2017-09-27 19:33:38 +00:00
_line = 'Error - You must get into drivers seat first!';
['Error - You must get into drivers seat first!',5] call Epoch_message;
2017-07-31 16:28:18 +00:00
};
_searchname = _hitpointname;
{
_x params ["_name","","","","_replacemat"];
_name = tolower _name;
2017-07-31 16:28:18 +00:00
if (_searchname isequalto _name) exitwith {
_returnmat = _replacemat;
};
} foreach _VehicleRepairs;
if (_returnmat isequalto "") exitwith {
['Error - Could not find Return Material!',5] call Epoch_message;
};
_repairarrays pushback [_hitpointname,1];
2017-09-25 17:06:08 +00:00
_secondlocalcheck = true;
2017-07-31 16:28:18 +00:00
};
};
if !(_repairarrays isequalto []) then {
2017-09-27 19:33:38 +00:00
player playMove 'AinvPknlMstpSnonWrflDnon_medic0';
player playMove 'AinvPknlMstpSnonWrflDnon_medicEnd';
2017-10-02 16:57:08 +00:00
_veh say3d 'vehicle_repair';
2017-09-27 19:33:38 +00:00
uisleep 5;
2017-10-02 16:27:09 +00:00
if (_secondlocalcheck && !local _veh) exitwith {
2017-10-02 16:57:08 +00:00
['Vehicle owner Changed - Go in as driver and try again!',5] call Epoch_message;
2017-10-02 16:27:09 +00:00
};
2017-07-31 16:28:18 +00:00
if !(_returnmat isequalto "") then {
_returnmat call EPOCH_fnc_addItemOverflow;
};
if (local _veh) then {
[_veh, _repairarrays] call EPOCH_client_repairVehicle;
} else {
[_veh,_repairarrays,player,Epoch_personalToken] remoteExec ["EPOCH_server_repairVehicle",2];
};
};
2017-09-25 17:06:08 +00:00
EPOCH_Vehicle_MaintainLock = false;