Author: Phantom Wolf
Author Website:

Short description: Allows a player to holster their weapons
Date: 2016-03-10 04:42
Submitted by: Pierre MGI


Comments: (1)
Rating:



 

Weapon holster

by
Phantom Wolf


Description
This script adds a local action to the player which allows him to holster his weapon, meaning putting a pistol on the pocket or a rifle on the back, or similar scenarios. It also includes an action to switch directly back to your primary weapon, which was not available if you were to use the holstering code, so a very similar action was implemented.

Code
PW_HolsterAction.sqf
while {alive player} do {
  waitUntil {primaryWeapon player != "" or handgunWeapon player != ""};
  _unitholsteraction = player addAction ["No weapon in hand",{
    player action ["SWITCHWEAPON",player,player,-1];
    },nil,6,false,true];
  waitUntil {currentWeapon player == "" or {primaryWeapon player == "" && handgunWeapon player == ""}};
  if (primaryWeapon player == "" && handgunWeapon player == "") exitWith {
    player removeAction _unitholsteraction;
  };
  player removeAction _unitholsteraction;
  _unitequipprimaryactiontext = "Weapon " + getText (configfile >> "CfgWeapons" >> primaryWeapon player >> "displayName");
   _unitequipprimaryaction = player addAction [_unitequipprimaryactiontext,{
     player action ["SWITCHWEAPON",player,player,0];
     },nil,6,false,true];
   waitUntil {currentWeapon player != "" or primaryWeapon player == ""};
   player removeAction _unitequipprimaryaction;
};

Syntax
[] execVM "PW_HolsterAction.sqf";

Parameters
NIL

Usage
TRIGGER - On Act, init.sqf ; need to be added in onPlayerRespawn.sqf, or EH respawn, in MP.
Example
_holster = [] execVM "PW_HolsterAction.sqf";





Tags: No tags