Jump to content
Sign in to follow this  
Undeceived

How to check if units is unarmed, EVEN if he has a gun in his backpack?

Recommended Posts

Hi guys. :)

I have this condition here, which is fulfilled, when the player has a weapon:

({getNumber (configFile/"CfgWeapons"/_x/"type") in [1,2,4,5]} count weapons player != 0 )

Unfortunately this will also be fulfilled if a weapon is in the player's backpack... This is what I want to prevent.

So, how can I change this condition, so that it only fires, when the player has a weapon in his main weapon slots (namely: in his hands)? Hidden weapons in a backpack should be allowed.

Thanks a lot for your time and help!

Share this post


Link to post
Share on other sites

Good ideas, but when I use this code...

({getNumber (configFile/"CfgWeapons"/_x/"type") in [1,2,4,5]} count primaryWeapon player != 0 )

...I get the error:

count: Type String, expected Array

EDIT:

I'm sorry to bother you, guys. This condition I used is from Arma 2 times where items, binoculars and NVGoggles were considered as weapons by the engine (if I remember correctly). Your suggestions work perfectly.

A trigger with the following condition will fire, if the player carries a weapon in his hands (rifle, launcher or sidearm):

(primaryweapon player != "") OR (secondaryWeapon player != "") OR (handgunWeapon player != "")

A trigger with the following condition will fire, if the player has no weapon in his hands (weapons in the backpack are allowed though):

(primaryweapon player == "") AND (secondaryWeapon player == "") AND (handgunWeapon player == "")

Edited by Undeceived

Share this post


Link to post
Share on other sites

({getNumber (configFile/"CfgWeapons"/_x/"type") in [1,2,4,5]} count [primaryWeapon player, secondaryWeapon player, handgunWeapon player] != 0 )

although I don't get the first part. Why isn't

{_x != ""} count [primaryWeapon player, secondaryWeapon player, handgunWeapon player] == 0

enough?

Edited by zapat

Share this post


Link to post
Share on other sites

Thanks a lot, zapat. That one works too (see my edited previous post).

I don't remember the author of that condition - can anyone tell me what exactly it checks? What are these 1,2,4,5 for? :)

EDIT: I think it comes from Arma 2 times where items, binoculars and NVGoggles were still considered as weapons by the engine, but I'm not sure.

Edited by Undeceived

Share this post


Link to post
Share on other sites

Hi,

For the trigger with the following condition will fire, if the player has no weapon in his hands (weapons in the backpack are allowed though):

You can do :

// Replace :
(primaryweapon player == "") AND (secondaryWeapon player == "") AND (handgunWeapon player == "")

// By :

currentWeapon player == "";

Share this post


Link to post
Share on other sites

As far as I can tell, that makes sense. :)

EDIT:

It doesn't work reliably though. If you have a rifle, a pistol and a launcher and then remove the rifle and pistol (or put them in the backpack), the player will stay with the launcher on his back, which means that he has NO current weapon. The result is that the trigger thinks that he's unarmed even though he has the launcher on him.

This one from zapat (adjusted a little bit) works fine:

({getNumber (configFile/"CfgWeapons"/_x/"type") in [1,2,4,5]} count [primaryWeapon player, secondaryWeapon player, handgunWeapon player] == 0 )

Edited by Undeceived

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  

×