OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: ZapBrannigan on 16 Oct 2007, 03:01:57
-
hey,
I need to detect if the player has a weapon, I see this command hasweapon, but that seems to only check for certain weapons, How can I detect in a trigger if the player has any weapon?
thanks
-
(count (weapons player))
The problem is though that binoculars and nvgoggles are weapons as well so that will return 1 even if the unit has no firearms at all, just binocs or nvgoggles in it's inventory..
-
try
?canFire player: ...
-
dosent work, it activates even if I dont have a weapon. thanks
-
How about that count thing I suggested?
You can bypass the binoc nvg problem by using this in the trigger's condition field
(count (weapons player - ["NVGoggles","Binocular"]))<1
-
What about laser designators, the telephone, normal and/or smoke grenades (though how do people know what type of grenade you have in your pocket at 100m?) or non-BIS items? You could just remove all the non-deadly weapons you know about or use SPON_getWeaponType (http://www.ofpec.com/forum/index.php?topic=30473.0) which is a more generic, though still imperfect, solution (doesn't account for smoke grenades):
_hasDeadlyWeapon = { ([_x] call SPON_getWeaponType) in ["PISTOL", "RIFLE", "LAUNCHER", "GRENADE", "PUT"] } count (weapons player)) > 0;
-
Not sure if mandoble's my weapon (http://www.ofpec.com/ed_depot/index.php?action=details&id=435&game=ArmA&type=fu&cat=we) returns 'nothing' when the player has no weapon. If it does, you can check for that condition.
You'll have to check if it returns 'nothing' , 'null' etc.
-
well I dont have to worry about NVG or binocs because the only weapon the player can get is a rifle and ammo.
so how would I use (count (weapons player))?
?(count (weapons player))> 1: t1 = true
and then I can use
? t1: do whatever i want
will this work?
thanks
-
Well, weapons gives an array of all weapons that the person is carrying and count tells you how many items are in the array. In your case, you only need the array to contain something for the person to be armed.
? (count (weapons player)) > 0 ? do stuff
-
works great, thanks guys