/**
  * Handles the Round_End event.
  *
  * @return void
  */
 public function handleRoundEnd()
 {
     $re = new RoundEvent();
     $re->map_id = $this->map->id;
     $re->current_round = $this->map->current_round;
     $re->type = 'round_ended';
     $re->data = ['time' => Carbon::now()];
     $re->save();
 }
Example #2
0
 /**
  * Handles the event.
  *
  * @param array $matches
  *
  * @return void
  */
 public function handle($matches)
 {
     return;
     list(, $side, $score) = $matches;
     if ($score == 0) {
         return;
     }
     if ($this->map->inWarmup() || $this->map->status == 4) {
         return;
     }
     if ($this->map->status == 3) {
         $re = new RoundEvent();
         $re->map_id = $this->map->id;
         $re->current_round = -1;
         $re->type = 'knife_round_win';
         $re->data = ['knife_winner_side' => $side];
         $re->save();
         $this->rcon->exec('mp_t_default_secondary "weapon_glock"; mp_ct_default_secondary "weapon_hkp2000";');
         $this->rcon->exec('mp_give_player_c4 1;');
         ++$this->map->status;
         $this->map->save();
         if ($side == 'TERRORIST') {
             $winner = $this->map->match->teamB;
         } else {
             $winner = $this->map->match->teamA;
         }
         $this->handler->chat->sendMessage("{$winner->name} won the knife round, type !stay or !switch to change sides.");
         $this->handler->timers['staySwitch'] = $this->handler->loop->addPeriodicTimer(10, function () use($winner) {
             $this->handler->chat->sendMessage("{$winner->name} won the knife round, type !stay or !switch to change sides.");
         });
         return;
     }
     if ($side == 'TERRORIST') {
         if ($this->map->current_side == 't') {
             $this->map->score_a = $score;
             $this->map->save();
         } else {
             $this->map->score_b = $score;
             $this->map->save();
         }
     } else {
         if ($this->map->current_side == 'ct') {
             $this->map->score_a = $score;
             $this->map->save();
         } else {
             $this->map->score_b = $score;
             $this->map->save();
         }
     }
     $this->handler->chat->sendMessage("{$this->map->match->teamA->name} {$this->map->score_a} - {$this->map->score_b} {$this->map->match->teamB->name}");
     if ($this->map->score_a + $this->map->score_b == $this->map->match->ruleset->max_rounds / 2) {
         ++$this->map->status;
         $this->map->save();
         $this->dispatch(InitHalftime::class);
     }
 }
 /**
  * Handles the Defused_The_Bomb event.
  *
  * @return void
  */
 public function handleDefusedTheBomb()
 {
     ++$this->player->defuses;
     $this->player->save();
     $re = new RoundEvent();
     $re->map_id = $this->map->id;
     $re->current_round = $this->map->current_round;
     $re->type = 'bomb_defused';
     $re->data = ['defuser' => $this->player->id];
     $re->save();
 }
Example #4
0
 /**
  * Handles the event.
  *
  * @param array $matches
  *
  * @return void
  */
 public function handle($matches)
 {
     $attacker = Player::where('steam_id', $matches[3])->where('map_id', $this->map->id)->first();
     $attacked = Player::where('steam_id', $matches[7])->where('map_id', $this->map->id)->first();
     if (is_null($attacker) || is_null($attacked)) {
         return;
     }
     ++$attacker->assists;
     $attacker->save();
     $re = new RoundEvent();
     $re->map_id = $this->map->id;
     $re->current_round = $this->map->score_a + $this->map->score_b + 1;
     $re->type = 'assisted_in_killing';
     $re->data = ['attacker' => $attacker->id, 'attacked' => $attacked->id];
     $re->save();
 }
Example #5
0
 /**
  * Handles the event.
  *
  * @param array $matches
  *
  * @return void
  */
 public function handle($matches)
 {
     $attacker = Player::where('steam_id', $matches[3])->where('map_id', $this->map->id)->first();
     $attacked = Player::where('steam_id', $matches[10])->where('map_id', $this->map->id)->first();
     if (is_null($attacker) || is_null($attacked)) {
         return;
     }
     ++$attacker->kills;
     ++$attacked->deaths;
     $re = new RoundEvent();
     $re->map_id = $this->map->id;
     $re->current_round = $this->map->score_a + $this->map->score_b + 1;
     $re->type = 'kill';
     $re->data = ['attacker' => $attacker->id, 'attacker_location' => $matches[5] . ' ' . $matches[6] . ' ' . $matches[7], 'attacked' => $attacked->id, 'attacked_location' => $matches[12] . ' ' . $matches[13] . ' ' . $matches[14], 'weapon' => $matches[15]];
     $re->save();
     if (Str::contains($matches[16], 'headshot')) {
         ++$attacker->headshots;
     }
     $attacker->save();
     $attacked->save();
 }
 /**
  * Handles the !switch command.
  *
  * @param array $matches
  *
  * @return void
  */
 public function handleSwitch($matches)
 {
     if ($this->map->status == 4) {
         $re = RoundEvent::where('map_id', $this->map->id)->where('type', 'knife_round_win')->first();
         if (is_null($re)) {
             return;
         }
         if ($re->data->knife_winner_side == $matches[4]) {
             $this->handler->chat->sendMessage('Sides will be swapped.');
             $this->rcon->exec('mp_swapteams;');
             $this->map->status = 5;
             $this->map->current_side = 't';
             $this->map->save();
             $this->handler->cancelTimer('staySwitch');
             $this->dispatch(StartWarmup::class);
         }
     }
 }