Difference between revisions of "DCS func getNearestCargos"

From DCS World Wiki - Hoggitworld.com
(Created page with "{{Template:dcs_funcs |fName= getNearestCargos |vNum= 2.5.5 |par1= Unit |par2= |par3= |par4= |desc= Returns a table of friendly cargo objects indexe...")
(No difference)

Revision as of 20:50, 17 July 2019

Scripting Root

Envrioment: Mission Scripting
Function: getNearestCargos Added with: 2.5.5
Member Of: Unit
Syntax: table Unit.getNearestCargos(Class Self )
Description: Returns a table of friendly cargo objects indexed numerically and sorted by distance from the helicopter.

Returns nil if used on any object other than a helicopter.


Return Value: table
Return Example: A table of unit objects.
   {
       [1] = {
           ["id_"] = 16777728,
       },
   [2] = {
           ["id_"] = 16777984,
       },
   }
Examples: This could be used in a function to find the nearest ammo crate to a given helicopter:
   local cargo = Unit.getByName('whoopwhoop'):getNearestCargos
   for i = 1, cargo do
       if Object.getDesc(cargo[i]).typeName == 'ammo_cargo' then
           return cargo[i]
       end
   end
Related Functions: Unit Functions: isActive, getPlayerName, getID, getNumber, getCategoryEx, getObjectID, getController, getGroup, getCallsign, getLife, getLife0, getFuel, getAmmo, getSensors, hasSensors, getRadar, getDrawArgumentValue, getNearestCargos, enableEmission, getDescentCapacity

Object Functions: isExist, destroy, getCategory, getTypeName, getDesc, hasAttribute, getName, getPoint, getPosition, getVelocity, inAir

Coalition Object Functions: getCoalition, getCountry

Notes: