fCraft.SchedulerTask.Stop C# (CSharp) Method

Stop() public method

Stops the task, and removes it from the schedule.
public Stop ( ) : SchedulerTask
return SchedulerTask
        public SchedulerTask Stop()
        {
            IsStopped = true;
            return this;
        }

Usage Example

Example #1
0
 public void Interval( SchedulerTask task )
 {
     //check to stop Interval
     if ( _world.gameMode != GameMode.ZombieSurvival || _world == null ) {
         _world = null;
         task.Stop();
         return;
     }
     if ( !_started ) {
         if ( startTime != null && ( DateTime.Now - startTime ).TotalMinutes > 1 ) {
             /*if (_world.Players.Length < 3){
                 _world.Players.Message("&WThe game failed to start: 2 or more players need to be in the world");
                 Stop(null);
                 return;
             }*/
             ShufflePlayerPositions();
             _started = true;
             RandomPick();
             lastChecked = DateTime.Now;
             return;
         }
     }
     //calculate humans
     _humanCount = _world.Players.Where( p => p.iName != _zomb ).Count();
     //check if zombies have won already
     if ( _started ) {
         if ( _humanCount == 1 && _world.Players.Count() == 1 ) {
             _world.Players.Message( "&WThe Zombies have failed to infect everyone... &9HUMANS WIN!" );
             Stop( null );
             return;
         }
         if ( _humanCount == 0 ) {
             _world.Players.Message( "&WThe Humans have failed to survive... &9ZOMBIES WIN!" );
             Stop( null );
             return;
         }
     }
     //check if 5mins is up and all zombies have failed
     if ( _started && startTime != null && ( DateTime.Now - startTime ).TotalMinutes > 6 ) {
         _world.Players.Message( "&WThe Zombies have failed to infect everyone... &9HUMANS WIN!" );
         Stop( null );
         return;
     }
     //if no one has won, notify players of their status every 31s
     if ( lastChecked != null && ( DateTime.Now - lastChecked ).TotalSeconds > 30 ) {
         _world.Players.Message( "&WThere are {0} humans", _humanCount.ToString() );
         foreach ( Player p in _world.Players ) {
             if ( p.iName == _zomb ) p.Message( "&8You are " + _zomb );
             else p.Message( "&8You are a Human" );
         }
         lastChecked = DateTime.Now;
     }
 }
All Usage Examples Of fCraft.SchedulerTask::Stop