Jump to content
Ilias38rus

How to get the weapon muzzleName?

Recommended Posts

/*

lua = _x;

selectWeapon (handgunweapon lua);

or

selectWeapon str (handgunweapon lua);

or

lua = handgunweapon _x;

selectWeapon (lua);

or

lua = handgunweapon _x;

selectWeapon str (lua);

 

Do not working, why?

*/

 

How to get the weapon muzzleName?

Share this post


Link to post
Share on other sites

The one thing that I immediately notice is that you aren't specifying a unit for selectWeapon. The syntax for selectWeapon is

unitName selectWeapon muzzleName;

So you should be able to do something like

{ 
    _sidearm = handgunWeapon _x;
    _x selectWeapon _sidearm;
} forEach units group player;

Additionally, you do not need to use the str command as handgunWeapon already returns a string.

Share this post


Link to post
Share on other sites

The one thing that I immediately notice is that you aren't specifying a unit for selectWeapon. The syntax for selectWeapon is

unitName selectWeapon muzzleName;

So you should be able to do something like

{ 
    _sidearm = handgunWeapon _x;
    _x selectWeapon _sidearm;
} forEach units group player;

Additionally, you do not need to use the str command as handgunWeapon already returns a string.

Sorry, forgot to insert, it looks:

 

lua = primaryweapon _x;

_x addaction ["Select weapon",{(_this select 0) selectWeapon lua;},"_x"];

 

and do not working, i need muzzle name,

found:

 

class arifle_MX_GL_F : arifle_MX_Base_F {

     muzzles[] = {this, GL_3GL_F};

 

but dont know how to get this mussle

 

lua = primaryweapon _x;// >> muzzles[] select 0 //?

Share this post


Link to post
Share on other sites

EDIT: never mind, note to self must remember to refresh old pages before posting :)

  • Like 2

Share this post


Link to post
Share on other sites

Try this:

_muzzles = getArray (configFile >> "CfgWeapons" >> (primaryWeapon _x) >> "muzzles")

 

laia = [];
lia1 = 0;
laia = getArray (configFile >> "CfgWeapons" >> (primaryweapon _x) >> "muzzles");
lia1 = laia select 0;
_x addaction ["Select weapon",{(_this select 0) selectWeapon lia1;},"_x"];

 

Nope,

 

selectWeapon |#|lia1

undefined variabdle

 

or

 

laia = [];
lia1 = 0;
laia = getArray (configFile >> "CfgWeapons" >> (primaryweapon _x) >> "muzzles");
lia1 = laia select 0;
_x addaction ["Select weapon",{(_this select 0) selectWeapon str (lia1);},"_x"];

 

Nope,

 

