PDA

View Full Version : 4.5 - C# way of detecting players have left the aircraft seems to no longer work



TWC_Flug
Dec-17-2017, 13:19
Hey, I've noticed in 4.5/Blitz, in both in the TWC missions & ATAG missions, that the previous method of detecting that a live player has left the aircraft, seems to no longer work.

Does anyone have the solution to this?

ATAG_Ezzie
Dec-17-2017, 14:31
Hey, I've noticed in 4.5/Blitz, in both in the TWC missions & ATAG missions, that the previous method of detecting that a live player has left the aircraft, seems to no longer work.

Does anyone have the solution to this?

Hey Flug - i think Freya posted a thread about the despawn not working and this might be related perhaps?

And then i think i saw Colander posted that it might have been fixed but i was in skim read mode so could be mistaken.

Ezzie

ATAG_Freya
Dec-17-2017, 15:25
Yeah I was having issues but twins are despawning on the server now, not sure what Colander puts in the server - but it worked! (TY Colander!!)

Still, without that it seems to me that scripting should have been able to do it, albeit I am not too savvy with c# or any code stuff.

Is one of these the ones you mean Flug, or related to it? It seemed to me that the .Destroy thing wasn't working on twin engines...







private bool isAiControlledPlane(AiAircraft aircraft)
{
if (aircraft == null)
return false;

//check if a player is in any of the "places"
for (int i = 0; i < aircraft.Places(); i++)
if (aircraft.Player(i) != null)
return false;

return true;
}

public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceLeave(player, actor, placeIndex);
Timeout(1, () =>
{ damageAiControlledPlane(actor); }
);
}

public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> damages)
{
base.OnActorDead(missionNumber, shortName, actor, damages);
if (actor != null && actor is AiGroundActor)
Timeout(300, () => { (actor as AiGroundActor).Destroy(); ; });
}

TWC_Flug
Dec-18-2017, 20:49
Yeah I was having issues but twins are despawning on the server now, not sure what Colander puts in the server - but it worked! (TY Colander!!)

Still, without that it seems to me that scripting should have been able to do it, albeit I am not too savvy with c# or any code stuff.

Is one of these the ones you mean Flug, or related to it? It seemed to me that the .Destroy thing wasn't working on twin engines...

I haven't had time to investigate thoroughly. But yes, it is something in the combination of detecting whether a plane as a player in it or is AI, which is usually done onPlaceLeave, and then damaging the aircraft immediately when the players leave (which keeps AI from assuming control and flying off with it), and then destroying the aircraft.

These seem to be fairly standard procedures that most servers follow to stop AI from assuming control of an aircraft when a player leaves, and also to de-spawn aircraft at some point after all players have left it.

Just for example I left a Spitfire in one our servers a day or two ago and then watched as AI assumed control and taxied, then took off.

That's not supposed to happen!

Salmo
Dec-18-2017, 23:02
There were no changes to script coding in TFS4.5. Unsure why previously working routines should now be failing. Flug, can you post the the code that is failing please.

Pitti
Jan-16-2018, 18:09
Despaning seems to work for me, but I found out that the functions/events OnAircraftLanded and OnAircraftCrashLanded are not getting called any more in multiplayer since CloD 4.5 Blitz.
I just opened a issue in the bugtracker: https://www.tfbt.nuvturais.de/issues/1052

TWC_Flug
Jan-19-2018, 16:03
There were no changes to script coding in TFS4.5. Unsure why previously working routines should now be failing. Flug, can you post the the code that is failing please.

FYI I noticed this a few times early on, it seemed to be particularly with twin engine aircraft. But I really haven't noticed it lately. So it was either something that was fixed somehow or it wasn't really happening as I thought in the first few days.