![]() |
#7
|
|||
|
|||
![]()
It looks I am in trouble with my script here too.
Again it works for hosted server killing my engine when required but does not work on dedicated server. First I used this line as you can see above in my message Code:
(actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng0TotalFailure); Then I tried to modify actor-damaging script to destroy player plane. The same thing happens. On a dedicated server this script damages abondoned aircrat but my modified methods do not work. But work on hosted server (when I am the server). OnPlaceEnter check where damagePlayerGroup((actor as AiAircraft)) does not work on a dedi. Code:
//checks limited aircraft showTestMsg(player); if (actor != null && actor is AiAircraft) { windowOfOp = 10; switch ((actor as AiAircraft).InternalTypeName()) { case "bob:Aircraft.Bf-109E-4": { current109s++; showTestMsg(player); // !!! test !!! if (current109s > allowed109s) // || current109s > 1) // !!! test !!! { damagePlayerGroup((actor as AiAircraft)); Timeout(12, () => { msgTooManyAircraft(player); showTestMsg(player); }); } break; } Code:
#region Destroy Actors Methods // by TheEnlightenedFlorist http://www.airwarfare.com/sow/index.php?option=com_kunena&func=view&catid=43&id=539&Itemid=54 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; } private void destroyPlane(AiAircraft aircraft) { if (aircraft != null && isAiControlledPlane(aircraft)) aircraft.Destroy(); } private void damageAiControlledPlane(AiActor actorMain) { foreach (AiActor actor in actorMain.Group().GetItems()) { if (actor == null || !(actor is AiAircraft)) return; AiAircraft aircraft = (actor as AiAircraft); if (!isAiControlledPlane(aircraft)) return; if (aircraft == null) return; aircraft.hitNamed(part.NamedDamageTypes.ControlsElevatorDisabled); aircraft.hitNamed(part.NamedDamageTypes.ControlsAileronsDisabled); aircraft.hitNamed(part.NamedDamageTypes.ControlsRudderDisabled); aircraft.hitNamed(part.NamedDamageTypes.FuelPumpFailure); int iNumOfEngines = (aircraft.Group() as AiAirGroup).aircraftEnginesNum(); for (int i = 0; i < iNumOfEngines; i++) { aircraft.hitNamed((part.NamedDamageTypes)Enum.Parse(typeof(part.NamedDamageTypes), "Eng" + i.ToString() + "TotalFailure")); } Timeout(240, () => { destroyPlane(aircraft); } ); } } // Ataros method private void destroyPlayerPlane(AiAircraft aircraft) { if (aircraft != null) aircraft.Destroy(); } private void damagePlayerGroup(AiActor actorMain) { foreach (AiActor actor in actorMain.Group().GetItems()) { if (actor == null ) // || !(actor is AiAircraft)) return; AiAircraft aircraft = (actor as AiAircraft); if (!isAiControlledPlane(aircraft)) { if (aircraft != null) { aircraft.hitNamed(part.NamedDamageTypes.ControlsElevatorDisabled); aircraft.hitNamed(part.NamedDamageTypes.ControlsAileronsDisabled); aircraft.hitNamed(part.NamedDamageTypes.ControlsRudderDisabled); aircraft.hitNamed(part.NamedDamageTypes.FuelPumpFailure); int iNumOfEngines = (aircraft.Group() as AiAirGroup).aircraftEnginesNum(); for (int i = 0; i < iNumOfEngines; i++) { aircraft.hitNamed((part.NamedDamageTypes)Enum.Parse(typeof(part.NamedDamageTypes), "Eng" + i.ToString() + "TotalFailure")); } //Timeout(60, () => // { destroyPlayerPlane(aircraft); } // ); } } } } #endregion Last edited by Ataros; 10-12-2011 at 09:43 PM. |
|
|