-
Notifications
You must be signed in to change notification settings - Fork 7
/
servicePointActions.sqf
136 lines (115 loc) · 5.16 KB
/
servicePointActions.sqf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Vehicle Service Point (Rearm) by Axe Cop
// Rewritten for single currency, gems, briefcase support and 1.0.6 epoch compatibility by salival - https://github.com/oiad/
// Requires DayZ Epoch 1.0.6 for gem support.
private ["_vehicle","_costs","_fuel","_magazineCount","_weapon","_type","_name","_weaponType","_weaponName","_turret","_magazines","_ammo","_textMissing","_pos","_message","_action","_damage","_selection","_strH","_disabled","_amount","_enoughMoney","_moneyInfo","_wealth","_success","_reason","_cmpt"];
_vehicle = _this select 0;
_ammo = "";
_reason = "";
_action = (_this select 3) select 0;
_type = typeOf _vehicle;
_disabled = false;
_name = getText(configFile >> "cfgVehicles" >> _type >> "displayName");
_amount = (_this select 3) select 1;
if (_action == "rearm") then {
_magazineCount = (_this select 3) select 2;
_weapon = (_this select 3) select 3;
_weaponType = _weapon select 0;
_weaponName = _weapon select 1;
};
if (typeName _amount == "STRING") then {
if (_amount == (localize "str_temp_param_disabled")) then {
if (_action == "rearm") then {_reason = format[localize "STR_CL_SP_UNABLE_REARM",_weaponName]; _disabled = true};
if (_action == "repair") then {_reason = format[localize "STR_CL_SP_UNABLE_REPAIR",_name]; _disabled = true};
if (_action == "refuel") then {_reason = format[localize "STR_CL_SP_UNABLE_REFUEL",_name]; _disabled = true};
};
if (_amount == (localize "strwffree")) then {_amount = 0};
};
if (_disabled) exitWith {[_reason,1] call dayz_rollingMessages};
_enoughMoney = false;
_moneyInfo = [false, [], [], [], 0];
_wealth = player getVariable[Z_MoneyVariable,0];
if (Z_SingleCurrency) then {
_enoughMoney = (_wealth >= _amount);
} else {
Z_Selling = false;
if (Z_AllowTakingMoneyFromVehicle) then {false call Z_checkCloseVehicle};
_moneyInfo = _amount call Z_canAfford;
_enoughMoney = _moneyInfo select 0;
};
_success = if (Z_SingleCurrency) then {true} else {[player,_amount,_moneyInfo,true,0] call Z_payDefault};
if (!_success && {_enoughMoney}) exitWith {systemChat localize "STR_EPOCH_TRADE_GEAR_AND_BAG_FULL"}; // Not enough room in gear or bag to accept change
if (_enoughMoney) then {
_success = if (Z_SingleCurrency) then {_amount <= _wealth} else {[player,_amount,_moneyInfo,false,0] call Z_payDefault};
if (_success) then {
if (Z_SingleCurrency) then {
player setVariable[Z_MoneyVariable,(_wealth - _amount),true];
};
[player,50,true,getPosATL player] spawn player_alertZombies;
if (_action == "refuel") then {
[player,50,true,getPosATL player] spawn player_alertZombies;
_vehicle engineOn false;
[format[localize "STR_CL_SP_REFUELING",_name],1] call dayz_rollingMessages;
[_vehicle,"refuel",0,false] call dayz_zombieSpeak;
while {vehicle player == _vehicle} do {
if ([0,0,0] distance (velocity _vehicle) > 1) exitWith {[format[localize "STR_CL_SP_REFUELING_STOPPED",_name],1] call dayz_rollingMessages};
_fuel = (fuel _vehicle) + ((_this select 3) select 3);
if (_fuel > 0.99) exitWith {
_vehicle setFuel 1;
[format[localize "STR_CL_SP_REFUEL_OK",_name],1] call dayz_rollingMessages;
};
_vehicle setFuel _fuel;
uiSleep ((_this select 3) select 2);
};
};
if (_action == "repair") then {
_vehicle engineOn false;
[_vehicle,"repair",0,false] call dayz_zombieSpeak;
_hitpoints = _vehicle call vehicle_getHitpoints;
_allRepaired = true;
{
if ((vehicle player != _vehicle) || {[0,0,0] distance (velocity _vehicle) > 1}) exitWith {
_allRepaired = false;
[format[localize "STR_CL_SP_REPAIRING_STOPPED",_name],1] call dayz_rollingMessages;
};
_damage = [_vehicle,_x] call object_getHit;
if (_damage > 0) then {
_cmpt = [];
{
if (_forEachIndex > 2) then {_cmpt set [count _cmpt,_x]};
} forEach toArray (_x);
_cmpt = toString _cmpt;
[format[localize "STR_CL_SP_REPAIRING",_cmpt],1] call dayz_rollingMessages;
_selection = getText(configFile >> "cfgVehicles" >> _type >> "HitPoints" >> _x >> "name");
_strH = "hit_" + (_selection);
_vehicle setHit[_selection,0];
_vehicle setVariable [_strH,0,true];
uiSleep ((_this select 3) select 2);
};
} forEach _hitpoints;
PVDZ_veh_Save = [_vehicle,"repair"];
publicVariableServer "PVDZ_veh_Save";
if (_allRepaired) then {
_vehicle setDamage 0;
_vehicle setVelocity [0,0,1];
[format[localize "STR_CL_SP_REPAIR_OK",_name],1] call dayz_rollingMessages;
};
};
if (_action == "rearm") then {
_turret = _weapon select 2;
_magazines = getArray (configFile >> "CfgWeapons" >> _weaponType >> "magazines");
_ammo = _magazines select 0;
for "_i" from 1 to _magazineCount do {_vehicle addMagazineTurret [_ammo,_turret];};
[format[localize "STR_CL_SP_REARMED",_weaponName,_name],1] call dayz_rollingMessages;
};
call player_forceSave;
} else {
systemChat localize "STR_EPOCH_TRADE_DEBUG";
};
} else {
_itemText = if (Z_SingleCurrency) then {CurrencyName} else {[_amount,true] call z_calcCurrency};
if (Z_SingleCurrency) then {
systemChat format[localize "STR_CL_SP_FAIL_COINS",[_amount] call BIS_fnc_numberText,_itemText,_action,_name];
} else {
systemChat format[localize "STR_CL_SP_FAIL_BRIEFCASES",_itemText,_action,_name];
};
};