PDA

View Full Version : Planes despawn


nilsabc
01-03-2013, 03:14 PM
Hi i have a problem with AI planes they all follow a rout and after 15-30 min they have order to land and then the mission starts again it all works fine and the script to restart mission is working. But the planes who have landed are not despawning thats really a problem for the performance. Is there a script where i can define that the AI planes despawn after landing and parking in their box? Or am i missing something (I did not set KI to inactive). A other thing i noticed is that landed planes sometimes begin to start again and doing what ever they want i really need to fix that issue. I hope someone can help me and i thank you in advance

PS: Its a MP mission

Greatings

salmo
01-04-2013, 10:11 AM
public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftLanded(missionNumber, shortName, aircraft);

double DespawnAfter = 5 * 60; // seconds after landing
Timeout(DespawnAfter, () => // despawn after specified seconds
{
try { aircraft.Destroy(); }
catch { }
});
}

nilsabc
01-04-2013, 01:08 PM
Wow wounderfull good that there are such peple like you out there without you i would have been lost. I will test it :)

nilsabc
01-04-2013, 02:11 PM
OK i tried it and it didn't work script was marked as ok but in mission nothing happend when plane landed but i think its because i implemented that script into the main mission where no aircraft are placed i tried to get it into te sub mission where the aircrafts get spawned but i have a simple problem there :

I have no other script there and i am lost what do i need to do if i just want the single script
public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftLanded(missionNumber, shortName, aircraft);

double DespawnAfter = 5 * 60; // seconds after landing
Timeout(DespawnAfter, () => // despawn after specified seconds
{
try { aircraft.Destroy(); }
catch { }
});
}

to work without anything else because i failed to achieve that

salmo
01-06-2013, 10:14 AM
Some scripting commands don't work from sub-missions so as a general rule put your scripts in your main mission. Sounds like you're missing a 'missionlistener' that will watch for your submission events. Try this in your main script file.


public override void OnBattleStarted()
{
base.OnBattleStarted();
MissionNumberListener = -1;
}