Jump to content
juleshuxley

Checking if a weapon is ready to fire

Recommended Posts

I'm trying to make a minimalist UI. I've had some success but one thing I'm struggling with is recreating the "waiting for the next round" bar. You know, this thing:

barrrrr.png

My UI is constantly getting refreshed in a while loop, so I was hoping I could query if a certain weapon was ready to fire. Functions such as CanFire and WeaponState unfortunately didn't give me what I wanted and are misleadingly named.

So is there a function I've missed that  can query the weapon state i.e ready to fire, not ready to fire?

Failing that, where is the m256's "time taken for next round to be loaded" set? In a config? What attribute am I looking for? Can I use getText to extract it to a variable in my script? If it's listed in seconds somewhere in the config I could use an event handler and BIS_fnc_deltaTime to work out if a weapon is ready to fire or not.

Share this post


Link to post
Share on other sites
7 hours ago, juleshuxley said:

Failing that, where is the m256's "time taken for next round to be loaded" set? In a config?

Yes in config of weapon reloadTime.

  • Like 1

Share this post


Link to post
Share on other sites
_name = getText(configfile >> "CfgWeapons" >> "CUP_optic_LeupoldMk4_20x40_LRT" >> "displayName");

_reloadTime = getText(configfile >> "CfgWeapons" >> "CUP_optic_LeupoldMk4_20x40_LRT" >> "reloadTime");

_name; // "Leupold Mark 4 6.5-20x50mm LR/T"
_reloadTime; // ""

Attempting to retrieve reloadTime results in an empty string?

reload.png

reloadTime is most definitely in the config, unless the indentation or colors mean something?

Update,  just realised displayName is red and unindented I'm guessing that's something to do with it...

Share this post


Link to post
Share on other sites
23 hours ago, juleshuxley said:

Attempting to retrieve reloadTime results in an empty string?

As it is not a string, its a number, so use getNumber instead.

 

23 hours ago, juleshuxley said:

unless the indentation or colors mean something?

Indentation means the member is inherited from its parent, not indented means set in this class. Colors are member type, text, number or array.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
On 10/31/2020 at 4:46 PM, pierremgi said:

already answered in another post. Don't duplicate please.

Which other thread?  Please show me the way.  I'm looking for an answer to this question myself, and so far google has only led to this thread where you're telling them to stop talking about the issue.  So unhelpful.

  • Confused 1

Share this post


Link to post
Share on other sites
1 hour ago, flyingsaucerinvasion said:

Which other thread? 

 

They're talking about the meaning of text color in the config viewer, and referencing a topic about that subject from the same date. He's not telling anyone to "stop talking about the issue."

 

Quote

Please show me the way. 

 

The answer to the original question appears to be available above. 

  • Like 2

Share this post


Link to post
Share on other sites

BTW

https://community.bistudio.com/wiki/weaponState

was enhanced in this regard:

 

Quote

2.06 roundReloadPhase: Number - current ammo round reload phase (see weaponReloadingTime)

2.06 magazineReloadPhase: Number - current magazine reload phase from 1 to 0, 0 - reload complete. > 0 - reload in progress

 

  • Like 3
  • Thanks 1

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

×