Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Check Units Weapon

Hybrid View

  1. #1
    Master Gunnery Sergeant
    Join Date
    Dec 13 2003
    Location
    Melbourne, Australia
    Posts
    1,362

    Red face

    Problem: I wanted a script to check that the player had a M4. How do I do this?

    Australian Armed Forces - Dedicated Tactical Coop Squad for ArmA2

  2. #2
    Master Gunnery Sergeant
    Join Date
    Jul 15 2003
    Location
    Belgium, the land of surialism
    Posts
    1,003
    Use the HasWeapon or the Weapons command.

    If you are talking about the weapon in hand... you can't

  3. #3
    First Sergeant Buliwyf's Avatar
    Join Date
    Jan 1 2004
    Location
    Hamburg / Germany
    Posts
    823
    Oh... thats not wright...

    He can also work with pirmaryWeapon and secondaryWeapon.


  4. #4
    Master Gunnery Sergeant
    Join Date
    Dec 13 2003
    Location
    Melbourne, Australia
    Posts
    1,362
    Author of the Thread
    Um anyone got some code for PW and SW (primary weapon and secondary weapon)

    All I want to know is how can I check if a guy has this weapon: M4.

  5. #5
    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit hasWeapon &#34;M4&#34;[/QUOTE]

    From comref:
    Quote Originally Posted by [b
    Quote[/b] ]unit hasWeapon weaponName
    Operand types:
    *** ***unit: Object
    *** ***weaponName: String
    Type of returned value:
    *** ***Boolean
    Description:
    *** ***Check if unit has given weapon.

    Example:
    *** ***player hasWeapon "M16"

  6. #6
    Master Gunnery Sergeant
    Join Date
    Dec 13 2003
    Location
    Melbourne, Australia
    Posts
    1,362
    Author of the Thread
    Didnt work, or maybe I didnt use it right, anyone able to show me?








  7. #7
    You must use that syntax within a condition statement. Can you supply your script/trigger settings/ etc.. where you are intending to use this? It would be easier if we knew what you were doing....

    EDIT:Also, the "M4" refers to the standard BIS M4... you are not using any add-on M4&#39;s are you?




  8. #8
    Master Gunnery Sergeant
    Join Date
    Dec 13 2003
    Location
    Melbourne, Australia
    Posts
    1,362
    Author of the Thread
    Could this work?

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
    _weapon = weapons Rommel

    ?&#40; _weapon == &#34;M4&#34;&#41;&#58; exit
    [/QUOTE]

    EDIT: This is the error message: "error ==: Type Array, expected Number,String,Object,Side,Group"

    For your Info:
    Rommel = Me
    M4 = STANDARD BIS M4


    Just Random Code - How to find out your weapon name and magazine. Quite handy if your OFP cant alt tab or the addon that your using doesnt tell you what the weapon names are in the readme or something (and or your to lazy to un-pbo the addon and read the config or you can but have no idea how to read a config).
    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
    hint format&#91;&#34;weapons&#58; %1, magazines&#58; %2&#34;,weapons this,magazines this&#93;
    exit
    [/QUOTE]

    This displays your weapon and what magazines you have.
    Its quite handy

    @Crashdome
    I used this:
    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
    ?&#40;player hasWeapon &#34;M16&#34;&#41;&#58; hint &#34;You have an M16&#34;; exit
    [/QUOTE]




  9. #9
    Master Gunnery Sergeant
    Join Date
    Dec 13 2003
    Location
    Melbourne, Australia
    Posts
    1,362
    Author of the Thread
    Nevermind I got the hasweapon thing to work.
    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
    ?&#40;_this hasweapon &#34;M4&#34;&#41;&#58; hint &#34;You have a M4&#33; How interesting&#33;&#34;; exit

    exit
    [/QUOTE]

  10. #10
    Master Gunnery Sergeant 5133p39's Avatar
    Join Date
    Feb 2 2004
    Location
    Czech Republic
    Posts
    1,383
    the command //Weapons// returns an array, so you must do something like this:

    ? "M4" In Weapons Rommel : exit
    MSI P55-GD65 | Core i5 750 @ 2.67GHz | 4GB DDR3 | ATI HD 5970 (Asus EAH5970​/G​/2DIS​/2GD5) | OCZ Revo 120GB PCIe SSD | 2x OCZ Vertex 4 120GB |
    Windows 7 64bit Home Premium | Catalysts 13.1 | ArmA2 OA 1.62.0.101480 (beta) +BAF +PMC +ACR | ArmA2 1.11.0.86734 | ArmA 1.18.0.5281 | OFP 1.0.0.96

    Be smart, use Sprocket!

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •