Hollander Posted October 13, 2020 Share Posted October 13, 2020 (edited) Hello. I am doing a multiplayer mission where a record of destroyed (lost) aircraft is kept. For this counter, I need a check at: Crash - it hit the ground (Client) Pilot dead - The pilot died (Client) Pilot ejected - The pilot ejected (Client) How to do it through the lua script? I fulfill the condition for the destruction of the plane with the destruction triggers. But so that it does not work when changing roles, I set a condition: the altitude of the object is more than 5 meters. But then the trigger does not work if the player crashed himself (hit the ground). Edited October 13, 2020 by Hollander Link to comment Share on other sites More sharing options...
Hollander Posted October 13, 2020 Author Share Posted October 13, 2020 what is wrong here? Handler = {} function Handler:onEvent(event) if event.id == world.event.S_EVENT_CRASH and event.initiator == Unit.getByName('RED1') then return true else return false end end world.addEventHandler(Handler) Link to comment Share on other sites More sharing options...
Catweedle Posted October 13, 2020 Share Posted October 13, 2020 Only clients/players return a value (string) for getPlayerName(), so you could try something like this: function Handler:onEvent(event) if event.id == world.event.S_EVENT_CRASH then local ei = event.initiator if ei == nil then return end local playerName = ei:getPlayerName() -- ... if playerName ~= nil then -- ... end -- ... end end Link to comment Share on other sites More sharing options...
Hollander Posted October 13, 2020 Author Share Posted October 13, 2020 And if you make a choice of coalition units? Link to comment Share on other sites More sharing options...
Catweedle Posted October 14, 2020 Share Posted October 14, 2020 Retrieve group via getGroup() on event initiator, then getCoalition() on the retrieved group, which will give you values 0, 1 or 2 for the coalition. Link to comment Share on other sites More sharing options...
Recommended Posts