hc_wolf
04-23-2012, 05:48 AM
I am having a bit of trouble getting this to subtract from the allowable flying planes on Crash land. It is usually easy when Actor is present. But how do I do it when player is null.
Below if a spitIIa crashlands then it should subtract 1 and the int allowedSpitIIas = 9;
The rest of the code works but it does not subtract from the allowedSpitIIas
Any idea?
int allowedSpitIIas = 10;
int currentSpitIIas = 0;
int allowed109s = 10;
int current109s = 0;
public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftCrashLanded(missionNumber, shortName, aircraft);
Timeout(120, () =>
{ destroyPlane(aircraft); });
Player player = null;
if (player != null && player is AiAircraft)
{
switch ((player as AiAircraft).InternalTypeName())
{
case "bob:Aircraft.SpitfireMkIIa":
currentSpitIIas--;
allowedSpitIIas -= 1;
break;
case "bob:Aircraft.Bf-109E-4":
currentSpitIIas--;
allowed109s -= 1;
break;
}
}
if (aircraft.Player(0) != null)
{
for (int i = 0; i < aircraft.Places(); i++)
{
if (aircraft.Player(i) != null)
{
player = aircraft.Player(i);
break;
}
}
if (player != null)
GamePlay.gpHUDLogCenter(new Player[] { player }, "Looks like you are walking home...", new object[] { });
}
}
Below if a spitIIa crashlands then it should subtract 1 and the int allowedSpitIIas = 9;
The rest of the code works but it does not subtract from the allowedSpitIIas
Any idea?
int allowedSpitIIas = 10;
int currentSpitIIas = 0;
int allowed109s = 10;
int current109s = 0;
public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftCrashLanded(missionNumber, shortName, aircraft);
Timeout(120, () =>
{ destroyPlane(aircraft); });
Player player = null;
if (player != null && player is AiAircraft)
{
switch ((player as AiAircraft).InternalTypeName())
{
case "bob:Aircraft.SpitfireMkIIa":
currentSpitIIas--;
allowedSpitIIas -= 1;
break;
case "bob:Aircraft.Bf-109E-4":
currentSpitIIas--;
allowed109s -= 1;
break;
}
}
if (aircraft.Player(0) != null)
{
for (int i = 0; i < aircraft.Places(); i++)
{
if (aircraft.Player(i) != null)
{
player = aircraft.Player(i);
break;
}
}
if (player != null)
GamePlay.gpHUDLogCenter(new Player[] { player }, "Looks like you are walking home...", new object[] { });
}
}