mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 20:13:13 +03:00
Update player_switchWeapon.sqf
Use dayz_actionInProgress variable to prevent errors when players spam the weapon switching hotkeys. Thanks to @AirwavesMan for noticing the issue. Add check for "Throw" as current weapon to prevent animation if 3 key is pressed with no available primary or on-back weapon.
This commit is contained in:
@@ -40,7 +40,7 @@ dz_fn_switchWeapon = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (_option == 2) exitWith { // Switch to rifle
|
if (_option == 2) exitWith { // Switch to rifle
|
||||||
if (_current == "") exitWith { // No current weapon
|
if (_current == "" || {_current == "Throw"}) exitWith { // No current weapon
|
||||||
switch FIND_RIFLE do {
|
switch FIND_RIFLE do {
|
||||||
case 1: { //In primary
|
case 1: { //In primary
|
||||||
player selectWeapon primaryWeapon player;
|
player selectWeapon primaryWeapon player;
|
||||||
@@ -87,7 +87,7 @@ dz_fn_switchWeapon = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
if (_option == 4) exitWith { //Switch to melee or onBack
|
if (_option == 4) exitWith { //Switch to melee or onBack
|
||||||
if (_current == "") exitWith { //No current weapon
|
if (_current == "" || {_current == "Throw"}) exitWith { //No current weapon
|
||||||
switch FIND_MELEE do {
|
switch FIND_MELEE do {
|
||||||
case 1: { //In primary
|
case 1: { //In primary
|
||||||
player selectWeapon primaryWeapon player;
|
player selectWeapon primaryWeapon player;
|
||||||
@@ -162,6 +162,8 @@ dz_fn_switchWeapon_swap = {
|
|||||||
//Swaps rifle / melee forcing an animation
|
//Swaps rifle / melee forcing an animation
|
||||||
dz_fn_switchWeapon_swapSecure = {
|
dz_fn_switchWeapon_swapSecure = {
|
||||||
private ["_anim","_array","_str"];
|
private ["_anim","_array","_str"];
|
||||||
|
if (dayz_actionInProgress) exitWith {};
|
||||||
|
dayz_actionInProgress = true;
|
||||||
//animation states are in the form "AmovPerc...", "AmovPknl...", "AmovPpne..."
|
//animation states are in the form "AmovPerc...", "AmovPknl...", "AmovPpne..."
|
||||||
_array = toArray (animationState player);
|
_array = toArray (animationState player);
|
||||||
_str = toString [_array select 5,_array select 6,_array select 7];
|
_str = toString [_array select 5,_array select 6,_array select 7];
|
||||||
@@ -174,5 +176,6 @@ dz_fn_switchWeapon_swapSecure = {
|
|||||||
true call dz_fn_switchWeapon_swap;
|
true call dz_fn_switchWeapon_swap;
|
||||||
player removeEventHandler ["AnimDone", dz_switchWeapon_handler];
|
player removeEventHandler ["AnimDone", dz_switchWeapon_handler];
|
||||||
dz_switchWeapon_handler = nil;
|
dz_switchWeapon_handler = nil;
|
||||||
|
dayz_actionInProgress = false;
|
||||||
}];
|
}];
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user