Jump to content

Recommended Posts

Posted
I tried to use the kill event, but I found that it couldn't find the event.target. According to https://wiki.hoggitworld.com/view/DCS_event_kill, the event table should have the following members when id=29:

 

Event = {
id = 29,
time = Time,
initiator = Unit,
weapon = Weapon,
target = Unit,
weapon_name = string,
}

 

However, when I executed a test script in the mission using doscriptfile:

 

env.setErrorMessageBoxEnabled(true)
local e = {}
function e:onEvent(event)
  if event.id == 29 then -- kill
    MessageToAll("type: " .. tostring(type(event)), 10, "DEBUG")
    MessageToAll("id: " .. tostring(event.id), 10, "DEBUG")
    MessageToAll("Time: " .. tostring(event.time), 10, "DEBUG")
    MessageToAll("Initiator: " .. tostring(event.initiator), 10, "DEBUG")
    MessageToAll("Weapon: " .. tostring(event.weapon), 10, "DEBUG")
    MessageToAll("Target: " .. tostring(event.target), 10, "DEBUG")
    MessageToAll("weapon_name: " .. tostring(event.weapon_name), 10, "DEBUG")
  end
end
world.addEventHandler(e)

 

The result is as the following image.
How can i use 'kill' event correctly?
 

killeventtest.png

Posted
51 minutes ago, deathgun said:

I tried to use the kill event, but I found that it couldn't find the event.target.

This is because there can be kill events that do not have a 'target': usually these are scenery (map) objects (i.e. not static objects nor units) or weapons like missiles from SAMs etc. So simply make sure that if target is nil, you then skip that kill event. Likewise, make sure that - before you access it - check that the target (if it exists) has a group: static objects do not belong to groups, and trying to invoke getGroup() from such an object will lead to an error.

 

Posted (edited)
3 hours ago, deathgun said:

S-300 LN. It's not a static objects.

That would be the SAM missile I believe I mentioned - or did you kill the launcher? That would be indeed unusual.

Edited by cfrag
Posted
20 hours ago, cfrag said:

That would be the SAM missile I believe I mentioned - or did you kill the launcher? That would be indeed unusual.

 

Yep... I kill one S-300 Launcher in a M1A2.

Now I'm use EVENTHANDLER in M.O.O.S.E framework to handle 'kill' event instead of the DCS one. It works great and i can get the killer when the 'kill' event is triggered

  • Recently Browsing   0 members

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