selectWeapon str (|#|lia1)

undefined variabdle

Share this post


Link to post
Share on other sites
{
    _weapon = _x;
    _muzzles = getArray( configFile >> "CfgWeapons" >> _weapon >> "muzzles" );
    {
        _muzzle = _x;
        _muzzleSelect = _x;
        if ( _muzzleSelect isEqualTo "this" ) then {
            _muzzleSelect = _weapon;
        };
        player addAction [ format[ "Use %1 - %2", _weapon, _muzzle ], format[ "player selectWeapon %1", str _muzzleSelect ] ];
    }forEach _muzzles;
}forEach [
    primaryWeapon player,
    secondaryWeapon player,
    handgunWeapon    player
];

Share this post


Link to post
Share on other sites

 

laia = [];
lia1 = 0;
laia = getArray (configFile >> "CfgWeapons" >> (primaryweapon _x) >> "muzzles");
lia1 = laia select 0;
_x addaction ["Select weapon",{(_this select 0) selectWeapon lia1;},"_x"];

 

Nope,

 

selectWeapon |#|lia1

undefined variabdle

 

or

 

laia = [];
lia1 = 0;
laia = getArray (configFile >> "CfgWeapons" >> (primaryweapon _x) >> "muzzles");
lia1 = laia select 0;
_x addaction ["Select weapon",{(_this select 0) selectWeapon str (lia1);},"_x"];

 

Nope,

 

selectWeapon str (|#|lia1)

undefined variabdle

 

 

on a sidenote, you might wanna think a bit about naming your variables (and your thread titles) since it's confusing as hell to read.

 

Cheers

Share this post


Link to post
Share on other sites

on a sidenote, you might wanna think a bit about naming your variables (and your thread titles) since it's confusing as hell to read.

 

Cheers

 

With the system i using, i can at anytime, in any skript write needeble variable without any help, notes (in the mission currently like ~80 global variables)

Share this post


Link to post
Share on other sites
{
    _weapon = _x;
    _muzzles = getArray( configFile >> "CfgWeapons" >> _weapon >> "muzzles" );
    {
        _muzzle = _x;
        _muzzleSelect = _x;
        if ( _muzzleSelect isEqualTo "this" ) then {
            _muzzleSelect = _weapon;
        };
        player addAction [ format[ "Use %1 - %2", _weapon, _muzzle ], format[ "player selectWeapon %1", str _muzzleSelect ] ];
    }forEach _muzzles;
}forEach [
    primaryWeapon player,
    secondaryWeapon player,
    handgunWeapon    player
];

Is that nessesary?

    {
        _muzzle = _x;
        _muzzleSelect = _x;
        if ( _muzzleSelect isEqualTo "this" ) then {
            _muzzleSelect = _weapon;
        };
        player addAction [ format[ "Use %1 - %2", _weapon, _muzzle ], format[ "player selectWeapon %1", str _muzzleSelect ] ];
    }forEach _muzzles;

Share this post


Link to post
Share on other sites
_x addaction ["Select grenade launcher",{(_this select 0) selectWeapon "GL_3GL_F";},"_x"];

is working, but any with str (this) not and i need exactly str (this)

 

Actualy _this selectweapon "hgun_pd7_f"; right in object init do not working at all, i starting be a little scared

Share this post


Link to post
Share on other sites

How to get the weapon muzzleName?

_muzzleSlotItem = (primaryWeaponItems _unit) select 0;

str _muzzleSlotItem;

 

Return muzzle classname ""muzzle_mas_snds_M""

 

What are you want to create?

Share this post


Link to post
Share on other sites

_muzzleSlotItem = (primaryWeaponItems _unit) select 0;

 

What are you want to create?

Nope, sorry do not working

Need command for Ai to change ugl on primarywapon

Share this post


Link to post
Share on other sites

Nope, sorry do not working

Need command for Ai to change ugl on primarywapon

 

Why didn't you ask this in the first place?

  • Like 1

Share this post


Link to post
Share on other sites

by Schatten :

//Adding muzzle
        {
            _unit = _x;

            if (alive _unit) then {
                _primaryWeapon = primaryWeapon _unit;

                if ((_primaryWeapon != '') and {((primaryWeaponItems _unit) select 0) == ''}) then {
                    _muzzleSlotItem = '';

                    _compatibleMuzzleSlotItems = getArray (configFile >> 'CfgWeapons' >> _primaryWeapon >> 'WeaponSlotsInfo' >> 'MuzzleSlot' >> 'compatibleItems');

                    {
                        _item = _x;

                        {if (_x == _item) exitWith {_muzzleSlotItem = _x}} forEach _compatibleMuzzleSlotItems;

                        if (_muzzleSlotItem != '') exitWith {};
                    }
                    forEach (items _unit);

                    if (_muzzleSlotItem != '') then {
                        _unit removeItem _muzzleSlotItem;

                        _unit addPrimaryWeaponItem _muzzleSlotItem;
                    };
                };
            };
        }
        forEach (units (group player));

        
//removing muzzle

        {
            _muzzleSlotItem = (primaryWeaponItems _x) select 0;

            if (_muzzleSlotItem != '') then {
                _x removePrimaryWeaponItem _muzzleSlotItem;

                _x addItem _muzzleSlotItem;
            };
        }
        forEach (units (group player));

Share this post


Link to post
Share on other sites

 

by Schatten :

//Adding muzzle
        {
            _unit = _x;

            if (alive _unit) then {
                _primaryWeapon = primaryWeapon _unit;

                if ((_primaryWeapon != '') and {((primaryWeaponItems _unit) select 0) == ''}) then {
                    _muzzleSlotItem = '';

                    _compatibleMuzzleSlotItems = getArray (configFile >> 'CfgWeapons' >> _primaryWeapon >> 'WeaponSlotsInfo' >> 'MuzzleSlot' >> 'compatibleItems');

                    {
                        _item = _x;

                        {if (_x == _item) exitWith {_muzzleSlotItem = _x}} forEach _compatibleMuzzleSlotItems;

                        if (_muzzleSlotItem != '') exitWith {};
                    }
                    forEach (items _unit);

                    if (_muzzleSlotItem != '') then {
                        _unit removeItem _muzzleSlotItem;

                        _unit addPrimaryWeaponItem _muzzleSlotItem;
                    };
                };
            };
        }
        forEach (units (group player));

        
//removing muzzle

        {
            _muzzleSlotItem = (primaryWeaponItems _x) select 0;

            if (_muzzleSlotItem != '') then {
                _x removePrimaryWeaponItem _muzzleSlotItem;

                _x addItem _muzzleSlotItem;
            };
        }
        forEach (units (group player));

Do not working

Share this post


Link to post
Share on other sites

Please, for the sake of us being able to help you, provide a bit more information than "do not working". What exactly is not working? Do you get a script error? Does nothing happen? Is something not happening as it's supposed to or as you want it?

 

You can't expect us to help you if you provide as little information as possible.

  • Like 2

Share this post


Link to post
Share on other sites

{

if !( isPlayer _x ) then {

_unit = _x;

{

if ( getText( configFile >> "CfgWeapons" >> primaryWeapon _unit >> _x >> "cursorAim" ) isEqualTo "gl" ) then {

_muzzle = configName( configFile >> "CfgWeapons" >> primaryWeapon _unit >> _x );

_unit addAction [ "Select UGL", {

_unit = _this select 0;

_unit selectWeapon ( _this select 3 select 0 );

}, [ _muzzle ]];

};

}forEach ( getArray( configFile >> "CfgWeapons" >> primaryWeapon _unit >> "muzzles" ) - [ "this" ] );

};

}forEach units group player;

Share this post


Link to post
Share on other sites

If i'm getting precise script error, i'm fixing it, if i'm getting script error, but do not understanding it i'm writing the error, if i'm getting some wrong working, i'm writing what wrong, if is nothing working (nothing happening), i have nothing to write, is it difficult?

  • Sad 1

Share this post


Link to post
Share on other sites

Just please all i need is command to get thing (what i can use for selectwepon for change ai weapon from ugl on rifle) this is all, i do not need all the

{
    if !( isPlayer _x ) then {
        _unit = _x;

        {

    };

                _unit addAction [ "Select UGL", {
                    _unit = _this select 0;
                    _unit selectWeapon ( _this select 3 select 0 );
                }, [ _muzzle ]];
}forEach units group player;

Share this post


Link to post
Share on other sites

There is no such thing as switch to ugl. It is all based off of the weapons muzzles and can be different based on what weapon a unit is carrying.

It is not like a rifle or handgun where there is a dedicated command for it like primaryweapon _unit etc, it is not its own weapon but instead is a secondary muzzle of the primary weapon, as such you need to query the config for the primaryweapon to find the muzzle name.

So yes you need all the ^. If you are unwilling to learn from the help given then im out. Maybe someone else knows the magic command you are looking for. Good luck.

Share this post


Link to post
Share on other sites

There is no such thing as switch to ugl. It is all based off of the weapons muzzles and can be different based on what weapon a unit is carrying.

It is not like a rifle or handgun where there is a dedicated command for it like primaryweapon _unit etc, it is not its own weapon but instead is a secondary muzzle of the primary weapon, as such you need to query the config for the primaryweapon to find the muzzle name.

So yes you need all the ^. If you are unwilling to learn from the help given then im out. Maybe someone else knows the magic command you are looking for. Good luck.

i not need to swith to ugl, i need from and }forEach units group player; i don't need for sure , i have all i need to identificate weapon, just imagine what it's with ugl, ai selected ugl, and tell how to order unit to switch back to riffle, please

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

×