public static void drownCheck( SchedulerTask task )
{
try {
foreach ( Player p in Server.Players.Where( p => !p.Immortal ) ) {
if ( p.World != null ) //ignore console
{
if ( p.World.waterPhysics ) {
Position pos = new Position(
( short )( p.Position.X / 32 ),
( short )( p.Position.Y / 32 ),
( short )( ( p.Position.Z + 1 ) / 32 )
);
if ( p.WorldMap.GetBlock( pos.X, pos.Y, pos.Z ) == Block.Water ) {
if ( p.DrownTime == null || ( DateTime.UtcNow - p.DrownTime ).TotalSeconds > 33 ) {
p.DrownTime = DateTime.UtcNow;
}
if ( ( DateTime.UtcNow - p.DrownTime ).TotalSeconds > 30 ) {
p.TeleportTo( p.WorldMap.Spawn );
p.World.Players.Message( "{0}&S drowned and died", p.ClassyName );
}
} else {
p.DrownTime = DateTime.UtcNow;
}
}
}
}
} catch ( Exception ex ) {
Logger.Log( LogType.SeriousError, "" + ex );
}
}