Difference between revisions of "DCS event shot"
From DCS World Wiki - Hoggitworld.com
m (1 revision imported) |
|||
| Line 8: | Line 8: | ||
|desc= Occurs whenever any unit in a mission fires a weapon. But not any machine gun or autocannon based weapon, those are handled by [[DCS_event_shooting_start|shooting_start.]] | |desc= Occurs whenever any unit in a mission fires a weapon. But not any machine gun or autocannon based weapon, those are handled by [[DCS_event_shooting_start|shooting_start.]] | ||
| − | |||
| − | |||
| − | |||
|form= The shot event table is in the following format. | |form= The shot event table is in the following format. | ||
| Line 17: | Line 14: | ||
id = 1, | id = 1, | ||
time = Time, | time = Time, | ||
| − | initiator = | + | initiator = [[DCS_Class_Object|Object]], |
| − | weapon = Weapon | + | weapon = [[DCS_Class_Weapon|Weapon]] |
} | } | ||
| − | |exam= | + | |exam= The following creates a message box stating the unit name has fired a weapon with the given name. If the weapon object returns a target then that target will also be displayed. |
| + | local e = {} | ||
| + | function e:onEvent(event) | ||
| + | if event.id == 1 then | ||
| + | local m = {} | ||
| + | m[#m+1] = event.initiator:getName() | ||
| + | m[#m+1] = ' has fired a ' | ||
| + | m[#m+1] = event.weapon:getDisplayName() | ||
| + | local tgt = event.weapon:getTarget() | ||
| + | if tgt then | ||
| + | m[#m+1] = ' at a target ' | ||
| + | m[#m+1] = tgt:getTypeName() | ||
| + | end | ||
| + | trigger.action.outText(table.concat(m), 60) | ||
| + | end | ||
| + | end | ||
| + | world.addEventHandler(e) | ||
|notes= | |notes= | ||
| − | |||
| − | |||
| − | |||
}} | }} | ||
Revision as of 01:39, 5 March 2022
