Page 1 of 1

Script: concealed weapons

Posted: Thu Nov 10, 2011 2:45 pm
by wolfenswan
Script: Concealed Weapons

This short script adds an action for the player to pull a concealed weapon, creating it out of thin air. As ARMA2 defaults to pull a gun as soon as it's equipped, it's hard to have player incognito by default without taking away all their weapons.

As the script fires it adds one of three random weapons and the corresponding magazines to the player's inventory and makes them pull the weapon.

The script's simple enough and you can easily change it to give specific weapons instead of random ones.

Known Bugs:
- as long as a player has not pulled the weapon, other players can activate their action for them when near; probably easy to fix but I'm ignoring it for now
- players have to change firemode/select through weapons ("F") after activating the script and pulling the gun; this is an arma2 thing, probably unfixable.

pullweaponaction.sqf
_unit = _this select 0;

_unit addAction ["<t color='#dddd00'>"+"Pull concealed weapon"+"</t>","scripts\pullweapon.sqf",[]];
pullweapon.sqf
Private ["_host","_value","_action"];

_host = _this select 0;
_action = _this select 2;
_value = floor(random 3);

if (_value == 0) then {
{_host addmagazine "20Rnd_B_765x17_Ball"} foreach [1,2];
_host addweapon "Sa61_EP1";
};

if (_value == 1) then {
{_host addmagazine "30Rnd_9x19_UZI"} foreach [1,2];
_host addweapon "UZI_EP1";
};

if (_value == 2) then {
{_host addmagazine "8Rnd_9x18_Makarov"} foreach [1,2,3];
_host addweapon "Makarov";
};

_host removeAction _action;

Re: Script: concealed weapons

Posted: Thu Nov 10, 2011 6:13 pm
by Draakon
[quote="wolfenswan"ยด]
- players have to change firemode/select through weapons ("F") after activating the script and pulling the gun; this is an arma2 thing, probably unfixable.
[/quote]

You always have to do that with any weapon that has multiple firemodes, no matter how you got your gun. Same goes to switching to other equipment.

Re: Script: concealed weapons

Posted: Fri Nov 11, 2011 12:35 am
by fer
wolfenswan wrote: Known Bugs:
- as long as a player has not pulled the weapon, other players can activate their action for them when near; probably easy to fix but I'm ignoring it for now
- players have to change firemode/select through weapons ("F") after activating the script and pulling the gun; this is an arma2 thing, probably unfixable.
The first issue can be fixed by changing the scope of the addAction - see the biki page for the addAction command for more details (iirc it's the final condition you need to set to "_target").

The second issue can also be fixed by ending the script with the selectWeapon command (again, see the biki for more details).

Re: Script: concealed weapons

Posted: Sat Jun 30, 2012 10:20 pm
by Black Mamba
Sorry for digging up that old thread, but as it happens, i just came up with another way to adress this issue this afternoon. I primarily made it for an ACE running server, using CBA functions, but i thought, hey, let's share a bit, so here is a "lite" version that should do the trick on a vanilla config.
Be aware that i couldn't test that one on a dedicated server. If anybody's bored to death, and happens to have a dedicated server in his pocket, well. You know what to do.

holsterinit.sqf
private ["_weap"];
sleep 5;
//_weap = currentWeapon _this;
//hint format ["%1", _weap];

if !(local _this) exitWith {};
_weap = currentWeapon _this;
if (_this hasWeapon _weap) then {
_this addAction ["Holster gun", "holster\holster.sqf", _weap];
} else {
_this addAction ["Pull gun", "holster\unholster.sqf", _weap];
};
holster.sqf
private ["_weap", "_caller", "_act"];

_weap = _this select 3;
_act = _this select 2;
_caller = _this select 1;

_weap = currentWeapon _caller;
sleep 0.01;
_caller removeWeapon _weap;
sleep 0.1;
_caller removeAction _act;
sleep 0.5;
_caller addAction ["Pull gun", "holster\unholster.sqf", _weap];
unholster.sqf
private ["_weap", "_caller", "_act"];

_weap = _this select 3;
_act = _this select 2;
_caller = _this select 1;

sleep 0.01;
_caller addWeapon _weap;
_caller selectWeapon _weap;
sleep 1;
_caller removeAction _act;
_caller addAction ["Holster gun", "holster\holster.sqf", _weap];
Basically what's left of it: it doesn't check if the weapon actually is a handgun, so you can actually make a machinegun disappear. Using CBA functions it was pretty easy, it could be done otherwise using inheritsFrom, though i fear this would be a bit cpu-tough on a large scale mission.
I use it by placing those three scripts in a holster folder, and calling the holsterinit script on every unit i need to have that ability.
Feel free to comment and modify/upgrade as needed.

Re: Script: concealed weapons

Posted: Sat Jun 30, 2012 10:33 pm
by wolfenswan
I've ditched my script and used this script instead:

http://www.armaholic.com/page.php?id=2135