![]() |
|
|
|
#1
|
||||
|
||||
|
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);
});
}
}
}
Last edited by ZaltysZ; 04-20-2011 at 07:26 PM. Reason: Code change |
|
#2
|
|||
|
|||
|
WOW! Thanks a lot!!!
|
|
#3
|
|||
|
|||
|
Quote:
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);
});
}
}
|
|
#4
|
|||
|
|||
|
HI Squoag,
I tried your version in nthe post above and it despawned the plane if I changed from pilot to a gunners position. I tested this on my own 'server' and in single player. Obviously in MP this would not be desireable! |
|
#5
|
|||
|
|||
|
Hi Flashman,
Are you 100% sure that you used the second code block in my post and not the first? What you're seeing is very symptomatic of the first code block in my post. I put it there as a before/after for the original author but perhaps I should mark it more clearly... |
|
#6
|
|||
|
|||
|
Quote:
Im pretty sure I tried both but truth be told you have me wondering now.... I will try this again when I get the time and see if it works for me. Please note: i tried this on my own 'server' not on the Syndicate server. |
|
#7
|
|||
|
|||
|
Quote:
Will test on Australian Skies tomorrow EDIT: This works for me, thanks No457_Mako & No457_Squog, has helped with server stability. Ran 3 maps no worries, we were having issues with loading new maps before this Worked with Position swap ONLINE in the bf 110 as well. Matoni Last edited by SC/JG Matoni; 05-02-2011 at 03:03 PM. |
![]() |
|
|