Jump to content
Sign in to follow this  
Wombat241

Detect Secondary Weapons

Recommended Posts

Does anyone know how to tell if someone has a pistol or a law launcher etc out, because I need it for my flashlight v2, which I wont release unless wanted. It'd be great for the help.

Rommel/Wombat. wink_o.gif

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? (unitname hasweapon "weaponclassname") :unitname chat "I've got weapon"

that'll check if a unit named unitname got the weapon you place replace weaponclassname with, and if he got it.

to check if a unit named unit1 got a m16, you write this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? (unit1 hasweapon "m16") : unit1 sidechat "I've got a m16"

Share this post


Link to post
Share on other sites

I knew that, but I wondering if there was a more universal command, anyway, is that for what he is holding of if he just has it, cause I need to if he is holding it. confused_o.gif

Share this post


Link to post
Share on other sites

For secondary weapons try:

Quote[/b] ]secondaryWeapon vehicle

Operand types:

   vehicle: Object

Compatibility:

   Version 1.75 required.

Type of returned value:

   String

Description:

   Returns name of vehicle's secondary weapon (empty string if none).

Example:

   secondaryWeapon player

NB: You can tell what weapons a unit has - but not which one he is holding. This is a real pain.

Also look at:

Quote[/b] ]weapons vehicle

Operand types:

   vehicle: Object

Compatibility:

   Version 1.75 required.

Type of returned value:

   Array

Description:

   Returns array of names of all vehicle's weapons..

Example:

   weapons player

So for eaxmple to check if a unit has no weapons use the condition:

count weapons unitname < 1

To check if a unit has a specific weapon either use hasWeapon as described above by Garcia or you could do something like:

if ("m16" in weapons unitname) then {hint"got an M16"}

Share this post


Link to post
Share on other sites
if ("m16" in weapons unitname) then {hint"got an M16"}

Lets say I want to check if any groupmember in my group named heroes is carrying an m16. The individual soldiers in the group are named h1,h2,h3... et cetera.

Do I need to make the check fo each individual soldier, or can I somehow pass an array of soldier names to be checked. How would the syntax read?

Share this post


Link to post
Share on other sites

something like

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? ({"m16" in weapons _x} foreach (units heroes)): hint "got an M16"

Share this post


Link to post
Share on other sites

I think:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if ({"m16" in weapons _x} count units heroes > 0) then {hint"At least one M16 in the group"}

Or some such

Share this post


Link to post
Share on other sites

Well thanks, I already knew the stuff you posted, I guess trying to find out if he is holding a secondary weapon isnt possible. Even though I somehow did it before.... huh.gifhuh.gif

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  

×