First module appearing in 3den (not zeus yet). Created custom PREP macros for compiling functions similar to CBA/ACE.
This commit is contained in:
1 parent
2a7c28af5f
commit
c5755fb259
42 files changed
+1805
-7
No files matched your search
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
Author: Clarky
|
||||
Usage:
|
||||
[
|
||||
"CLRK_fnc_VehicleUnloaded",
|
||||
[_target, _caller, _depot]
|
||||
] call CBA_fnc_serverEvent;
|
||||
|
||||
Intended to be run by an event handler call from a vehicle unload action from a player on a valid supply vehicle
|
||||
|
||||
*/
|
||||
|
||||
params ["_vehicle", "_player", "_depot"];
|
||||
|
||||
if (!isServer) exitWith {};
|
||||
|
||||
if (isNull _vehicle) exitWith {hint "Vehicle ain't exist";};
|
||||
if (isNull _player) exitWith {hint "Player ain't exist";};
|
||||
if (isNull _depot) exitWith {hint "Depot ain't exist";};
|
||||
|
||||
if !(_vehicle getVariable ["isSupplyVehicle", false]) exitWith {hint "Vehicle ain't supply vehicle";};
|
||||
|
||||
private _vehicleCurrent =
|
||||
_vehicle getVariable ["currentOre", 0];
|
||||
|
||||
private _transferRate =
|
||||
_vehicle getVariable ["transferRate", 50];
|
||||
|
||||
private _depotCurrent =
|
||||
_depot getVariable ["currentOre", 0];
|
||||
|
||||
private _depotMax =
|
||||
_depot getVariable ["maxOre", 300];
|
||||
|
||||
private _freeSpace =
|
||||
_depotMax - _depotCurrent;
|
||||
|
||||
if (_freeSpace <= 0) exitWith {
|
||||
|
||||
[
|
||||
"CLRK_ShowMessage",
|
||||
[
|
||||
1,
|
||||
0,
|
||||
"Depot is already full."
|
||||
],
|
||||
_player
|
||||
] call CBA_fnc_targetEvent;
|
||||
};
|
||||
|
||||
if (_vehicleCurrent <= 0) exitWith {
|
||||
|
||||
[
|
||||
"CLRK_ShowMessage",
|
||||
[
|
||||
2,
|
||||
0,
|
||||
"Vehicle has no Ore available."
|
||||
],
|
||||
_player
|
||||
] call CBA_fnc_targetEvent;
|
||||
};
|
||||
|
||||
private _amount =
|
||||
(_transferRate min _freeSpace)
|
||||
min _vehicleCurrent;
|
||||
|
||||
_vehicle setVariable [
|
||||
"currentOre",
|
||||
_vehicleCurrent - _amount,
|
||||
true
|
||||
];
|
||||
|
||||
_depot setVariable [
|
||||
"currentOre",
|
||||
_depotCurrent + _amount,
|
||||
true
|
||||
];
|
||||
|
||||
[
|
||||
"CLRK_ShowMessage",
|
||||
[
|
||||
0,
|
||||
0,
|
||||
format [
|
||||
"Unloaded %1 Ore. Depot now contains %2/%3.",
|
||||
_amount,
|
||||
_depot getVariable ["currentOre",0],
|
||||
_depotMax
|
||||
]
|
||||
],
|
||||
_player
|
||||
] call CBA_fnc_targetEvent;
|
||||
Reference in new issue
Block a user