OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Goullou on 01 Apr 2008, 18:54:13

Title: How to get the muzzle of the current selected weapon?
Post by: Goullou on 01 Apr 2008, 18:54:13
Hi all,

I would like to get the related string of the main muzzle name of the current select weapon.
ex: M16A4_ACG_GL  ----> M16Muzzle

I'd like to do something like this:
Code: [Select]
_weap = primaryWeapon _unit;
_muz = getText (configFile >> "Cfgweapons" >> ...........................);// need help here for a correct syntax

I don't know the right syntax for getText.
May be i'm on the bad way...
Thx for any help.
Title: Re: How to get the muzzle of the current selected weapon?
Post by: Goullou on 01 Apr 2008, 21:34:25
Ok, i'm back 'cause i found something.  :cool2:
I must tell you i was trying to fix a bug happening when respawning with a preset of weapons & ammos, with weapons having 2 muzzles. The player respawn with the 2nd muzzle always selected...  >:(

Code: [Select]
_Pweap = primaryWeapon _unit;
if (_Pweap != "") then
{
_allMuzzles = getArray (configFile >> "cfgWeapons" >> _Pweap >> "muzzles");
if ((_allMuzzles select 0) != "this") then
{
_unit selectWeapon (_allMuzzles select 0);
}
else
{
_unit selectWeapon _Pweap;
};
};

This is a working method ... May be there's better ...
Title: Re: How to get the muzzle of the current selected weapon?
Post by: h- on 01 Apr 2008, 22:06:13
Quote
Ok, i'm back 'cause i found something.
Still, do not post consecutively.
If you have something to add after a short period of time modify your post instead of replying to yourself...  :good:
Title: Re: How to get the muzzle of the current selected weapon?
Post by: johnnyboy on 17 Dec 2008, 19:22:51
I would like the answer to this post's title.  Note that the poster's resolution was to force a muzzle selection, not actually detect the muzzle of the current selected weapon...

I need to know the current muzzle selected by the player.  Specifically whether they have any Throw object selected (i.e., grenades or smoke grenades).

I know that selectWeapon can force a muzzle, but that's not my problem.

MandoMyWeapon does not show this either.  I tried adding weapon "Throw" to the list of weapons checked by MandoMyWeapon, but it appears that "Throw" does not work with his clever weaponDirection check code...

How can I detect if a player has currently selected a Grenade?
Title: Re: How to get the muzzle of the current selected weapon?
Post by: Spooner on 18 Dec 2008, 08:29:47
I am pretty sure you can't tell what weapon you are using (unless you use Mando_myWeapon, which is not 100% accurate , nor can you tell which muzzle or mode is selected on any weapon. Spent a lot of time trying to work it out myself ;P

Incidentally, you can force a firing mode only by using the SWITCHWEAPON (http://community.bistudio.com/wiki/ArmA:_Actions#SWITCHWEAPON) or SWITCHMAGAZINE  (http://community.bistudio.com/wiki/ArmA:_Actions#SWITCHMAGAZINE)actions (as far as I can tell, they are the same thing). This could be useful, for example, to respawn players using full-auto on weapons rather that default to semi-auto (or vica versa).
Title: Re: How to get the muzzle of the current selected weapon?
Post by: Worldeater on 18 Dec 2008, 13:15:36
Isn't there a way to read the text from idd #300, idc #118 (RscUnitInfoSoldier >> Weapon)?
Title: Re: How to get the muzzle of the current selected weapon?
Post by: Spooner on 19 Dec 2008, 00:07:23
Well, the only displays that exist at the start of the game in the SP editor, when I can see my mode/ammo count, are #0 (Not sure about this one), #12 (the map), #26 (editor) and #46 (which we use to capture key events; not sure what it is really for and it doesn't have any controls). Definitely no #300 anywhere to be seen.

However, the idea doesn't sound too illogical, but using this little script I didn't find any of this sort of info being readable:
Code: [Select]
for "_i" from 0 to 10000 do
{
if (not isNull (findDisplay _i)) then
{
_display = findDisplay _i;
_controls = [];
for "_j" from 0 to 10000 do
{
if (not isNull (_display displayCtrl _j)) then
{
_controls = _controls + [_j, ctrlText (_display displayCtrl _j)];
};
};

player sideChat str [_i, _controls];
(str [_i, _controls]) createVehicle [0, 0, 0]; // Easier to read in the arma.rpt
};
};

Shame though...
Title: Re: How to get the muzzle of the current selected weapon?
Post by: johnnyboy on 19 Dec 2008, 03:07:38
Spoon and WorldEater:  Thanks guys.  I guess this just ain't possible... :(
Title: Re: How to get the muzzle of the current selected weapon?
Post by: Worldeater on 19 Dec 2008, 17:10:19
Code: [Select]
(str [_i, _controls]) createVehicle [0, 0, 0]; // Easier to read in the arma.rpt

Nice trick! This combined with a simple bash one-liner finally gave me a debug log! Thanks, man! :)