Home   Help Search Login Register  

Author Topic: How to get the muzzle of the current selected weapon?  (Read 2298 times)

0 Members and 1 Guest are viewing this topic.

Offline Goullou

  • Members
  • *
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.
Si vis pacem, para bellum.

Offline Goullou

  • Members
  • *
Re: How to get the muzzle of the current selected weapon?
« Reply #1 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 ...
« Last Edit: 02 Apr 2008, 21:49:35 by Goullou »
Si vis pacem, para bellum.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: How to get the muzzle of the current selected weapon?
« Reply #2 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:
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: How to get the muzzle of the current selected weapon?
« Reply #3 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?
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: How to get the muzzle of the current selected weapon?
« Reply #4 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 or 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).
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: How to get the muzzle of the current selected weapon?
« Reply #5 on: 18 Dec 2008, 13:15:36 »
Isn't there a way to read the text from idd #300, idc #118 (RscUnitInfoSoldier >> Weapon)?
try { return true; } finally { return false; }

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: How to get the muzzle of the current selected weapon?
« Reply #6 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...
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: How to get the muzzle of the current selected weapon?
« Reply #7 on: 19 Dec 2008, 03:07:38 »
Spoon and WorldEater:  Thanks guys.  I guess this just ain't possible... :(
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: How to get the muzzle of the current selected weapon?
« Reply #8 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! :)

try { return true; } finally { return false; }