Jump to content

Get cannon ammo


EasyEB

Recommended Posts

local flight=FLIGHTGROUP:New("Group Name")
local nshells=flight:GetAmmoTot().Guns

Requires MOOSE develop branch version.

A warrior's mission is to foster the success of others.

i9-12900K | MSI RTX 3080Ti Suprim X | 128 GB Ram 3200 MHz DDR-4 | MSI MPG Edge Z690 | Samung EVO 980 Pro SSD | Virpil Stick, Throttle and Collective | MFG Crosswind | HP Reverb G2

RAT - On the Range - Rescue Helo - Recovery Tanker - Warehouse - Airboss

Link to comment
Share on other sites

  • 2 months later...

In case you're still in need for, or for anyone else who needs to know, I just got usage of getammo function.
Here a function I made to see how it returns values (but in purpose of checking WM's ammo). Gun ammo is the first [1] value returned, but when depleted the first entry is replaced by ammo that was in second entry. If you want to keep track of gun ammo only you could check if WeapTable[1]["desc"]["displayName"] is still equal to "M61_20_HE sans traceurs" (in my F18 exemple and in french), if not then gun ammo is zero.
I put 10 entries to eventually cover varied ammo on high hardpoint count aircraft.

 

missionCommands.addCommand('Check my ammo', nil, MA_Dec2Weapons)

 

function MA_Dec2Weapons()

        local Wingman = Unit.getByName('Blue F18c 1-1') --my aircraft unitName
        local WeapTable = Unit.getAmmo(Wingman)
        if WeapTable[1] and WeapTable[1]["count"] and WeapTable[1]["desc"]["displayName"] then
        trigger.action.outText('You have : ' .. WeapTable[1]["count"] .. ' ' .. WeapTable[1]["desc"]["displayName"] .. '.', 10)
        end
        if WeapTable[2] and WeapTable[2]["count"] and WeapTable[2]["desc"]["displayName"] then
        trigger.action.outText('' .. WeapTable[2]["count"] .. ' ' .. WeapTable[2]["desc"]["displayName"] .. '.', 10)
        end
        if WeapTable[3] and WeapTable[3]["count"] and WeapTable[3]["desc"]["displayName"] then
        trigger.action.outText('' .. WeapTable[3]["count"] .. ' ' .. WeapTable[3]["desc"]["displayName"] .. '.', 10)
        end
        if WeapTable[4] and WeapTable[4]["count"] and WeapTable[4]["desc"]["displayName"] then
        trigger.action.outText('' .. WeapTable[4]["count"] .. ' ' .. WeapTable[4]["desc"]["displayName"] .. '.', 10)
        end
        if WeapTable[5] and WeapTable[5]["count"] and WeapTable[5]["desc"]["displayName"] then
        trigger.action.outText('' .. WeapTable[5]["count"] .. ' ' .. WeapTable[5]["desc"]["displayName"] .. '.', 10)
        end
        if WeapTable[6] and WeapTable[6]["count"] and WeapTable[6]["desc"]["displayName"] then
        trigger.action.outText('' .. WeapTable[6]["count"] .. ' ' .. WeapTable[6]["desc"]["displayName"] .. '.', 10)
        end
        if WeapTable[7] and WeapTable[7]["count"] and WeapTable[7]["desc"]["displayName"] then
        trigger.action.outText('' .. WeapTable[7]["count"] .. ' ' .. WeapTable[7]["desc"]["displayName"] .. '.', 10)
        end
        if WeapTable[8] and WeapTable[8]["count"] and WeapTable[8]["desc"]["displayName"] then
        trigger.action.outText('' .. WeapTable[8]["count"] .. ' ' .. WeapTable[8]["desc"]["displayName"] .. '.', 10)
        end
        if WeapTable[9] and WeapTable[9]["count"] and WeapTable[9]["desc"]["displayName"] then
        trigger.action.outText('' .. WeapTable[9]["count"] .. ' ' .. WeapTable[9]["desc"]["displayName"] .. '.', 10)
        end
        if WeapTable[10] and WeapTable[10]["count"] and WeapTable[10]["desc"]["displayName"] then
        trigger.action.outText('' .. WeapTable[10]["count"] .. ' ' .. WeapTable[10]["desc"]["displayName"] .. '.', 10)
        end

end

AmmoCounter.jpg

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...