Home   Help Search Login Register  

Author Topic: detect if player has weapon or not?  (Read 2513 times)

0 Members and 1 Guest are viewing this topic.

Offline D_P_

  • Members
  • *
  • YAY! I'm a lama again! ...oh wait.
    • ArmaAddons
detect if player has weapon or not?
« on: 20 Sep 2007, 02:55:03 »
I need to find out if the player in my mission is carrying a gun or not when he activates a script....to get the animation/sounds to sync. Anyone know how I'd do this? thx
just setpos & forgetpos!

Offline LeeHunt

  • Former Staff
  • ****
  • John 21:25
Re: detect if player has weapon or not?
« Reply #1 on: 20 Sep 2007, 02:58:33 »
This may help, however I believe it only detects a certain type of weapon.  So you might have to repeat the code ? (player hasWeapon "M16") : goto "ready" multiple times for each type of weapon the player picks up. There may be a better solution out there using primaryweapon but i know this will work (have used it myself) if you keep repeating the code for different weapon types...

http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=h#hasWeapon

unit hasWeapon weaponName
Operand types:
unit: Object
weaponName: String

Type of returned value:
Boolean
Description:
Check if unit has given weapon.
Used In:
ArmA/OFP
Example:
? (player hasWeapon "M16") : goto "ready"

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: detect if player has weapon or not?
« Reply #2 on: 20 Sep 2007, 10:05:24 »
cud use da primaryweapon command :D

now unless he has a handgund and he is usin it it wud work 4 u :D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: detect if player has weapon or not?
« Reply #3 on: 20 Sep 2007, 14:09:07 »
Do you mean if the player has a particular weapon in the hands? or just of the player has a particular weapon in his inventory?

Offline D_P_

  • Members
  • *
  • YAY! I'm a lama again! ...oh wait.
    • ArmaAddons
Re: detect if player has weapon or not?
« Reply #4 on: 21 Sep 2007, 02:33:03 »
Thanks for the speedy replies :D

I will try the above and see if it does the trick.

@Mandoble: I mean in his hand and/or inventory.

He starts with no weapons...then after completing a few objectives...finds a weapon. I have some cut scenes where he can stop and examine objects...the animations/sounds in the cutscenes are timed perfectly...provided he has no weapons in his hands. When he does have a weapon, he first has to holster the weapon and then perform the animation...this delay makes all the actions in the cutscene off cue =(

Anyway - I'll try the above advice and hopefully can get this mission moving along.
Thanks
just setpos & forgetpos!

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: detect if player has weapon or not?
« Reply #5 on: 21 Sep 2007, 13:32:52 »
weapons should give you an array of all a vehicles weapons.

_wArray = weapons player

If the array is empty he has no weapons I suppose, although I imagine binoculars or nvg's might count as weapons too.


Planck
I know a little about a lot, and a lot about a little.

Offline D_P_

  • Members
  • *
  • YAY! I'm a lama again! ...oh wait.
    • ArmaAddons
Re: detect if player has weapon or not?
« Reply #6 on: 26 Sep 2007, 02:39:28 »
Code: [Select]
? (player hasWeapon "M16") : goto "ready"
Works perfectly.  :)

just setpos & forgetpos!