Jump to content
thetrooper

hasweapon simple syntax problem

Recommended Posts

hi all.

I'm simply trying to have a condition if a player has either 1 or two of the weapons. Not sure what it should be.

player hasweapon "arifle_MX_ACO_F" OR  "srifle_EBR_SOS_F";

I'm stuck. Any ideas?

Share this post


Link to post
Share on other sites

try

(player hasweapon "arifle_MX_ACO_F" OR player hasweapon "srifle_EBR_SOS_F")

Share this post


Link to post
Share on other sites

Even more options....

({player hasWeapon _x}count ["arifle_MX_ACO_F", "srifle_EBR_SOS_F"] > 0);

(primaryWeapon player) in ["arifle_MX_ACO_F", "srifle_EBR_SOS_F"]

Share this post


Link to post
Share on other sites

Ive tried all of the above in a trigger condition with no luck, ive also tried "Weapon_srifle_GM6_F" in weapons player but nothing seems to work, ive tried a few others from other threads but get the feeling it maybe broken, im on 1.56 stable.

 

Is there anything else i can try in a trigger condition to detect if player has a specific weapon?

Share this post


Link to post
Share on other sites

Ive tried all of the above in a trigger condition with no luck, ive also tried "Weapon_srifle_GM6_F" in weapons player but nothing seems to work, ive tried a few others from other threads but get the feeling it maybe broken, im on 1.56 stable.

 

Is there anything else i can try in a trigger condition to detect if player has a specific weapon?

Wrong class. Try:

"srifle_GM6_F" in weapons player

Share this post


Link to post
Share on other sites

 

Wrong class. Try:

"srifle_GM6_F" in weapons player

 

Jeesuz! thanks Greenfist, that was driving me nuts... i got that from the config viewer, even tried other weapons but i guess they arent the actual classnames

Share this post


Link to post
Share on other sites

Jeesuz! thanks Greenfist, that was driving me nuts... i got that from the config viewer, even tried other weapons but i guess they arent the actual classnames

The "Weapon_srifle_GM6_F" is the object name from CfgVehicles, not the actual weapon from CfgWeapons.

 

You could have just equipped it and typed "weapons player" in the console's watch field. ;)

Share this post


Link to post
Share on other sites

The "Weapon_srifle_GM6_F" is the object name from CfgVehicles, not the actual weapon from CfgWeapons.

 

You could have just equipped it and typed "weapons player" in the console's watch field. ;)

Ahh nice, ive only just started using the console lol, thanks for the pro tip!

Share this post


Link to post
Share on other sites

If player has, for example, "srifle_GM6_LRPS_F" your check against "srifle_GM6_F" will fail. Better way is to use isKindOf to check whether some of (weapons player) has common ancestor class in its parents list:

scopeName "yourScope";
private _hasGM6 = false;
{
	private _weap = _x select 0;
	if (_weap isKindOf ["srifle_GM6_F", configFile >> "CfgWeapons"]) then {
		_hasGM6 = true;
		breakTo "yourScope";
	};
} forEach (weapons player);

Share this post


Link to post
Share on other sites

For this scenario i am placing the specific weapon down that the player is expected to pick up to complete task but thats a useful tip thanks.

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

×