Elphaba Posted March 16 Share Posted March 16 I have a player manager that records when players join and leave. The join events are either birth or on enter unit. The leave events are either dead pilot or leave unit On trying to handle the onEvent for the leaving events, the event specifies that the initiator is a Unit. The problem is, that I have to filter out players from AI units. So the way to do that is getPlayerName() on the Unit. But when I try and cast the event.initiator : Unit.getByName(event.initiator:getName()) then I get an error because the unit has already been destroyed in the game engine! What's worse is that in the event the player changes slot or even changes coalition, the BIRTH event for the new aircraft happens BEFORE the LEAVE_UNIT event for the previous aircraft!?! @Exorcet Surely there's something screwy going on here? Link to comment Share on other sites More sharing options...
Exorcet Posted March 16 Share Posted March 16 I don't have experience with trying to create a player manager, but if the event handler ends up pointing to a non existent unit you might try checking for a change in the existence of the unit. So if unit1 existed previously but searching for it later during an event check returns nil, count that as leaving. I'm not sure if you're doing this already. It will make things more cumbersome, but unless some kind of memory is added to the event handler to keep it from referring to destroyed objects it might be the only way to record leave events. 1 Awaiting: DCS F-15C Win 10 i5-9600KF 4.6 GHz 64 GB RAM RTX2080Ti 11GB -- Win 7 64 i5-6600K 3.6 GHz 32 GB RAM GTX970 4GB -- A-10C, F-5E, Su-27, F-15C, F-14B, F-16C missions in User Files Link to comment Share on other sites More sharing options...
Elphaba Posted March 17 Author Share Posted March 17 (edited) 16 hours ago, Exorcet said: I don't have experience with trying to create a player manager, but if the event handler ends up pointing to a non existent unit you might try checking for a change in the existence of the unit. So if unit1 existed previously but searching for it later during an event check returns nil, count that as leaving. I'm not sure if you're doing this already. It will make things more cumbersome, but unless some kind of memory is added to the event handler to keep it from referring to destroyed objects it might be the only way to record leave events. But why does the new birth happen before the previous aircraft's leave? That makes no sense. And surely the event leave - as it does contain data to a unit that in the sim no longer exists - that unit shouldn't have been removed from the backend before all the necessary events have completed, right? Otherwise - like now, it's utterly useless and asking for trouble if the things it's referencing are already gone. Shouldn't these events be firing for the scripting engine at a point where all the referenced objects still exist - the the scripter / mission designer and do what they need to first, and then the back end removes them as it completes its actions? There seems to be a rather larger issue at hand if this is the way it's been architected... Edited March 17 by Elphaba Link to comment Share on other sites More sharing options...
Exorcet Posted March 17 Share Posted March 17 Yes those all look like issues with how these events are being handled internally in the sim, but as just another DCS user I can't do anything about it other than try to offer a workaround. Hopefully the issue is seen by ED and addressed. I can't say for sure but since the mission debrief log records all the event info in a mission, it shouldn't be very hard to pull unit info that belongs to a destroyed unit. The information has to be recorded somewhere if the debrief log contains it. Awaiting: DCS F-15C Win 10 i5-9600KF 4.6 GHz 64 GB RAM RTX2080Ti 11GB -- Win 7 64 i5-6600K 3.6 GHz 32 GB RAM GTX970 4GB -- A-10C, F-5E, Su-27, F-15C, F-14B, F-16C missions in User Files Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now