Fulqrum Publishing Home   |   Register   |   Today Posts   |   Members   |   UserCP   |   Calendar   |   Search   |   FAQ

Go Back   Official Fulqrum Publishing forum > Fulqrum Publishing > IL-2 Sturmovik: Cliffs of Dover > FMB, Mission & Campaign builder Discussions

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #23  
Old 05-01-2011, 03:14 PM
No457_Squog No457_Squog is offline
Registered Member
 
Join Date: Mar 2010
Location: Melbourne, Australia
Posts: 10
Default

Quote:
Originally Posted by ZaltysZ View Post
Script for despawning planes without humans inside. Multicrew friendly.

Code:
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

public class  Mission : AMission
{
	public void _DespawnEmptyPlane(AiActor actor)
	{
					if (actor == null)
						{ return;}

					Player[] Players = GamePlay.gpRemotePlayers();
					
					bool PlaneIsEmpty = true;
					
					foreach (Player i in Players)
					{	
						if ((i.Place() as AiAircraft) == (actor as AiAircraft))
							{ 
								PlaneIsEmpty = false;
								break;
							}
					}
					
					if (PlaneIsEmpty)
						{ (actor as AiAircraft).Destroy(); }
	}

    public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceLeave(player, actor, placeIndex);
        Timeout(1, () =>
        {
         	_DespawnEmptyPlane(actor);
        });
    }
}
}
No457_Mako & myself tweaked this code so that the server is included in the workings. The Server isn't listed in the GamePlay.gpRemotePlayers() array.
Code:
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

public class  Mission : AMission
{
	public void _DespawnEmptyPlane(AiActor actor)
	{
		if (actor == null)
			return;
		Player[] Players = GamePlay.gpRemotePlayers();
		bool PlaneIsEmpty = true;
		foreach (Player i in Players) {
			if (((i.Place() as AiAircraft) == (actor as AiAircraft)) || ((GamePlay.gpPlayer().Place() as AiAircraft) == (actor as AiAircraft))) {
				PlaneIsEmpty = false;
				break;
			}
		}
		if (PlaneIsEmpty) {
			(actor as AiAircraft).Destroy();
		}
	}

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


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:04 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.