Home   Help Search Login Register  

Author Topic: bullets left on a magazine.  (Read 1248 times)

0 Members and 1 Guest are viewing this topic.

Offline Woolridge

  • Members
  • *
bullets left on a magazine.
« on: 21 Jan 2008, 18:42:52 »
Is there anyway to SET how many bullets are in the loaded magazine of a weapon???

With the ammo command, I can know how many bullets left I have in the magazine that is loaded on my weapon using a code like this one:

Code: [Select]
_weaps = weapons player
_weap = _weaps select 0
_bulls = player ammo _weap
hint format ["%1", _bulls]

So if I have an m16 and I have 5 bullets left in it, _bulls is 5.

but I need to know how to modify these value. (not the _bulls variable, but the number of bulletts left in the weapon).


I appreciate any ideas on the matter.

Thanks in advance

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: bullets left on a magazine.
« Reply #1 on: 21 Jan 2008, 20:24:05 »
Nope, unless you fire the weapon.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: bullets left on a magazine.
« Reply #2 on: 21 Jan 2008, 21:09:18 »
Sadly ArmA lacks the commands for some more advanced bullet/magazine/weapon handling natively.

It -would- be possible to sort of bypass this by making the whole magazine/ammo/shooting process more dependent on scripting. I.e., first have a script which essentially gives you endless ammo and reloads your weapon immediately upon discharge, and then have a virtual counter that "remembers" the amount of bullets you want the player to be able to shoot, and once that counter reaches zero, the magazine would be removed/some other magic would happen which would produce the "click" sound and force a reload.

But to be entirely frank, it'd be a lot of work in exchange for nothing much. What exactly do you need this for?

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline Woolridge

  • Members
  • *
Re: bullets left on a magazine.
« Reply #3 on: 21 Jan 2008, 22:52:56 »
I was preparing a "safe mode" script for the player's weapon. I mean (don't know the exact word in english) a button in your weapon used to turn the weapon in a "safe mode". When you turn "safe mode" ON, the weapon can't be fired unintentionally. In real life all weapons have this button, but ArmA it's not contempling it, and in some MP coop games it sucks when your teammate fires his weapon unintentionally and you lose the surprise element. So, my solution was:

1.-create one addaction attached to player, that gives it the possibility of turning on "safe mode". When you activate that action, I save in an array all player's magazines, then I remove all player's magazines and add them again. So, the result is that now you can't fire your weapon if you don't reload it.  :clap:

2.-Now appears another addaction to turn "safe mode" off. Now I do the same process, but with player's weapons, so all weapons get reloaded instantly and you can fire again.  :good:


PROBLEM: All magazines are now at 100% of its capacity, even if you had only 1 bullet per magazine, now you have 30 bullets in every magazine. :(

If i could set the number of ammo in the loaded magazine, I could store how many bullets has every magazine shifting them in its weapon in the first action, and then set the number of magazines left in every magazine with the same process in the second action.
Well, if there is no way to set the number of bullets in the weapon, my scripts will never work properly because they can be used to get infite ammo, and as a quick reload way.

Wolfrug, I think I understand your idea. I could change the weapon's mag every time it is shot with an addeventhandler, and every 30 shots make the player to reload it with an addaction for example, but I was looking for something very very simple to attach to every cooperative mission and very simple to understand for players. This idea would be not very effective because the number of bullets depends on every weapon (m240 has 100, m24 has 10 etc). The system that I was creating was perfect and working for every weapon, from sniper rifles with 5 bullets per magazine to mguns with 200 even for mods' weapons. It was only 2 files and one line to put in the init file of the mission and it looked smart and simple. This idea would probably work, but would be more complicated for the players and worked only with certain weapons. :(

Thanks anyway, i'll try to think in a way to make it possible.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: bullets left on a magazine.
« Reply #4 on: 21 Jan 2008, 23:09:40 »
Ahh....I see.

Well, here's a quick fix that utilises a known ArmA bug: basically after having removed then returned the primary weapon of a unit, you have to press "F" to switch back to "single" (or use the selectWeapon command to fix it). Try this code:

Code: [Select]
_weapon = primaryWeapon _unit;
_unit removeweapon _weapon;
_unit addweapon _weapon;

Note however that if the unit has other weapons, such as satchel charges or grenades, these will be selected instead: to prevent this you can obviously remove these and add them later, since THEY don't have any charges (they're just one shot, right?). Note that this could potentially be abused by people picking up grenades etc. and then removing the safety, giving them more magazines than they can actually carry. I'm sure you can figure some way around that though. :)

Hope that works out for you!

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"