Jump to content

Recommended Posts

Posted

Writing my first hook in the savedgames/scripts/hooks folder.

When a player kills an AI unit, i want to know if it was a ground, air, sea or static type.

catching the 'kill' game event, gives me access to the unittype.

I then try:

DCS.getUnitTypeAttribute( UnitType, 'category' )

 but this does not give me anything.

I tried:

DCS.getUnitTypeAttribute( UnitType, '"DisplayName"' ),

and this works, so the routine works, however i cannot find a list of what other strings i can access with the second parameter.

anyone figured this out?

 

Posted
2 hours ago, nighteyes2017 said:

DCS.getUnitTypeAttribute( UnitType, 'category' )

Where did you get that from? The DCS singleton isn't available in mission scripting, just on the server.

I recommend that you try to invoke

Object.getCategory(theUnit) to find out what general type of object you are dealing with 

Once that you have determined that it is of a type 1 (a Unit) perform 

local theGroup = Unit.getGroup(theUnit) to access the unit's group, and finally 

local theCat = Group.getCategory(theGroup) to find out if it's an aircraft, helo, ground, ship or train.

Why such a roundabout way? Because Lua isn't OOP, and some of the accessors in DCS scripting environment are quite fubar.

 

  • Recently Browsing   0 members

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