Jump to content
Sign in to follow this  
TCGM

Player Addaction if handgun on inventory? [Solved]

Recommended Posts

Hi guys.
I am trying to add a new option to the mouse wheel menu, but I want it to be activated only if I have any handgun and if I do not have any the option does not shows at all.

Everything works well, but I need it to only works if I have the handgun.

 

This is what i have now: And of course at this moment works with or with out the handgun.

 

player addaction ["<t color='#FF0000'>Shoot as Rich Texan</t>","AirShoot.sqf"];

 

Te script on "AirShoot.sqf" file works great.

 

Please help. Thanks.

 

Share this post


Link to post
Share on other sites
player addAction ["<t color='#FF0000'>Shoot as Rich Texan</t>", "AirShoot.sqf", nil, 1.5, true, true, "", currentWeapon player == handgunWeapon player];

test that? 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Tested ... This is the error that appeared.
 

'...ns\ShootAsRichTexan.VR\init.sqf"
Player |#|addAction ["<t color='#FF0000'>Shoot as ...'
Error Type Bool, Espected String
File X:\XXXX\missions\ShootAsRichTexan.VR\init.sqf,
line 1

Where init.sqf is the file with the addAction code that you sent me. Thank you. Next test?

 

Share this post


Link to post
Share on other sites
30 minutes ago, TCGM said:

Tested ... This is the error that appeared.
 


'...ns\ShootAsRichTexan.VR\init.sqf"
Player |#|addAction ["<t color='#FF0000'>Shoot as ...'
Error Type Bool, Espected String
File X:\XXXX\missions\ShootAsRichTexan.VR\init.sqf,
line 1

Where init.sqf is the file with the addAction code that you sent me. Thank you. Next test?

 

 

@Spatsiba forgot the quotation marks.

This should do the trick:

 

//only show if current weapon is the handgun
//downside: will also show if no weapon equipped and no weapon in handgun slot and also if player is inside a vehicle
player addAction ["<t color='#FF0000'>Shoot as Rich Texan</t>", "AirShoot.sqf", nil, 1.5, true, true, "", "currentWeapon _target isEqualTo handgunWeapon _target"];

//only show if on foot and the current weapon is handgun and the player isn't unarmed
player addAction ["<t color='#FF0000'>Shoot as Rich Texan</t>", "AirShoot.sqf", nil, 1.5, true, true, "", "objectParent _target isEqualTo objNull AND currentWeapon _target isEqualTo handgunWeapon _target AND handgunWeapon _target !=''"];

Might want to use the second example if you want to play an animation (just guessing), so players won't be able to play animations inside vehicles (FFV slots).

 

Cheers

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Yes, the script executes an animation. Well guessed.
Your script works perfectly, but only when the weapon is in my hand, since the animation starts with the sheathed weapon, could you help me activate the menu with the sheathed weapon?
Thanks.
 

Share this post


Link to post
Share on other sites

It would be perfect if the menu option could be activated only if the player is not in a vehicle and has a handgun but does not have it in his hand. Can have a rifle as current weapon because I can add a transition animation so he hang the rifle on his shoulder before my animation starts.
Thanks again.

Share this post


Link to post
Share on other sites

@Grumpy Old Man:
I think I already solved it ... I used the second code that you sent me and I simply removed a part. It seems that everything works exactly as I need it ... Thank you very much.
 

player addAction ["<t color='#FF0000'>Shoot as Rich Texan</t>", "AirShoot.sqf", nil, 1.5, true, true, "", "objectParent _target isEqualTo objNull AND handgunWeapon _target !=''"];

 

  • Like 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
Sign in to follow this  

×