ChaosRifle Posted July 17, 2024 Posted July 17, 2024 events are returning objects that don't exist, either because they are cleaned up or just broken returns. They should be returning data on the object in question, or, at least returning nil (though that would defeat the point of the events) if an object does not exist. instead, it crashes the script entirely. IE: Event.id = 1 returns event.weapon, which if you use event.weapon:getTarget() you are given a unit object that often does not exist - the object appears valid in a logging function, but if you use Unit.getTypeName(event.weapon:getTarget()) or any other Unit.getdata() function on the unit object, it errors out saying "Unit doesn't exist". similarly, event.id = 30 returns event.initiator, where you can log the data and see a seemingly normal unit object. however, again, if we use Unit.getPlayerName(event.initiator) (yes nonplayers return nil, i know, this is an error, not nil.) or Unit.getTypeName(event.initiator) it errors the script, again with "Unit doesn't exist". This happens with all Unit class functions operated on the returned event.initiator. similarly, event.id = 8 returns event.initiator, just like event.id = 30, doing any Unit class functions is totally broken. Error is "Unit doesn't exist" if you try to use them on it. I also believe (its been a few days of trying various things, so I am only 99% sure here) that event.id = 21 also has this issue. The initiator passed will not be able to be operated on with Unit class functions. Again, error is "Unit doesn't exist" All of these issues started with 2.9.6, and worked fine before. My theory right now is it is passing wrong data, or the backend of DCS is cleaning things up and removing them before our event callbacks run, resulting in code not working. 1
rob10 Posted July 17, 2024 Posted July 17, 2024 Is this the same as what you're describing? Just started to happen to me and I'm just starting to try and figure out what's causing it. Always seems to happen on weapon impact. 1
ChaosRifle Posted July 18, 2024 Author Posted July 18, 2024 correct. I have the popups disabled on mine and tend to just look at the log file, but yes.
Fallen_Tyrael Posted July 20, 2024 Posted July 20, 2024 I too am having the same issue with the exact same error as rob10. 1
ChaosRifle Posted July 23, 2024 Author Posted July 23, 2024 (edited) latest hotfix at time of writing has fixed a few, in some cases, but not all, of these instances. Namely, event exit unit is still giving a bad unit object. (dynamic spawn unit, untested if slot units still break too) Edited July 24, 2024 by ChaosRifle
ChaosRifle Posted August 10, 2024 Author Posted August 10, 2024 Issue still present after latest patch. Namely, event world.event.S_EVNT_DEAD is still returning units that do not exist. My guess is its due to them being a different model, and thus probably different Id, but it is still making that event basically useless unless. if event.id == world.event.S_EVENT_DEAD then -- Event = { -- id = 8, -- time = Time, -- initiator = Object, -- } local playerName = Unit.getPlayerName(event.initiator) in the snippit of code, unit.getPlayerName should return nil if ai, or a player if a player. it crashes the code saying unit doesnt exist, still. was not the case before 2.9.6. Same for any other Unit class functions run on this.
Pikey Posted August 31, 2024 Posted August 31, 2024 What are you doing with the group in your code after the death? Nil is normal, its always been there in DCS and especially common in timing and heavy load. It should be handled and expected in code, that's what any reasonable code would do - have a look at nil checks in moose.lua for example. The real question is what can't you get, what are you trying to do? ED are way more interested in the value of any change in terms of what you can achieve, rather than correcting your code remotely and you will be struggling uphill with another 15 year thread unless it is illustrated. ___________________________________________________________________________ SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *
Recommended Posts