celery 8 Posted February 25, 2011 (edited) It seems that a script like this could be useful for some people so here is a simple sidearm holstering script that I made for an SP mission. The script remembers the sidearm's classname and leaves the magazines intact. In theory it should work in team switching and respawn missions. You can add a hidden sidearm at start with this setVariable ["CLY_holsteredgun","gunclassname",false] cly_holster.sqs ;CLY Holster written by Celery ;Enables a player to holster and unholster his sidearm. ; ;Execute in the init script with [] exec "cly_holster" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ?isDedicated:exit #start @alive player ?count _this>0:goto "holster" _unit=player ?isNil {_unit getVariable "CLY_holsteredgun"}:_unit setVariable ["CLY_holsteredgun","",true] _holster=_unit addAction ["Holster sidearm","cly_holster.sqs",nil,2.5,false,true,"","_this==_target and getNumber (configFile/'CfgWeapons'/(currentWeapon _this)/'type')==2 and _this getVariable 'CLY_holsteredgun'==''"] _unholster=_unit addAction ["Unholster sidearm","cly_holster.sqs",nil,2.5,false,true,"","_this==_target and {getNumber (configFile/'CfgWeapons'/_x/'type')==2} count weapons _this==0 and _this getVariable 'CLY_holsteredgun'!=''"] @!alive _unit or _unit!=player {_unit removeAction _x} forEach [_holster,_unholster] ?!alive _unit and _unit getVariable "CLY_holsteredgun"!="":_unit addWeapon _unit getVariable "CLY_holsteredgun";_unit setVariable ["CLY_holsteredgun",nil,true] goto "start" #holster _unit=_this select 0 ?isNil {_unit getVariable "CLY_holsteredgun"}:exit ?_unit getVariable "CLY_holsteredgun"!="":goto "unholster" _gun=currentWeapon player _type=getNumber (configFile/"CfgWeapons"/(currentWeapon player)/"type") ?_type!=2:exit _unit setVariable ["CLY_holsteredgun",_gun,true] _unit removeWeapon _gun _unit addWeapon _gun ~0.5 _unit removeWeapon _gun exit #unholster _gun=_unit getVariable "CLY_holsteredgun" _unit addWeapon _gun _unit selectWeapon _gun _unit setVariable ["CLY_holsteredgun","",true] exit A known issue is that unholstering automatically loads the sidearm with the fullest magazine, but it's an engine limitation with no reasonable workaround. Edited February 26, 2011 by Celery Share this post Link to post Share on other sites
ffur2007slx2_5 11 Posted February 26, 2011 Good, I'll take a try. lol. Share this post Link to post Share on other sites
-DirTyDeeDs--Ziggy- 0 Posted February 26, 2011 thanks for sharing Share this post Link to post Share on other sites
stephen271276 10 Posted February 26, 2011 Cant seem to get it to work? Keeps saying "CLY_holsteredgun" not found? when I try to holster it? sample mission maybe? Share this post Link to post Share on other sites
celery 8 Posted February 26, 2011 Script improved by preventing multiple actions upon team switch and making actions exclusive to their owners. Cant seem to get it to work?Keeps saying "CLY_holsteredgun" not found? when I try to holster it? sample mission maybe? I couldn't reproduce such an error. You only need cly_holster.sqs in the mission folder and [] exec "cly_holster.sqs" in init.sqs/sqf. Share this post Link to post Share on other sites
stephen271276 10 Posted February 26, 2011 got it working I was using it as an sqf file Share this post Link to post Share on other sites
SigintArmA 10 Posted February 26, 2011 Ooo very useful :D Thanks man ^^ Share this post Link to post Share on other sites
f2k sel 164 Posted February 26, 2011 Works fine, The gun did vanish a little to soon so I just increased the the delay a to ~1.5 and it looks fine now. _unit setVariable ["CLY_holsteredgun",_gun,true] _unit removeWeapon _gun _unit addWeapon _gun ~1.5 _unit removeWeapon _gun exit Share this post Link to post Share on other sites
Undeceived 392 Posted August 8, 2011 Thanks for this, Celery! :) Useful as always! :) Share this post Link to post Share on other sites
Undeceived 392 Posted September 1, 2011 Hi Celery, I have a bug to report. When you have the pistol holstered and then go to an ammobox and mess around with other weapons (e.g. take a rifle), all pistol magazines will disappear. This can be "deadly" as you somewhere down the road need the pistol but there are no mags left. Is this possible to fix? Would be great. Btw. the script is well used in the campaign, I'm making atm. :) Share this post Link to post Share on other sites
celery 8 Posted September 2, 2011 Unfortunately that's a feature within the engine where all magazines in your gear that don't have a weapon present will change owners in the next gear transaction. Share this post Link to post Share on other sites
Undeceived 392 Posted November 14, 2011 (edited) Too sad. :) Because even though I always try to remember the pistol mags, I often forget to check them. :) Anyway, a great script, I'm using it quite a lot in my new project. EDIT: Oh, and another question that came up: How can I make the gun being holstered scriptwise, so that I can make it hidden at the beginning of the mission? Edited November 14, 2011 by Undeceived Share this post Link to post Share on other sites
celery 8 Posted November 14, 2011 How can I make the gun being holstered scriptwise, so that I can make it hidden at the beginning of the mission? this setVariable ["CLY_holsteredgun","gunclassname"] Share this post Link to post Share on other sites
Undeceived 392 Posted November 14, 2011 (edited) Hm, doesn't work... I tried to put this in the init.sqf, like: player setVariable ["CLY_holsteredgun","M9"]; The holster script was launched 3 second before. The only thing that happens is that the action to holster the weapon disappears. But the pistol doesn't hide. Can you also teach me how to do it when I don't know which sidearm the player will have (because I want to make a weapon selection in the briefing). Thanks a lot, man! Edited November 14, 2011 by Undeceived Share this post Link to post Share on other sites
celery 8 Posted November 14, 2011 Hm, doesn't work... I tried to put this in the init.sqf, like:player setVariable ["CLY_holsteredgun","M9"]; The holster script was launched 3 second before. The only thing that happens is that the action to holster the weapon disappears. But the pistol doesn't hide. The unit isn't supposed to have that weapon in his gear if you mean it to be already hidden. If you want to choose your pistol first, get the classname of the handgun 0.1 seconds after mission start, set it as the holsteredgun variable and delete the gun it from the player. Share this post Link to post Share on other sites
Undeceived 392 Posted November 14, 2011 Ah, ok, I got it. Thanks, it works. Share this post Link to post Share on other sites