Just a guess: gpPlayer() returns null if you are hosting it on a dedicated server and gpPlayer().Place() returns null if the player is not within an vehicle.
Code:
private void DoDamage()
{ // Script that triggered an accidental damage to the player plane
// Author: FG28_Kodiak Modified by: Salmo
// Ref: http://forum.1cpublishing.eu/showthread.php?t=22184
if(GamePlay.gpPlayer() != null && GamePlay.gpPlayer().Place() != null && GamePlay.gpPlayer().Place() is AiAircraft)
{
PlayerPlane = (AiAircraft)GamePlay.gpPlayer().Place();
...
}
}