fnc_reloadExternal.sqf 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. params ["_target", "_player", "_params"];
  2. if(!alive _target) exitWith {
  3. [format["Static Weapon is Destroyed"], true, 4, 0] call ace_common_fnc_displayText;
  4. };
  5. if(!alive _player) exitWith {
  6. [format["Can't reload while you're dead!"], true, 4, 0] call ace_common_fnc_displayText;
  7. };
  8. _currentTurret = _target currentWeaponTurret [0];
  9. if(_currentTurret == "") then {
  10. _currentTurret = _target weaponsTurret [0] select 0;
  11. if(_currentTurret == "") exitWith {
  12. ["Doesn't look like this is a valid static weapon", true, 4, 0] call ace_common_fnc_displayText;
  13. };
  14. };
  15. _compatMags = [_currentTurret] call CBA_fnc_compatibleMagazines;
  16. _magazines = (magazinesAmmo _player) select {_x select 1 > 0 && (_x select 0) in _compatMags};
  17. _magazines sort false;
  18. if(count _magazines == 0) exitWith {
  19. ["You aren't carrying any compatible mags", true, 4, 0] call ace_common_fnc_displayText;
  20. };
  21. _magazine = _magazines select 0;
  22. _ammoAmount = _magazine select 1;
  23. _magazine = _magazine select 0;
  24. private _onFinish = {
  25. (_this select 0) params ["_player", "_target", "_magazine", "_ammoAmount"];
  26. [_player, _magazine, _ammoAmount] call ace_common_fnc_removeSpecificMagazine;
  27. ["rd501_external_reload", [_target, _magazine, _ammoAmount]] call CBA_fnc_globalEvent;
  28. [format["Reload Complete"], true, 4, 0] call ace_common_fnc_displayText;
  29. [_player, "AmovPknlMstpSrasWrflDnon", 1] call ace_common_fnc_doAnimation;
  30. };
  31. private _onFailure = {
  32. (_this select 0) params ["_player", "_target"];
  33. [_player, "AmovPknlMstpSrasWrflDnon", 1] call ace_common_fnc_doAnimation;
  34. };
  35. [_player, "AinvPknlMstpSnonWnonDr_medic5", 0] call ace_common_fnc_doAnimation;
  36. _timeToLoad = 5;
  37. if (!isNull(configFile >> "CfgVehicles" >> (typeOf _target) >> "rd501_external_reload_time")) then {
  38. _timeToLoad = getNumber(configFile >> "CfgVehicles" >> (typeOf _target) >> "rd501_external_reload_time");
  39. };
  40. [_timeToLoad, [_player, _target, _magazine, _ammoAmount], _onFinish, _onFailure, ("Reloading")] call ace_common_fnc_progressBar;