Home   Help Search Login Register  

Author Topic: Does the ammo command actually work?  (Read 990 times)

0 Members and 1 Guest are viewing this topic.

RedHouse

  • Guest
Does the ammo command actually work?
« on: 12 Jul 2005, 17:36:33 »
Try putting a fired event handler in for a unit, everytime he shoots, make sure u know wht magazine he has (for example M16), then do a hint messege something like this.

hint format ["%1", (unit ammo "M16")]

It says in the com ref that it returns the amount of shots the unit has left for that magazine, but all i keep getting is 0, it always returns 0.

Am I doing something wrong or is this an OFP problem?

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:Does the ammo command actually work?
« Reply #1 on: 12 Jul 2005, 17:48:55 »
see attached.

RedHouse

  • Guest
Re:Does the ammo command actually work?
« Reply #2 on: 13 Jul 2005, 00:19:02 »
ive found the problem; in the com ref it says u have to put the name of the magazine, i dunno if this is right, but it works for me if u put the name of the weapon ur fireing.

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Does the ammo command actually work?
« Reply #3 on: 13 Jul 2005, 01:37:12 »
Correct, you are supposed to give the weapon name, not the magazine.

This becomes a problem with weapons that use multiple ammo types, or weapons that have multiple muzzles. I haven't figured out the specifics yet, but I just ran into a problem where the ammo command was returning 0 when a grenadier shot all of his grenades (but still had m16 ammo).

EDIT

Heh, looks like I already figured this problem out in the past. Here is my comment I left on the command in the online com ref:

Quote
Actually, the syntax for this command is incorrect. Really it works like this:

unit ammo muzzle

Where "muzzle" is a weapon's muzzle name. Often this is the same as the weapon's name, but sometimes it is different. Weapons can have multiple muzzles, such as the m16+grenades.

You can find what muzzle you are firing by putting this in the player's init field:
Code: [Select]
this addEventHandler ["fired", {hint format [{Muzzle = "%1"}, _this select 2]}];


That would explain why my grenadiers were returning "0" ammo. I was asking for how much ammo was in their "primaryweapon"; which for a grenadier is "m16grenadelauncher"-- while his M16 muzzle is called "m16".
« Last Edit: 13 Jul 2005, 05:28:24 by General Barron »
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

RedHouse

  • Guest
Re:Does the ammo command actually work?
« Reply #4 on: 13 Jul 2005, 13:18:47 »
cheers, so the com ref is wrong its not magazine its muzzle