Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Paste the code below inside of a gamelogic or inside the initplayer.sqf, avoid copy this comment or you will get errors.
- if (isdedicated) exitWith {};
- RTG_Shotgun_TacReloadInProgress = 0;
- RTG_Shotgun_TacReload = {
- if (RTG_Shotgun_TacReloadInProgress == 1) exitWith {};
- RTG_Shotgun_TacReloadInProgress = 1;
- private _shotgun = currentMuzzle player;
- private _oldmagazine = currentMagazine player;
- private _MyMags = magazinesAmmo player;
- private _MyMags = _MyMags select {(currentMagazine player) in _x};
- private _fullMagNum = getNumber (configFile >> "CfgMagazines" >> _oldmagazine >> "count");
- private _AmmoInWeapon = player ammo currentMuzzle player;
- private _AmoutOfMags = count _MyMags;
- private _MyMagsAllAmmo = 0;
- {_MyMagsAllAmmo = _MyMagsAllAmmo + (_x select 1)} foreach _MyMags;
- sleep 0.1;
- if (_AmmoInWeapon == _fullMagNum) exitWith {systemChat "Weapon already Full"; RTG_Shotgun_TacReloadInProgress = 0;};
- if (_AmoutOfMags == 0) exitWith {systemChat "No mags to reload"; RTG_Shotgun_TacReloadInProgress = 0;};
- player playactionNow "GestureEmpty" ;
- player playactionNow "GestureReloadM4SSAS";
- sleep 1.4;
- if (_AmmoInWeapon < _fullMagNum) then {
- player setAmmo [_shotgun, (_AmmoInWeapon + 1)];
- _MyMagsAllAmmo = _MyMagsAllAmmo - 1;
- _AmmoInWeapon = player ammo currentMuzzle player;
- sleep 0.7;
- };
- while {((inputAction "User12") > 0 or ((inputAction "LeanLeft" > 0 and inputAction "LeanRight" > 0 ))) and _AmmoInWeapon < _fullMagNum and _MyMagsAllAmmo > 0} do {
- _AmmoInWeapon = player ammo currentMuzzle player;
- if (_AmmoInWeapon < _fullMagNum) then {
- _MyMagsAllAmmo = _MyMagsAllAmmo - 1;
- player setAmmo [_shotgun, (_AmmoInWeapon + 1)];
- sleep 0.7;
- };
- };
- player removeMagazines _oldmagazine;
- {
- if (_MyMagsAllAmmo > _fullMagNum) then {
- player addMagazine _oldmagazine;
- _MyMagsAllAmmo = abs (_MyMagsAllAmmo - _fullMagNum);
- };
- if (_MyMagsAllAmmo <= _fullMagNum and _MyMagsAllAmmo > 0) then {
- player addMagazine [_oldmagazine, _MyMagsAllAmmo];
- _MyMagsAllAmmo = 0;
- };
- } foreach _MyMags;
- player playactionNow "gestureNod" ;
- RTG_Shotgun_TacReloadInProgress = 0;
- };
- ["ShotgunTacReload", "onEachFrame"] call BIS_fnc_removeStackedEventHandler;
- ["ShotgunTacReload", "onEachFrame", {
- private _MyMags = magazinesAmmo player;
- private _MyMags = _MyMags select {(currentMagazine player) in _x};
- private _AmoutOfMags = count _MyMags;
- private _oldmagazine = currentMagazine player;
- private _fullMagNum = getNumber (configFile >> 'CfgMagazines' >> _oldmagazine >> 'count');
- private _AmmoInWeapon = player ammo (currentMuzzle player);
- if (
- vehicle player == player and
- _AmoutOfMags > 0 and
- _fullMagNum != _AmmoInWeapon and
- _fullMagNum < 9 and
- _fullMagNum > 4 and
- (['buck','slug','HE','frag','PPA','Stun','Pellets'] findIf {[_x, _oldmagazine] call BIS_fnc_inString} != -1) and
- ((inputAction "LeanLeft" > 0 and inputAction "LeanRight" > 0) or (inputAction "User12") > 0) and
- RTG_Shotgun_TacReloadInProgress == 0
- ) then {
- [] spawn RTG_Shotgun_TacReload;
- };
- }] call BIS_fnc_addStackedEventHandler;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement