Jump to content
Sign in to follow this  
CaptainBravo

Expert advice needed on how to Detect weapon only if in hand

Recommended Posts

Anyone know how to detect weapon in group if they have in hand? So group will be set captive true as long as they have weapon on back but will be set to false as soon as they have it in hand.

I have found a similar one with fire eventhandler but not the same.

Any help would be highly appreciated. :confused:

Share this post


Link to post
Share on other sites

if you use a weapon on back script, why not just remove all the weapons and readd them when they "take the weapons from the back".

then you can check for if count weapons unit == 0 then setcaptive true.

Share this post


Link to post
Share on other sites
if you use a weapon on back script, why not just remove all the weapons and readd them when they "take the weapons from the back".

then you can check for if count weapons unit == 0 then setcaptive true.

Thanks Demonized. I am not using any script as group will be human players who will put weapon on back (via inventory) before entering town. So I am not sure how to script weapon on back script.

Share this post


Link to post
Share on other sites

Why not just check their currentMuzzle? That'll tell you the weapon, or weapon mode, they are on or whatever item (bionc, grenade, whatever) they have active. Unarmed will respond with an empty string.

Or maybe check what animation state they are in, if it's a Rfl one they have a rifle? Not sure how reliable or whatever that is though, but currentWeapon/currentMuzzle should work.

Edited by kylania

Share this post


Link to post
Share on other sites
Why not just check their currentMuzzle? That'll tell you the weapon, or weapon mode, they are on or whatever item (bionc, grenade, whatever) they have active. Unarmed will respond with an empty string.

Or maybe check what animation state they are in, if it's a Rfl one they have a rifle? Not sure how reliable or whatever that is though, but currentWeapon/currentMuzzle should work.

I think both could be a good option. Although I am not sure hoq as I am not a scripter by any imagination :o

Share this post


Link to post
Share on other sites

Put this in an sqf and run it before you need to start detecting:


if (isDedicated) exitWith {};

_unit = _this select 0;

while {currentWeapon _unit == "Throw"} do
{
sleep 1;
};

hint "watch out lads.  He's pulled a shooter";
_unit setCaptive false;

You could run it with something like:

0 = [unit1,unit2] execVM "nameofscript.sqf";

Def works for SP, but untested for MP (should be okay though)

Share this post


Link to post
Share on other sites
Put this in an sqf and run it before you need to start detecting:


if (isDedicated) exitWith {};

_unit = _this select 0;

while {currentWeapon _unit == "Throw"} do
{
sleep 1;
};

hint "watch out lads.  He's pulled a shooter";
_unit setCaptive false;

You could run it with something like:

0 = [unit1,unit2] execVM "nameofscript.sqf";

Def works for SP, but untested for MP (should be okay though)

Thanks Das Attorney for the script. After testing it seems to only work if you go into area with weapons in hand. You will be detected and fired upon. HOwever, if you go with weapon on back then switch to wepon in hand, the script will not detect you. How do you get the other side to detect you as soon as you get your weapon in hand?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×