![]() |
#1
|
|||
|
|||
![]()
Hi all, first sorry for my english.
I have no idea of programming in c. But i have a cuestion. can someone make a script where ia is destroyed after 5 seconds of landing? THX |
#2
|
|||
|
|||
![]() Code:
using System; using System.Collections; using System.Collections.Generic; using maddox.game; using maddox.game.world; using maddox.GP; public class Mission : AMission { private bool IsDestroyable(AiAircraft aircraft) { bool Destroyable = true; //Check if actor is empty (no Player) if (aircraft.ExistCabin(0)) for (int i = 0; i < aircraft.Places(); i++) { if (aircraft.Player(i) != null) { Destroyable = false; break; } } return Destroyable; } public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft) { base.OnAircraftCrashLanded(missionNumber, shortName, aircraft); if(IsDestroyable(aircraft)) Timeout(5, () => { aircraft.Destroy(); }); } public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft) { base.OnAircraftLanded(missionNumber, shortName, aircraft); if (IsDestroyable(aircraft)) Timeout(5, () => { aircraft.Destroy(); }); } } |
#3
|
|||
|
|||
![]()
Thx.
But i have a problem. When create a flight with the triggers,not disappear when it lands ![]() |
#4
|
|||
|
|||
![]()
Ok, add this to the script:
Code:
public override void OnBattleStarted() { base.OnBattleStarted(); MissionNumberListener = -1; } Code:
using System; using System.Collections; using System.Collections.Generic; using maddox.game; using maddox.game.world; using maddox.GP; public class Mission : AMission { public override void OnBattleStarted() { base.OnBattleStarted(); MissionNumberListener = -1; } private bool IsDestroyable(AiAircraft aircraft) { bool Destroyable = true; //Check if actor is empty (no Player) if (aircraft.ExistCabin(0)) for (int i = 0; i < aircraft.Places(); i++) { if (aircraft.Player(i) != null) { Destroyable = false; break; } } return Destroyable; } public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft) { base.OnAircraftCrashLanded(missionNumber, shortName, aircraft); if(IsDestroyable(aircraft)) Timeout(5, () => { aircraft.Destroy(); }); } public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft) { base.OnAircraftLanded(missionNumber, shortName, aircraft); if (IsDestroyable(aircraft)) Timeout(5, () => { aircraft.Destroy(); }); } } |
#5
|
|||
|
|||
![]()
Ok Thx,
this nigh test the scrip |
![]() |
|
|